@wildo-ai/platform-config-lib 1.1.5 → 1.1.7
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/index.d.ts.map +1 -1
- package/dist/esm/_unimplemented/index.js.map +1 -1
- package/dist/esm/_unimplemented/soft-warn.d.ts.map +1 -1
- package/dist/esm/_unimplemented/soft-warn.js.map +1 -1
- package/dist/esm/_unimplemented/unimplemented-field-warning.d.ts.map +1 -1
- package/dist/esm/_unimplemented/unimplemented-field-warning.js.map +1 -1
- package/dist/esm/bootstrap/application-backend-env.contracts.d.ts.map +1 -1
- 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.d.ts.map +1 -1
- package/dist/esm/bootstrap/bootstrap-planner.js.map +1 -1
- package/dist/esm/bootstrap/bootstrap.contracts.d.ts +3 -2
- package/dist/esm/bootstrap/bootstrap.contracts.d.ts.map +1 -1
- package/dist/esm/bootstrap/bootstrap.contracts.js +3 -2
- package/dist/esm/bootstrap/bootstrap.contracts.js.map +1 -1
- package/dist/esm/bootstrap/bootstrap.schemas.d.ts +47 -0
- package/dist/esm/bootstrap/bootstrap.schemas.d.ts.map +1 -1
- package/dist/esm/bootstrap/bootstrap.schemas.js +8 -0
- package/dist/esm/bootstrap/bootstrap.schemas.js.map +1 -1
- package/dist/esm/bootstrap/platform-runtime-env.contracts.d.ts +12 -1
- package/dist/esm/bootstrap/platform-runtime-env.contracts.d.ts.map +1 -1
- package/dist/esm/bootstrap/platform-runtime-env.contracts.js +12 -0
- package/dist/esm/bootstrap/platform-runtime-env.contracts.js.map +1 -1
- package/dist/esm/bootstrap/platform-store-preconnect.d.ts +37 -0
- package/dist/esm/bootstrap/platform-store-preconnect.d.ts.map +1 -0
- package/dist/esm/bootstrap/platform-store-preconnect.js +43 -0
- package/dist/esm/bootstrap/platform-store-preconnect.js.map +1 -0
- package/dist/esm/bootstrap/runtime-backing-service-access.d.ts.map +1 -1
- package/dist/esm/bootstrap/runtime-backing-service-access.js +8 -4
- package/dist/esm/bootstrap/runtime-backing-service-access.js.map +1 -1
- package/dist/esm/bootstrap/runtime-network-policy.d.ts.map +1 -1
- package/dist/esm/bootstrap/runtime-network-policy.js.map +1 -1
- package/dist/esm/bootstrap/runtime-network-topology.d.ts.map +1 -1
- package/dist/esm/bootstrap/runtime-network-topology.js.map +1 -1
- package/dist/esm/bootstrap/runtime-platform-access.d.ts.map +1 -1
- package/dist/esm/bootstrap/runtime-platform-access.js.map +1 -1
- package/dist/esm/bootstrap/runtime-principal.contracts.d.ts.map +1 -1
- package/dist/esm/bootstrap/runtime-principal.contracts.js.map +1 -1
- package/dist/esm/bootstrap/runtime-topology.contracts.d.ts +36 -3
- package/dist/esm/bootstrap/runtime-topology.contracts.d.ts.map +1 -1
- package/dist/esm/bootstrap/runtime-topology.contracts.js +36 -13
- package/dist/esm/bootstrap/runtime-topology.contracts.js.map +1 -1
- package/dist/esm/bootstrap/wildo-owner-organization.contracts.d.ts.map +1 -1
- package/dist/esm/bootstrap/wildo-owner-organization.contracts.js.map +1 -1
- package/dist/esm/config-authoring.entry.d.ts.map +1 -1
- 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 +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/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.map +1 -1
- package/dist/esm/lockfile/canonical-json.js.map +1 -1
- package/dist/esm/lockfile/lockfile-io.d.ts +7 -1
- package/dist/esm/lockfile/lockfile-io.d.ts.map +1 -1
- package/dist/esm/lockfile/lockfile-io.js +17 -3
- package/dist/esm/lockfile/lockfile-io.js.map +1 -1
- package/dist/esm/lockfile/materialize-infra-section.d.ts +27 -6
- package/dist/esm/lockfile/materialize-infra-section.d.ts.map +1 -1
- package/dist/esm/lockfile/materialize-infra-section.js +23 -10
- package/dist/esm/lockfile/materialize-infra-section.js.map +1 -1
- package/dist/esm/lockfile/wildo-saas-lock.shared.schemas.d.ts +455 -6
- package/dist/esm/lockfile/wildo-saas-lock.shared.schemas.d.ts.map +1 -1
- package/dist/esm/lockfile/wildo-saas-lock.shared.schemas.js +27 -0
- package/dist/esm/lockfile/wildo-saas-lock.shared.schemas.js.map +1 -1
- package/dist/esm/project-config/application-public-pricing-catalog.loader.d.ts +13 -0
- package/dist/esm/project-config/application-public-pricing-catalog.loader.d.ts.map +1 -0
- package/dist/esm/project-config/application-public-pricing-catalog.loader.js +56 -0
- package/dist/esm/project-config/application-public-pricing-catalog.loader.js.map +1 -0
- package/dist/esm/project-config/define-framework-config.d.ts.map +1 -1
- package/dist/esm/project-config/define-framework-config.js.map +1 -1
- package/dist/esm/project-config/define-infra-env-config.d.ts +0 -27
- package/dist/esm/project-config/define-infra-env-config.d.ts.map +1 -1
- package/dist/esm/project-config/define-infra-env-config.js +0 -2
- package/dist/esm/project-config/define-infra-env-config.js.map +1 -1
- package/dist/esm/project-config/define-minion-config.d.ts.map +1 -1
- package/dist/esm/project-config/define-minion-config.js.map +1 -1
- package/dist/esm/project-config/define-saas-config.d.ts +52 -0
- package/dist/esm/project-config/define-saas-config.d.ts.map +1 -1
- package/dist/esm/project-config/define-saas-config.js +65 -15
- package/dist/esm/project-config/define-saas-config.js.map +1 -1
- package/dist/esm/project-config/define-worker-config.d.ts.map +1 -1
- 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.map +1 -1
- package/dist/esm/project-config/index.d.ts +3 -0
- package/dist/esm/project-config/index.d.ts.map +1 -1
- package/dist/esm/project-config/index.js +3 -0
- package/dist/esm/project-config/index.js.map +1 -1
- package/dist/esm/project-config/loader.d.ts +11 -0
- package/dist/esm/project-config/loader.d.ts.map +1 -1
- package/dist/esm/project-config/loader.js +34 -7
- package/dist/esm/project-config/loader.js.map +1 -1
- 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 +23 -0
- package/dist/esm/project-config/npm-version-range.d.ts.map +1 -0
- package/dist/esm/project-config/npm-version-range.js +175 -0
- package/dist/esm/project-config/npm-version-range.js.map +1 -0
- package/dist/esm/project-config/provider-catalog-types.d.ts.map +1 -1
- package/dist/esm/project-config/provider-catalog-types.js.map +1 -1
- package/dist/esm/project-config/provider-companion-discovery.d.ts +256 -30
- package/dist/esm/project-config/provider-companion-discovery.d.ts.map +1 -1
- package/dist/esm/project-config/provider-companion-discovery.js +719 -40
- package/dist/esm/project-config/provider-companion-discovery.js.map +1 -1
- package/dist/esm/project-config/provider-runtime-artifacts.d.ts +125 -2
- package/dist/esm/project-config/provider-runtime-artifacts.d.ts.map +1 -1
- package/dist/esm/project-config/provider-runtime-artifacts.js +283 -66
- package/dist/esm/project-config/provider-runtime-artifacts.js.map +1 -1
- 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.d.ts.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.d.ts.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.map +1 -1
- package/dist/esm/project-config/shared/auth.schemas.js.map +1 -1
- package/dist/esm/project-config/shared/backing-service-servability.d.ts +157 -0
- package/dist/esm/project-config/shared/backing-service-servability.d.ts.map +1 -0
- package/dist/esm/project-config/shared/backing-service-servability.js +256 -0
- package/dist/esm/project-config/shared/backing-service-servability.js.map +1 -0
- package/dist/esm/project-config/shared/backing-services.schemas.d.ts +62 -67
- package/dist/esm/project-config/shared/backing-services.schemas.d.ts.map +1 -1
- package/dist/esm/project-config/shared/backing-services.schemas.js +71 -68
- package/dist/esm/project-config/shared/backing-services.schemas.js.map +1 -1
- package/dist/esm/project-config/shared/cdn.example.d.ts.map +1 -1
- package/dist/esm/project-config/shared/cdn.example.js.map +1 -1
- 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.map +1 -1
- package/dist/esm/project-config/shared/csp-defaults.js.map +1 -1
- package/dist/esm/project-config/shared/csp-emit.d.ts.map +1 -1
- package/dist/esm/project-config/shared/csp-emit.js +41 -2
- package/dist/esm/project-config/shared/csp-emit.js.map +1 -1
- package/dist/esm/project-config/shared/csp.schemas.d.ts.map +1 -1
- package/dist/esm/project-config/shared/csp.schemas.js.map +1 -1
- 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.map +1 -1
- package/dist/esm/project-config/shared/environment.schemas.js.map +1 -1
- package/dist/esm/project-config/shared/infra-providers.schemas.d.ts +180 -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 +40 -0
- package/dist/esm/project-config/shared/infra-providers.schemas.js.map +1 -1
- package/dist/esm/project-config/shared/infra-service.schemas.d.ts.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.map +1 -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.map +1 -1
- 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-services.schemas.d.ts.map +1 -1
- package/dist/esm/project-config/shared/platform-services.schemas.js.map +1 -1
- package/dist/esm/project-config/shared/platform-storage.schemas.d.ts.map +1 -1
- package/dist/esm/project-config/shared/platform-storage.schemas.js.map +1 -1
- package/dist/esm/project-config/shared/schema-version.schemas.d.ts.map +1 -1
- package/dist/esm/project-config/shared/schema-version.schemas.js.map +1 -1
- package/dist/esm/project-config/shared/service-definitions.schemas.d.ts.map +1 -1
- 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.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 +26 -0
- package/dist/esm/project-config/static-asset-import-noop.d.ts.map +1 -0
- package/dist/esm/project-config/static-asset-import-noop.js +49 -0
- package/dist/esm/project-config/static-asset-import-noop.js.map +1 -0
- 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.d.ts.map +1 -1
- package/dist/esm/registry/digest.schemas.js.map +1 -1
- package/dist/esm/registry/index.d.ts +3 -1
- package/dist/esm/registry/index.d.ts.map +1 -1
- package/dist/esm/registry/index.js +3 -1
- package/dist/esm/registry/index.js.map +1 -1
- package/dist/esm/registry/local-checkout-source.d.ts +31 -0
- package/dist/esm/registry/local-checkout-source.d.ts.map +1 -0
- package/dist/esm/registry/local-checkout-source.js +45 -0
- package/dist/esm/registry/local-checkout-source.js.map +1 -0
- package/dist/esm/registry/lockfile-modules-section.schemas.d.ts +174 -14
- package/dist/esm/registry/lockfile-modules-section.schemas.d.ts.map +1 -1
- package/dist/esm/registry/lockfile-modules-section.schemas.js +120 -11
- package/dist/esm/registry/lockfile-modules-section.schemas.js.map +1 -1
- package/dist/esm/registry/module-artifact.schemas.d.ts +79 -0
- package/dist/esm/registry/module-artifact.schemas.d.ts.map +1 -1
- package/dist/esm/registry/module-artifact.schemas.js +36 -0
- package/dist/esm/registry/module-artifact.schemas.js.map +1 -1
- package/dist/esm/registry/module-manifest.schemas.d.ts +393 -7
- package/dist/esm/registry/module-manifest.schemas.d.ts.map +1 -1
- package/dist/esm/registry/module-manifest.schemas.js +488 -40
- package/dist/esm/registry/module-manifest.schemas.js.map +1 -1
- package/dist/esm/registry/module-search.schemas.d.ts +80 -0
- package/dist/esm/registry/module-search.schemas.d.ts.map +1 -0
- package/dist/esm/registry/module-search.schemas.js +112 -0
- package/dist/esm/registry/module-search.schemas.js.map +1 -0
- package/dist/esm/registry/registry-config.schemas.d.ts +16 -0
- package/dist/esm/registry/registry-config.schemas.d.ts.map +1 -1
- package/dist/esm/registry/registry-config.schemas.js +8 -0
- 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 +126 -2
- package/dist/esm/registry/registry-errors.d.ts.map +1 -1
- package/dist/esm/registry/registry-errors.js +183 -14
- package/dist/esm/registry/registry-errors.js.map +1 -1
- package/dist/esm/registry/registry-keys.schemas.d.ts +80 -0
- package/dist/esm/registry/registry-keys.schemas.d.ts.map +1 -0
- package/dist/esm/registry/registry-keys.schemas.js +68 -0
- package/dist/esm/registry/registry-keys.schemas.js.map +1 -0
- package/dist/esm/registry/registry-section-schemas.constants.d.ts +25 -3
- 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/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.d.ts.map +1 -1
- package/dist/esm/schemas/framework-info.schemas.js.map +1 -1
- package/dist/esm/schemas/framework-secrets.schemas.d.ts.map +1 -1
- package/dist/esm/schemas/framework-secrets.schemas.js.map +1 -1
- package/dist/esm/schemas/platform-application-config.schemas.d.ts.map +1 -1
- package/dist/esm/schemas/platform-application-config.schemas.js.map +1 -1
- package/dist/esm/schemas/platform-application-secrets.schemas.d.ts.map +1 -1
- package/dist/esm/schemas/platform-application-secrets.schemas.js.map +1 -1
- package/dist/esm/schemas/platform-config.schemas.d.ts.map +1 -1
- package/dist/esm/schemas/platform-config.schemas.js.map +1 -1
- package/dist/esm/workspace-scope/application-subject-manifest.d.ts.map +1 -1
- package/dist/esm/workspace-scope/application-subject-manifest.js.map +1 -1
- package/dist/esm/workspace-scope/index.d.ts.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 +13 -11
- package/dist/esm/workspace-scope/workspace-homes.schemas.d.ts.map +1 -1
- package/dist/esm/workspace-scope/workspace-homes.schemas.js +2 -2
- 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 +7 -7
- package/dist/esm/registry/companion-api.schemas.d.ts +0 -176
- package/dist/esm/registry/companion-api.schemas.d.ts.map +0 -1
- package/dist/esm/registry/companion-api.schemas.js +0 -165
- package/dist/esm/registry/companion-api.schemas.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cdn.schemas.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"cdn.schemas.js","sourceRoot":"","sources":["../../../../src/project-config/shared/cdn.schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;;;;;;GAWG;AAEH;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAN,IAAY,SAmBX;AAnBD,WAAY,SAAS;IACnB;;;;;;OAMG;IACH,gCAAmB,CAAA;IACnB;;;;;;;;OAQG;IACH,sCAAyB,CAAA;AAC3B,CAAC,EAnBW,SAAS,KAAT,SAAS,QAmBpB;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,CAAC,YAAY,CAAC;IACzD,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC;CACnC,CAAC,CAAC;AAGH;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAAG,CAAC,CAAC,YAAY,CAAC;IAC5D,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,UAAU,CAAC;IACrC;;;OAGG;IACH,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACzB;;;;OAIG;IACH,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,sBAAsB,CAAC;CAClE,CAAC,CAAC;AAGH;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,kBAAkB,CAAC,MAAM,EAAE;IAChE,4BAA4B;IAC5B,+BAA+B;CAChC,CAAC,CAAC;AAGH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,YAAY,CAAC;IACjD;;;;;;;OAOG;IACH,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;IAClC;;;;;;OAMG;IACH,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IACpC;;;;OAIG;IACH,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACnC;;;OAGG;IACH,MAAM,EAAE,qBAAqB;CAC9B,CAAC,CAAC;AAGH,iDAAiD","sourcesContent":["import { z } from 'zod';\n\n/**\n * @wildo_source:part:start platform.config.cdn facet:layer:platform facet:family:infra\n *\n * Per-service CDN publish configuration, authored per-environment under\n * `wildo.infra.<env>.config.ts > cdn?[serviceKey]` (import the schemas + the\n * `CdnVendor` enum from `@wildo-ai/platform-config-lib`). Opting a frontend\n * into CDN serving (REMOTE envs only — the schema rejects `cdn` in local)\n * makes the deploy render skip its nginx Deployment/Service + ingress route\n * (served off-cluster by the CDN) while keeping its `runtime.endPoints.publicUrl`\n * unchanged; `wildo frontend publish` then uploads the built `dist/` to the S3\n * bucket + re-homes CSP to the edge.\n */\n\n/**\n * CDN vendor brands the framework can drive a live edge-publish against.\n *\n * Imported from `@wildo-ai/platform-config-lib`. Authored per-service-key\n * under `wildo.infra.<env>.config.ts > cdn?[serviceKey].vendor.kind`.\n *\n * The catalog is intentionally small and grows one brand at a time (mirrors\n * the `InfraProvider` brand convention). Each brand that supports LIVE\n * provisioning gets its own arm in {@link CdnVendorConfigSchema} carrying its\n * addressing (`zoneId`, …). `GENERIC` is the provider-agnostic escape hatch:\n * the publish path still uploads the `dist/` + writes a portable `_headers`\n * CSP file, but performs NO live vendor API call — the operator points their\n * own CDN (any `_headers`-consuming host: Cloudflare Pages, Netlify, Vercel,\n * or a bucket fronted by a proxy) at the published bucket.\n */\nexport enum CdnVendor {\n /**\n * No live vendor call. `wildo frontend publish` uploads the built `dist/`\n * to the configured S3 bucket and writes a portable `_headers` CSP file\n * alongside it; the operator wires their own CDN to the bucket. This is the\n * lowest-fabrication path and the correct choice when the CDN is fronted by\n * a host that reads `_headers`, or when the edge policy is managed out-of-band.\n */\n GENERIC = 'generic',\n /**\n * Cloudflare. `wildo frontend publish` additionally ensures a\n * `http_response_headers_transform` ruleset on the authored zone that SETs\n * the resolved CSP response header at the edge (the header nginx would emit\n * on a pod-served frontend). The live call fires only when the API token\n * (resolved from {@link CloudflareCdnVendorConfigSchema.apiTokenEnvVar}) is\n * present at publish time; otherwise the publish emits artifacts and skips\n * the live call with a warning.\n */\n CLOUDFLARE = 'cloudflare',\n}\n\n/**\n * `GENERIC` vendor — no live provisioning, no addressing. Presence of this\n * arm still opts the service into the CDN publish path (upload + `_headers`).\n */\nexport const GenericCdnVendorConfigSchema = z.strictObject({\n kind: z.literal(CdnVendor.GENERIC),\n});\nexport type GenericCdnVendorConfig = z.infer<typeof GenericCdnVendorConfigSchema>;\n\n/**\n * `CLOUDFLARE` vendor — live edge CSP provisioning against a Cloudflare zone.\n *\n * Only the token's ENV-VAR NAME is authored here, never the token value:\n * secrets never live in a checked-in `wildo.infra.<env>.config.ts`. The\n * publish path reads `process.env[apiTokenEnvVar]` at runtime; a missing var\n * degrades to artifacts-only (no throw).\n */\nexport const CloudflareCdnVendorConfigSchema = z.strictObject({\n kind: z.literal(CdnVendor.CLOUDFLARE),\n /**\n * Cloudflare zone id that fronts this frontend's public host. The publish\n * path PUTs the response-header-transform ruleset entrypoint on this zone.\n */\n zoneId: z.string().min(1),\n /**\n * NAME of the environment variable holding the Cloudflare API token (a\n * scoped token with `Zone.Ruleset` edit on the zone). NOT the token itself.\n * Default `CLOUDFLARE_API_TOKEN`.\n */\n apiTokenEnvVar: z.string().min(1).default('CLOUDFLARE_API_TOKEN'),\n});\nexport type CloudflareCdnVendorConfig = z.infer<typeof CloudflareCdnVendorConfigSchema>;\n\n/**\n * Discriminated union over {@link CdnVendor}. Adding a brand = adding an arm\n * here (+ a live adapter in the publish path). The discriminant `kind` gives\n * exhaustive narrowing at every consumer.\n */\nexport const CdnVendorConfigSchema = z.discriminatedUnion('kind', [\n GenericCdnVendorConfigSchema,\n CloudflareCdnVendorConfigSchema,\n]);\nexport type CdnVendorConfig = z.infer<typeof CdnVendorConfigSchema>;\n\n/**\n * Per-service CDN publish config — authored under\n * `wildo.infra.<env>.config.ts > cdn?[serviceKey]`, keyed by the SaaS-config\n * service key (same keyspace as `serviceHosts`).\n *\n * # Semantics\n *\n * Opting a frontend service into CDN serving means, FOR THAT ENVIRONMENT:\n * - the deploy render emits NEITHER an nginx Deployment/Service NOR an ingress\n * / compose route for the service — its public host is served off-cluster by\n * the CDN (DNS points the `<serviceHost>.<publicDomain>` at the CDN edge);\n * - `runtime.endPoints.publicUrl` is UNCHANGED (still\n * `<serviceHost>.<publicDomain>`) — the browser gets the same URL, it just\n * resolves to the CDN. This preserves the CORS / cross-frontend-handoff\n * coherence the ingress model relied on.\n *\n * CDN-served-ness is a PER-ENV deployment decision (a service can be\n * nginx-served in staging and CDN-served in production), which is why this\n * lives in the infra env config alongside `serviceHosts` — NOT on the app\n * service definition. The CSP *content* stays app-owned via the existing\n * `csp` resolution; the publish path REUSES that resolved policy to emit the\n * edge CSP, so this surface carries only the deployment targeting.\n *\n * # Object-storage target\n *\n * The S3 endpoint + credentials come from `backingServices.s3` (the app's\n * existing object-storage authoring surface — reused, not re-declared). Only\n * the bucket (+ optional key prefix) is CDN-specific: static public assets\n * SHOULD live in a bucket separate from the app's private file-storage bucket\n * (different access policy), so `bucket` is authored here; when omitted it\n * falls back to `backingServices.s3.bucket`.\n */\nexport const WildoCdnConfigSchema = z.strictObject({\n /**\n * Opt-out switch WITHOUT deleting the block. `true` (default) => this\n * service is CDN-served in this env (nginx pod + ingress route skipped,\n * publish path active). `false` => authored-but-inactive: the service falls\n * back to normal nginx-pod serving and the publish path ignores it. The\n * emit-skip / publish set keys on `enabled === true`, never on mere\n * presence, so a disabled entry never silently drops the ingress route.\n */\n enabled: z.boolean().default(true),\n /**\n * S3 bucket holding this frontend's PUBLIC static assets. Defaults to\n * `backingServices.s3.bucket` when omitted, but a SEPARATE public-read\n * bucket is recommended (do not mix public static assets with the app's\n * private user-uploaded files). The S3 endpoint + credentials always come\n * from `backingServices.s3`.\n */\n bucket: z.string().min(1).optional(),\n /**\n * Optional object-key prefix within the bucket (e.g. when one bucket serves\n * several frontends). Defaults to the service key. No leading/trailing\n * slash — the uploader joins segments.\n */\n bucketPrefix: z.string().optional(),\n /**\n * CDN vendor + its live-provisioning addressing. `GENERIC` = upload +\n * `_headers` only; branded vendors additionally push the edge CSP policy.\n */\n vendor: CdnVendorConfigSchema,\n});\nexport type WildoCdnConfig = z.infer<typeof WildoCdnConfigSchema>;\nexport type WildoCdnConfigInput = z.input<typeof WildoCdnConfigSchema>;\n/** @wildo_source:part:end platform.config.cdn */\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"csp-defaults.d.ts","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"csp-defaults.d.ts","sourceRoot":"","sources":["../../../../src/project-config/shared/csp-defaults.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwEG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AACvE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEtD;;;;;GAKG;AACH,MAAM,MA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AAiB,CAAC;IAC1C,SAAS,EAAE,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAC;IACvC,aAAa,EAAE,CAAC,QAAQ,CAAC;IACzB,UAAU,EAAE,CAAC,QAAQ,CAAC;IACtB,iBAAiB,EAAE,CAAC,QAAQ,CAAC;IAC7B,YAAY,EAAE,CAAC,QAAQ,CAAC;IACxB,aAAa,EAAE,CAAC,QAAQ,CAAC;IACzB,UAAU,EAAE,CAAC,QAAQ,CAAC;CACvB,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,uBAAuB,GAA4B;IACvD,aAAa,EAAE,CAAC,QAAQ,CAAC;IACzB,YAAY,EAAE,CAAC,QAAQ,CAAC;IACxB,WAAW,EAAE,CAAC,QAAQ,EAAE,iBAAiB,CAAC;IAC1C,SAAS,EAAE,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC;IACjD,aAAa,EAAE,CAAC,QAAQ,CAAC;IACzB,UAAU,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC/B,iBAAiB,EAAE,CAAC,QAAQ,CAAC;IAC7B,YAAY,EAAE,CAAC,QAAQ,CAAC;IACxB,aAAa,EAAE,CAAC,QAAQ,CAAC;IACzB,UAAU,EAAE,CAAC,QAAQ,CAAC;CACvB,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,aAAa,GAEtB;IACF,CAAC,eAAe,CAAC,QAAQ,CAAC,EAAE,iBAAiB;IAC7C,CAAC,eAAe,CAAC,cAAc,CAAC,EAAE,uBAAuB;IACzD,CAAC,eAAe,CAAC,QAAQ,CAAC,EAAE,iBAAiB;CAC9C,CAAC","sourcesContent":["/**\n * Per-`AppFrontendType` Content-Security-Policy baselines (Slice B B-Step 1\n * — `auth-hardening.md`).\n *\n * # Why one baseline per frontend kind (vs a single platform-wide one)\n *\n * The three `AppFrontendType` kinds (`SAAS_APP` / `STATIC_WEBSITE` /\n * `TECH_DOC`) genuinely have different inline-script / inline-style\n * pressure:\n *\n * - `SAAS_APP` — React SPA built with Vite. Vite's production output\n * uses ESM `<script type=\"module\">` with no inline scripts, AND\n * the runtime emits no inline styles. So the `SAAS_APP` baseline\n * is the tightest of the three: NO `'unsafe-inline'` for scripts,\n * `'unsafe-inline'` for styles ONLY because Tailwind's runtime\n * style-injection (e.g., `@apply` with arbitrary values) emits\n * short-lived inline `<style>` tags.\n * - `TECH_DOC` — Docusaurus 3.x SSG. Its hydration shim and classic-theme\n * bootstrap inject inline `<script>` (theme detection, color-mode\n * restoration and route-state seed), while generated/theme markup uses\n * inline styles. So the `TECH_DOC` baseline MUST allow `'unsafe-inline'`\n * for both scripts AND styles. Tightening\n * to nonce-based `'self'` only is a post-Slice-B follow-up that\n * would require an upstream Docusaurus runtime change OR a\n * nonce-injecting build plugin.\n * - `STATIC_WEBSITE` — Astro SSG marketing site. The marketing\n * surface typically embeds analytics / advertising / chat-widget\n * pixels (each a third-party origin), so the baseline ships an\n * intentionally-empty `script-src` / `connect-src` extension list\n * (just `'self'`) and forces the per-app config to opt into every\n * third-party origin explicitly. Per-app `directives['script-src']`\n * overrides MUST list the third-party hostnames the marketing team\n * has actually whitelisted (no implicit `'unsafe-inline'`).\n *\n * A single platform-wide baseline would force the lowest common\n * denominator (`TECH_DOC`'s `'unsafe-inline'` for everyone) and lose\n * the SAAS_APP tightness for no gain.\n *\n * # Shared posture across all three baselines\n *\n * - `default-src 'self'` — block by default; everything else opts\n * in explicitly via specific directives.\n * - `frame-ancestors 'none'` — refuse iframe embedding. Header-only\n * directive (meta channel ignores it; the `csp-emit.ts` serializer\n * strips it from the meta tag automatically).\n * - `object-src 'none'` — block `<object>` / `<embed>` plugin loading\n * entirely. None of the three frontend kinds have a use case for\n * legacy plugins.\n * - `form-action 'self'` — block `<form action=\"…\">` from POSTing\n * to a third-party origin. Closes the cross-origin form-injection\n * surface even when the rest of the policy is permissive.\n * - `base-uri 'self'` — block `<base href=\"…\">` injection from\n * redirecting relative URLs to an attacker-controlled origin.\n *\n * # Connect-src\n *\n * Every baseline ships `connect-src 'self'` — the resolver merges in\n * additional origins via the app-static `directives['connect-src']`\n * override (e.g., the SaaS backend API hostname), and via Slice B\n * Step 2's env-layer override for per-env additions (Sentry, analytics\n * collectors). The baseline does NOT include any backend hostname\n * because the resolver does NOT know the deployment env at the engine\n * layer; per-env hostnames are an env-config concern.\n *\n * # `report-uri` is intentionally NOT in any baseline\n *\n * The platform doesn't ship a CSP-violation collector yet\n * (`auth-hardening.md` \"Cheap Bonuses — CSP violation monitoring\n * endpoint\" tracks that as an independent follow-up). Authoring a\n * baseline `report-uri` value would be a config lie; per-app authoring\n * via the `WildoCspConfigSchema.reportUri` field is the right seam\n * once a real collector exists.\n */\n\nimport { AppFrontendType } from '@wildo-ai/saas-models/public-runtime';\nimport type { CspDirectiveName } from './csp.schemas';\n\n/**\n * Baseline directive map for one `AppFrontendType`. Internal shape — the\n * resolver in `platform-config-lib/src/project-config/shared/csp-emit.ts` produces\n * the same shape as its post-merge output. Distinct from the AUTHOR-side\n * `WildoCspConfig.directives` (which is partial; this is total).\n */\nexport type CspBaselineDirectiveMap = Readonly<\n Partial<Record<CspDirectiveName, readonly string[]>>\n>;\n\n/**\n * `SAAS_APP` baseline — tightest of the three. Vite-bundled React SPA\n * with no inline scripts (production builds emit `<script type=\"module\">`).\n * `style-src 'unsafe-inline'` covers Tailwind runtime style injection.\n *\n * # Google Fonts origins in `style-src` and `font-src`\n *\n * The design-token system (`saas-frontend-lib/src/core/ui/design-token.utils.ts`)\n * ships `applyGoogleFontPreset()` as the canonical web-font loader for\n * `SAAS_APP` shells. It builds a `https://fonts.googleapis.com/css2?...`\n * `<link rel=\"stylesheet\">` at runtime, which in turn pulls woff2 files\n * from `https://fonts.gstatic.com/...`. Both origins MUST be in the\n * baseline because:\n *\n * 1. The font loader is framework-shipped, not app-authored. An app\n * developer that simply uses an `OKLCH` design-token preset with a\n * Google Font family inherits the loader without writing any code,\n * and would hit CSP blocks on every shell render in production\n * (today they're masked because `reportOnly: true` is the typical\n * dev posture).\n * 2. Widening to two specific origins is dramatically safer than the\n * alternatives — `'unsafe-inline'` (which we already accept for\n * Tailwind) is orders of magnitude broader; nonces are not\n * compatible with a runtime-injected `<link>` that doesn't carry\n * our nonce attribute.\n * 3. Apps that prefer fully-local fonts (e.g., self-hosted woff2 in\n * `public/fonts/`) and never call `applyGoogleFontPreset()` can\n * tighten back via the per-app `directives['style-src']` /\n * `directives['font-src']` override — the resolver merges as a\n * union, so the per-app config can restate `[\"'self'\", \"'unsafe-inline'\"]`\n * without `fonts.googleapis.com` and CSP will warn (or block) any\n * stray Google-Fonts call.\n *\n * `preconnect` to both origins happens at the same site\n * (`design-token.utils.ts` lines 982–996). Preconnect is governed by\n * `connect-src`, not `style-src` / `font-src`, BUT modern browsers\n * treat `<link rel=\"preconnect\">` as a hint that doesn't require CSP\n * fetch directives — the actual fetch later in the pipeline carries\n * the resource type and is what CSP grades. No `connect-src` widening\n * is needed.\n */\nconst SAAS_APP_BASELINE: CspBaselineDirectiveMap = {\n 'default-src': [\"'self'\"],\n 'script-src': [\"'self'\"],\n 'style-src': [\"'self'\", \"'unsafe-inline'\", 'https://fonts.googleapis.com'],\n 'img-src': [\"'self'\", 'data:', 'blob:'],\n 'connect-src': [\"'self'\"],\n 'font-src': [\"'self'\", 'data:', 'https://fonts.gstatic.com'],\n 'frame-ancestors': [\"'none'\"],\n 'object-src': [\"'none'\"],\n 'form-action': [\"'self'\"],\n 'base-uri': [\"'self'\"],\n};\n\n/**\n * `TECH_DOC` baseline — Docusaurus 3.x SSG. `'unsafe-inline'` on both\n * `script-src` AND `style-src` is required by the Docusaurus runtime\n * (classic-theme bootstrap and hydration shim). `img-src` retains `data:` and\n * `blob:` because the documentation product supports generated/MDX images\n * expressed with those browser-native URL schemes. Fonts are self-hosted; the\n * removed OpenAPI theme's inline icon-font allowance is deliberately gone.\n *\n * Tightening to nonce-based `'self'` only is a post-Slice-B follow-up\n * (would require an upstream Docusaurus runtime change OR a\n * nonce-injecting build plugin — out of scope today).\n */\nconst TECH_DOC_BASELINE: CspBaselineDirectiveMap = {\n 'default-src': [\"'self'\"],\n 'script-src': [\"'self'\", \"'unsafe-inline'\"],\n 'style-src': [\"'self'\", \"'unsafe-inline'\"],\n 'img-src': [\"'self'\", 'data:', 'blob:'],\n 'connect-src': [\"'self'\"],\n 'font-src': [\"'self'\"],\n 'frame-ancestors': [\"'none'\"],\n 'object-src': [\"'none'\"],\n 'form-action': [\"'self'\"],\n 'base-uri': [\"'self'\"],\n};\n\n/**\n * `STATIC_WEBSITE` baseline — Astro SSG marketing site. Intentionally\n * narrow `script-src` / `connect-src` to force the per-app config to\n * opt into every third-party hostname (analytics, advertising, chat\n * widget) explicitly. NO implicit `'unsafe-inline'` — the marketing\n * team must opt in per origin (or use nonces / hashes once those are\n * wired by the marketing build plugin).\n *\n * `style-src 'unsafe-inline'` is included because Astro's view\n * transitions and inline scoped styles emit short-lived inline\n * `<style>` tags; stripping that would break the marketing animations\n * the website team relies on.\n *\n * `img-src` includes `https:` because marketing pages routinely embed\n * third-party imagery (case-study screenshots, partner logos hosted on\n * a CDN). Tightening to a closed allow-list per app is the per-app\n * `directives['img-src']` override's job.\n */\nconst STATIC_WEBSITE_BASELINE: CspBaselineDirectiveMap = {\n 'default-src': [\"'self'\"],\n 'script-src': [\"'self'\"],\n 'style-src': [\"'self'\", \"'unsafe-inline'\"],\n 'img-src': [\"'self'\", 'data:', 'blob:', 'https:'],\n 'connect-src': [\"'self'\"],\n 'font-src': [\"'self'\", 'data:'],\n 'frame-ancestors': [\"'none'\"],\n 'object-src': [\"'none'\"],\n 'form-action': [\"'self'\"],\n 'base-uri': [\"'self'\"],\n};\n\n/**\n * Per-`AppFrontendType` baseline registry. Total over the enum — adding\n * a new `AppFrontendType` value forces a baseline edit here at compile\n * time (TS error on the missing key). That coupling is the whole point\n * of the registry shape: a new frontend kind that ships without a CSP\n * baseline would silently get NO policy on any deployment until someone\n * notices.\n */\nexport const CSP_BASELINES: Readonly<\n Record<AppFrontendType, CspBaselineDirectiveMap>\n> = {\n [AppFrontendType.SAAS_APP]: SAAS_APP_BASELINE,\n [AppFrontendType.STATIC_WEBSITE]: STATIC_WEBSITE_BASELINE,\n [AppFrontendType.TECH_DOC]: TECH_DOC_BASELINE,\n};\n"]}
|
|
1
|
+
{"version":3,"file":"csp-defaults.js","sourceRoot":"","sources":["../../../../src/project-config/shared/csp-defaults.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwEG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AAavE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,MAAM,iBAAiB,GAA4B;IACjD,aAAa,EAAE,CAAC,QAAQ,CAAC;IACzB,YAAY,EAAE,CAAC,QAAQ,CAAC;IACxB,WAAW,EAAE,CAAC,QAAQ,EAAE,iBAAiB,EAAE,8BAA8B,CAAC;IAC1E,SAAS,EAAE,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAC;IACvC,aAAa,EAAE,CAAC,QAAQ,CAAC;IACzB,UAAU,EAAE,CAAC,QAAQ,EAAE,OAAO,EAAE,2BAA2B,CAAC;IAC5D,iBAAiB,EAAE,CAAC,QAAQ,CAAC;IAC7B,YAAY,EAAE,CAAC,QAAQ,CAAC;IACxB,aAAa,EAAE,CAAC,QAAQ,CAAC;IACzB,UAAU,EAAE,CAAC,QAAQ,CAAC;CACvB,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,MAAM,iBAAiB,GAA4B;IACjD,aAAa,EAAE,CAAC,QAAQ,CAAC;IACzB,YAAY,EAAE,CAAC,QAAQ,EAAE,iBAAiB,CAAC;IAC3C,WAAW,EAAE,CAAC,QAAQ,EAAE,iBAAiB,CAAC;IAC1C,SAAS,EAAE,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAC;IACvC,aAAa,EAAE,CAAC,QAAQ,CAAC;IACzB,UAAU,EAAE,CAAC,QAAQ,CAAC;IACtB,iBAAiB,EAAE,CAAC,QAAQ,CAAC;IAC7B,YAAY,EAAE,CAAC,QAAQ,CAAC;IACxB,aAAa,EAAE,CAAC,QAAQ,CAAC;IACzB,UAAU,EAAE,CAAC,QAAQ,CAAC;CACvB,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,uBAAuB,GAA4B;IACvD,aAAa,EAAE,CAAC,QAAQ,CAAC;IACzB,YAAY,EAAE,CAAC,QAAQ,CAAC;IACxB,WAAW,EAAE,CAAC,QAAQ,EAAE,iBAAiB,CAAC;IAC1C,SAAS,EAAE,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC;IACjD,aAAa,EAAE,CAAC,QAAQ,CAAC;IACzB,UAAU,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC/B,iBAAiB,EAAE,CAAC,QAAQ,CAAC;IAC7B,YAAY,EAAE,CAAC,QAAQ,CAAC;IACxB,aAAa,EAAE,CAAC,QAAQ,CAAC;IACzB,UAAU,EAAE,CAAC,QAAQ,CAAC;CACvB,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,aAAa,GAEtB;IACF,CAAC,eAAe,CAAC,QAAQ,CAAC,EAAE,iBAAiB;IAC7C,CAAC,eAAe,CAAC,cAAc,CAAC,EAAE,uBAAuB;IACzD,CAAC,eAAe,CAAC,QAAQ,CAAC,EAAE,iBAAiB;CAC9C,CAAC","sourcesContent":["/**\n * Per-`AppFrontendType` Content-Security-Policy baselines (Slice B B-Step 1\n * — `auth-hardening.md`).\n *\n * # Why one baseline per frontend kind (vs a single platform-wide one)\n *\n * The three `AppFrontendType` kinds (`SAAS_APP` / `STATIC_WEBSITE` /\n * `TECH_DOC`) genuinely have different inline-script / inline-style\n * pressure:\n *\n * - `SAAS_APP` — React SPA built with Vite. Vite's production output\n * uses ESM `<script type=\"module\">` with no inline scripts, AND\n * the runtime emits no inline styles. So the `SAAS_APP` baseline\n * is the tightest of the three: NO `'unsafe-inline'` for scripts,\n * `'unsafe-inline'` for styles ONLY because Tailwind's runtime\n * style-injection (e.g., `@apply` with arbitrary values) emits\n * short-lived inline `<style>` tags.\n * - `TECH_DOC` — Docusaurus 3.x SSG. Its hydration shim and classic-theme\n * bootstrap inject inline `<script>` (theme detection, color-mode\n * restoration and route-state seed), while generated/theme markup uses\n * inline styles. So the `TECH_DOC` baseline MUST allow `'unsafe-inline'`\n * for both scripts AND styles. Tightening\n * to nonce-based `'self'` only is a post-Slice-B follow-up that\n * would require an upstream Docusaurus runtime change OR a\n * nonce-injecting build plugin.\n * - `STATIC_WEBSITE` — Astro SSG marketing site. The marketing\n * surface typically embeds analytics / advertising / chat-widget\n * pixels (each a third-party origin), so the baseline ships an\n * intentionally-empty `script-src` / `connect-src` extension list\n * (just `'self'`) and forces the per-app config to opt into every\n * third-party origin explicitly. Per-app `directives['script-src']`\n * overrides MUST list the third-party hostnames the marketing team\n * has actually whitelisted (no implicit `'unsafe-inline'`).\n *\n * A single platform-wide baseline would force the lowest common\n * denominator (`TECH_DOC`'s `'unsafe-inline'` for everyone) and lose\n * the SAAS_APP tightness for no gain.\n *\n * # Shared posture across all three baselines\n *\n * - `default-src 'self'` — block by default; everything else opts\n * in explicitly via specific directives.\n * - `frame-ancestors 'none'` — refuse iframe embedding. Header-only\n * directive (meta channel ignores it; the `csp-emit.ts` serializer\n * strips it from the meta tag automatically).\n * - `object-src 'none'` — block `<object>` / `<embed>` plugin loading\n * entirely. None of the three frontend kinds have a use case for\n * legacy plugins.\n * - `form-action 'self'` — block `<form action=\"…\">` from POSTing\n * to a third-party origin. Closes the cross-origin form-injection\n * surface even when the rest of the policy is permissive.\n * - `base-uri 'self'` — block `<base href=\"…\">` injection from\n * redirecting relative URLs to an attacker-controlled origin.\n *\n * # Connect-src\n *\n * Every baseline ships `connect-src 'self'` — the resolver merges in\n * additional origins via the app-static `directives['connect-src']`\n * override (e.g., the SaaS backend API hostname), and via Slice B\n * Step 2's env-layer override for per-env additions (Sentry, analytics\n * collectors). The baseline does NOT include any backend hostname\n * because the resolver does NOT know the deployment env at the engine\n * layer; per-env hostnames are an env-config concern.\n *\n * # `report-uri` is intentionally NOT in any baseline\n *\n * The platform doesn't ship a CSP-violation collector yet\n * (`auth-hardening.md` \"Cheap Bonuses — CSP violation monitoring\n * endpoint\" tracks that as an independent follow-up). Authoring a\n * baseline `report-uri` value would be a config lie; per-app authoring\n * via the `WildoCspConfigSchema.reportUri` field is the right seam\n * once a real collector exists.\n */\n\nimport { AppFrontendType } from '@wildo-ai/saas-models/public-runtime';\nimport type { CspDirectiveName } from './csp.schemas';\n\n/**\n * Baseline directive map for one `AppFrontendType`. Internal shape — the\n * resolver in `platform-config-lib/src/project-config/shared/csp-emit.ts` produces\n * the same shape as its post-merge output. Distinct from the AUTHOR-side\n * `WildoCspConfig.directives` (which is partial; this is total).\n */\nexport type CspBaselineDirectiveMap = Readonly<\n Partial<Record<CspDirectiveName, readonly string[]>>\n>;\n\n/**\n * `SAAS_APP` baseline — tightest of the three. Vite-bundled React SPA\n * with no inline scripts (production builds emit `<script type=\"module\">`).\n * `style-src 'unsafe-inline'` covers Tailwind runtime style injection.\n *\n * # Google Fonts origins in `style-src` and `font-src`\n *\n * The design-token system (`saas-frontend-lib/src/core/ui/design-token.utils.ts`)\n * ships `applyGoogleFontPreset()` as the canonical web-font loader for\n * `SAAS_APP` shells. It builds a `https://fonts.googleapis.com/css2?...`\n * `<link rel=\"stylesheet\">` at runtime, which in turn pulls woff2 files\n * from `https://fonts.gstatic.com/...`. Both origins MUST be in the\n * baseline because:\n *\n * 1. The font loader is framework-shipped, not app-authored. An app\n * developer that simply uses an `OKLCH` design-token preset with a\n * Google Font family inherits the loader without writing any code,\n * and would hit CSP blocks on every shell render in production\n * (today they're masked because `reportOnly: true` is the typical\n * dev posture).\n * 2. Widening to two specific origins is dramatically safer than the\n * alternatives — `'unsafe-inline'` (which we already accept for\n * Tailwind) is orders of magnitude broader; nonces are not\n * compatible with a runtime-injected `<link>` that doesn't carry\n * our nonce attribute.\n * 3. Apps that prefer fully-local fonts (e.g., self-hosted woff2 in\n * `public/fonts/`) and never call `applyGoogleFontPreset()` can\n * tighten back via the per-app `directives['style-src']` /\n * `directives['font-src']` override — the resolver merges as a\n * union, so the per-app config can restate `[\"'self'\", \"'unsafe-inline'\"]`\n * without `fonts.googleapis.com` and CSP will warn (or block) any\n * stray Google-Fonts call.\n *\n * `preconnect` to both origins happens at the same site\n * (`design-token.utils.ts` lines 982–996). Preconnect is governed by\n * `connect-src`, not `style-src` / `font-src`, BUT modern browsers\n * treat `<link rel=\"preconnect\">` as a hint that doesn't require CSP\n * fetch directives — the actual fetch later in the pipeline carries\n * the resource type and is what CSP grades. No `connect-src` widening\n * is needed.\n */\nconst SAAS_APP_BASELINE: CspBaselineDirectiveMap = {\n 'default-src': [\"'self'\"],\n 'script-src': [\"'self'\"],\n 'style-src': [\"'self'\", \"'unsafe-inline'\", 'https://fonts.googleapis.com'],\n 'img-src': [\"'self'\", 'data:', 'blob:'],\n 'connect-src': [\"'self'\"],\n 'font-src': [\"'self'\", 'data:', 'https://fonts.gstatic.com'],\n 'frame-ancestors': [\"'none'\"],\n 'object-src': [\"'none'\"],\n 'form-action': [\"'self'\"],\n 'base-uri': [\"'self'\"],\n};\n\n/**\n * `TECH_DOC` baseline — Docusaurus 3.x SSG. `'unsafe-inline'` on both\n * `script-src` AND `style-src` is required by the Docusaurus runtime\n * (classic-theme bootstrap and hydration shim). `img-src` retains `data:` and\n * `blob:` because the documentation product supports generated/MDX images\n * expressed with those browser-native URL schemes. Fonts are self-hosted; the\n * removed OpenAPI theme's inline icon-font allowance is deliberately gone.\n *\n * Tightening to nonce-based `'self'` only is a post-Slice-B follow-up\n * (would require an upstream Docusaurus runtime change OR a\n * nonce-injecting build plugin — out of scope today).\n */\nconst TECH_DOC_BASELINE: CspBaselineDirectiveMap = {\n 'default-src': [\"'self'\"],\n 'script-src': [\"'self'\", \"'unsafe-inline'\"],\n 'style-src': [\"'self'\", \"'unsafe-inline'\"],\n 'img-src': [\"'self'\", 'data:', 'blob:'],\n 'connect-src': [\"'self'\"],\n 'font-src': [\"'self'\"],\n 'frame-ancestors': [\"'none'\"],\n 'object-src': [\"'none'\"],\n 'form-action': [\"'self'\"],\n 'base-uri': [\"'self'\"],\n};\n\n/**\n * `STATIC_WEBSITE` baseline — Astro SSG marketing site. Intentionally\n * narrow `script-src` / `connect-src` to force the per-app config to\n * opt into every third-party hostname (analytics, advertising, chat\n * widget) explicitly. NO implicit `'unsafe-inline'` — the marketing\n * team must opt in per origin (or use nonces / hashes once those are\n * wired by the marketing build plugin).\n *\n * `style-src 'unsafe-inline'` is included because Astro's view\n * transitions and inline scoped styles emit short-lived inline\n * `<style>` tags; stripping that would break the marketing animations\n * the website team relies on.\n *\n * `img-src` includes `https:` because marketing pages routinely embed\n * third-party imagery (case-study screenshots, partner logos hosted on\n * a CDN). Tightening to a closed allow-list per app is the per-app\n * `directives['img-src']` override's job.\n */\nconst STATIC_WEBSITE_BASELINE: CspBaselineDirectiveMap = {\n 'default-src': [\"'self'\"],\n 'script-src': [\"'self'\"],\n 'style-src': [\"'self'\", \"'unsafe-inline'\"],\n 'img-src': [\"'self'\", 'data:', 'blob:', 'https:'],\n 'connect-src': [\"'self'\"],\n 'font-src': [\"'self'\", 'data:'],\n 'frame-ancestors': [\"'none'\"],\n 'object-src': [\"'none'\"],\n 'form-action': [\"'self'\"],\n 'base-uri': [\"'self'\"],\n};\n\n/**\n * Per-`AppFrontendType` baseline registry. Total over the enum — adding\n * a new `AppFrontendType` value forces a baseline edit here at compile\n * time (TS error on the missing key). That coupling is the whole point\n * of the registry shape: a new frontend kind that ships without a CSP\n * baseline would silently get NO policy on any deployment until someone\n * notices.\n */\nexport const CSP_BASELINES: Readonly<\n Record<AppFrontendType, CspBaselineDirectiveMap>\n> = {\n [AppFrontendType.SAAS_APP]: SAAS_APP_BASELINE,\n [AppFrontendType.STATIC_WEBSITE]: STATIC_WEBSITE_BASELINE,\n [AppFrontendType.TECH_DOC]: TECH_DOC_BASELINE,\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"csp-emit.d.ts","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"csp-emit.d.ts","sourceRoot":"","sources":["../../../../src/project-config/shared/csp-emit.ts"],"names":[],"mappings":"AACA,OAAO,EACL,eAAe,EAEf,KAAK,4BAA4B,EAClC,MAAM,sCAAsC,CAAC;AAM9C,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,cAAc,EACpB,MAAM,eAAe,CAAC;AAGvB,MAAM,MAAM,uBAAuB,GAAG,QAAQ,CAC5C,OAAO,CAAC,MAAM,CAAC,gBAAgB,EAAE,SAAS,MAAM,EAAE,CAAC,CAAC,CACrD,CAAC;AAEF,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,UAAU,EAAE,uBAAuB,CAAC;IAC7C,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;CACxC;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;IACpC,QAAQ,CAAC,OAAO,EACZ;QACE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;QACzB,QAAQ,CAAC,UAAU,EAAE;YACnB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;YAC9B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;SAC1B,CAAC;KACH,GACD,IAAI,CAAC;CACV;AAoED,MAAM,WAAW,qBAAqB;I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;CAC/B;AAED,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,MAAM,EAChB,aAAa,EAAE,MAAM,GACpB,kBAAkB,CAkBpB;AAED,wBAAgB,gCAAgC,CAC9C,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,MAAM,EACrB,QAAQ,SAAgB,GACvB;IACD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;CAC/B,CA4DA"}
|
|
@@ -30,6 +30,39 @@ const PROVIDER_CSP_BUCKET_DIRECTIVES = {
|
|
|
30
30
|
[ProviderFrontendCspOriginBucket.IMG]: 'img-src',
|
|
31
31
|
[ProviderFrontendCspOriginBucket.STYLE]: 'style-src',
|
|
32
32
|
[ProviderFrontendCspOriginBucket.FONT]: 'font-src',
|
|
33
|
+
[ProviderFrontendCspOriginBucket.WORKER]: 'worker-src',
|
|
34
|
+
[ProviderFrontendCspOriginBucket.MEDIA]: 'media-src',
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* The directives a fetch falls back to when the directive a provider bucket maps to is ABSENT, most
|
|
38
|
+
* specific first and excluding the directive itself — CSP Level 3's fetch-directive fallback list,
|
|
39
|
+
* restricted to the directives `PROVIDER_CSP_BUCKET_DIRECTIVES` can write.
|
|
40
|
+
*
|
|
41
|
+
* spec-cite: CSP Level 3 (W3C Working Draft) §6.8.3 "Get fetch directive fallback list" —
|
|
42
|
+
* https://www.w3.org/TR/CSP3/#directive-fallback-list. `script-src` and `style-src` are not keys of that
|
|
43
|
+
* algorithm; they are the second step of the `-elem`/`-attr` chains, whose next step is `default-src`.
|
|
44
|
+
* The algorithm also puts `child-src` before `script-src` for workers and before `default-src` for
|
|
45
|
+
* frames; it is omitted here because `CSP_DIRECTIVE_NAMES` does not admit it, so a composed policy can
|
|
46
|
+
* never state it and that step can never be the one in force.
|
|
47
|
+
*
|
|
48
|
+
* ## Why the provider layer needs it (#1702)
|
|
49
|
+
*
|
|
50
|
+
* Adding a source list for a directive the policy does not state does not ADD to what the page may do —
|
|
51
|
+
* it REPLACES the fallback that was governing it. None of the three baselines states `worker-src` or
|
|
52
|
+
* `media-src`, so a provider declaring `workerOrigins: ['blob:']` would otherwise have produced
|
|
53
|
+
* `worker-src blob:` and silently revoked the page's own `'self'` workers, which `default-src 'self'` had
|
|
54
|
+
* been admitting. Seeding the new directive from the list it was falling back to keeps the provider layer
|
|
55
|
+
* additive, which is its whole contract. The same was already true, and latent, for `frame-src`.
|
|
56
|
+
*/
|
|
57
|
+
const PROVIDER_CSP_DIRECTIVE_FALLBACKS = {
|
|
58
|
+
'script-src': ['default-src'],
|
|
59
|
+
'connect-src': ['default-src'],
|
|
60
|
+
'frame-src': ['default-src'],
|
|
61
|
+
'img-src': ['default-src'],
|
|
62
|
+
'style-src': ['default-src'],
|
|
63
|
+
'font-src': ['default-src'],
|
|
64
|
+
'worker-src': ['script-src', 'default-src'],
|
|
65
|
+
'media-src': ['default-src'],
|
|
33
66
|
};
|
|
34
67
|
export const NGINX_CSP_BEGIN_MARKER = '# >>> wildo csp begin';
|
|
35
68
|
export const NGINX_CSP_END_MARKER = '# <<< wildo csp end';
|
|
@@ -167,10 +200,16 @@ export function resolveCspPolicy(input) {
|
|
|
167
200
|
const out = { ...merged };
|
|
168
201
|
for (const footprint of providerFootprints) {
|
|
169
202
|
for (const [bucket, directive] of Object.entries(PROVIDER_CSP_BUCKET_DIRECTIVES)) {
|
|
170
|
-
|
|
203
|
+
// `?? []`: a footprint read off an artifact older than a bucket lacks the key.
|
|
204
|
+
const origins = footprint[bucket] ?? [];
|
|
171
205
|
if (origins.length === 0)
|
|
172
206
|
continue;
|
|
173
|
-
|
|
207
|
+
// An absent directive is seeded from the one it was falling back to, so adding a provider's
|
|
208
|
+
// origin never REVOKES what the fallback admitted — see `PROVIDER_CSP_DIRECTIVE_FALLBACKS`.
|
|
209
|
+
const current = out[directive] ?? PROVIDER_CSP_DIRECTIVE_FALLBACKS[directive]
|
|
210
|
+
.map((fallback) => out[fallback])
|
|
211
|
+
.find((sources) => sources !== undefined);
|
|
212
|
+
out[directive] = mergeSourceLists(current, origins);
|
|
174
213
|
}
|
|
175
214
|
}
|
|
176
215
|
merged = out;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"csp-emit.js","sourceRoot":"","sources":["../../../../../src/project-config/shared/csp-emit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACtD,OAAO,EACL,eAAe,EACf,+BAA+B,GAEhC,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EACL,aAAa,GAEd,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,gBAAgB,GAIjB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AA2BzD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,8BAA8B,GAEhC;IACF,CAAC,+BAA+B,CAAC,MAAM,CAAC,EAAE,YAAY;IACtD,CAAC,+BAA+B,CAAC,OAAO,CAAC,EAAE,aAAa;IACxD,CAAC,+BAA+B,CAAC,KAAK,CAAC,EAAE,WAAW;IACpD,CAAC,+BAA+B,CAAC,GAAG,CAAC,EAAE,SAAS;IAChD,CAAC,+BAA+B,CAAC,KAAK,CAAC,EAAE,WAAW;IACpD,CAAC,+BAA+B,CAAC,IAAI,CAAC,EAAE,UAAU;CACnD,CAAC;AAyCF,MAAM,CAAC,MAAM,sBAAsB,GAAG,uBAAuB,CAAC;AAC9D,MAAM,CAAC,MAAM,oBAAoB,GAAG,qBAAqB,CAAC;AAE1D,MAAM,uBAAuB,GAAwB,IAAI,GAAG,CAAC;IAC3D,iBAAiB;IACjB,YAAY;IACZ,WAAW;IACX,SAAS;CACV,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,SAA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{\n AppFrontendType,\n ProviderFrontendCspOriginBucket,\n type ProviderFrontendCspFootprint,\n} from '@wildo-ai/saas-models/public-runtime';\n\nimport {\n CSP_BASELINES,\n type CspBaselineDirectiveMap,\n} from './csp-defaults';\nimport {\n CspMergeStrategy,\n type CspDirectiveName,\n type EnvCspOverride,\n type WildoCspConfig,\n} from './csp.schemas';\nimport { WildoEnvironment } from './environment.schemas';\n\nexport type ResolvedCspDirectiveMap = Readonly<\n Partial<Record<CspDirectiveName, readonly string[]>>\n>;\n\nexport interface ResolvedCspPolicy {\n readonly directives: ResolvedCspDirectiveMap;\n readonly reportOnly: boolean;\n readonly reportUri: string | undefined;\n}\n\nexport interface CspEmitArtifacts {\n readonly nginxHeaderName: string;\n readonly nginxPolicyValue: string;\n readonly nginxAddHeaderLine: string;\n readonly metaTag:\n | {\n readonly tagName: 'meta';\n readonly attributes: {\n readonly 'http-equiv': string;\n readonly content: string;\n };\n }\n | null;\n}\n\n/**\n * Where each of a provider's declared origin buckets lands in the policy.\n *\n * THE ONE PLACE the mapping exists. A provider declares what it is REACHING\n * — a script it loads, an API it calls, an iframe it embeds — and which\n * directive grades that fetch is framework knowledge, so a provider author\n * never has to learn the CSP directive taxonomy and a change to it is a change\n * here rather than in every provider package.\n *\n * The bucket names are also why `ProviderFrontendCspFootprint` does not restate\n * `CSP_DIRECTIVE_NAMES`: that vocabulary already has one named source, in this\n * package, and `@wildo-ai/saas-models` — where the footprint has to live,\n * because it rides on the wire — depends on nothing of ours.\n *\n * Total over the footprint's buckets: adding a bucket without deciding its\n * directive is a compile error here, which is the coupling this shape exists\n * for. A bucket with no mapping would be authored, serialized, read, and\n * silently contribute nothing — in production only, since CSP is report-only\n * in development.\n */\nconst PROVIDER_CSP_BUCKET_DIRECTIVES: Readonly<\n Record<ProviderFrontendCspOriginBucket, CspDirectiveName>\n> = {\n [ProviderFrontendCspOriginBucket.SCRIPT]: 'script-src',\n [ProviderFrontendCspOriginBucket.CONNECT]: 'connect-src',\n [ProviderFrontendCspOriginBucket.FRAME]: 'frame-src',\n [ProviderFrontendCspOriginBucket.IMG]: 'img-src',\n [ProviderFrontendCspOriginBucket.STYLE]: 'style-src',\n [ProviderFrontendCspOriginBucket.FONT]: 'font-src',\n};\n\nexport interface ResolveCspPolicyInput {\n readonly frontendType: AppFrontendType;\n readonly appCsp: WildoCspConfig | undefined;\n readonly envOverride?: EnvCspOverride;\n /**\n * The CSP footprints of the providers DECLARED for this service — the fourth\n * layer, added by #332.\n *\n * Without it, a marketing site that wants an embedded meeting or a SaaS app\n * that wants a Drive picker means hand-editing script / frame / connect\n * origins per application, per service, per environment; and getting it wrong\n * is invisible until production, because development is report-only. The\n * caller reads these from the service's materialized provider block, which is\n * DATA precisely so that no frontend module has to be executed to obtain them.\n *\n * Providers declared for ANOTHER service must not appear here: the point of\n * the layer is that a Zoom origin admitted for the marketing site is not\n * thereby admitted for the SaaS app.\n *\n * A footprint's `derivedOrigins` must ALREADY BE RESOLVED into its buckets by\n * the caller. This resolver sees no `publicConfig` — it composes a policy, it\n * does not read a provider's configuration — and the one caller that has both\n * halves is `CspSyncService`, which reads each entry out of the materialized\n * block.\n */\n readonly providerCspFootprints?: ReadonlyArray<ProviderFrontendCspFootprint>;\n /**\n * Environment id this CSP is being resolved for (e.g. `'local'`,\n * `'staging'`, `'production'`, or any custom slug). Optional for\n * back-compat — when `undefined`, no env-aware auto-loosening applies\n * (the resolver behaves exactly as it did pre-`viteDevLoosening`).\n *\n * Required when the caller wants the framework to auto-apply\n * `viteDevLoosening` for `'local'` + `SAAS_APP`. The CLI's\n * `CspSyncService` already knows the env id and SHOULD pass it.\n */\n readonly environmentId?: string;\n}\n\nexport const NGINX_CSP_BEGIN_MARKER = '# >>> wildo csp begin';\nexport const NGINX_CSP_END_MARKER = '# <<< wildo csp end';\n\nconst META_INVALID_DIRECTIVES: ReadonlySet<string> = new Set([\n 'frame-ancestors',\n 'report-uri',\n 'report-to',\n 'sandbox',\n]);\n\n/**\n * Derives the WebSocket-scheme companion origins for every HTTP(S) origin\n * present in a `connect-src` source list, and returns the list widened to\n * include them.\n *\n * Why the framework ships this rather than making each app author it:\n * every Wildo backend serves its realtime channel (Socket.IO) on the SAME\n * origin as its HTTP API. Socket.IO opens the handshake over polling and\n * then UPGRADES to a raw `ws://` / `wss://` connection to that origin. The\n * CSP `connect-src` directive grades WebSocket connections by their `ws`/\n * `wss` scheme, and — per the CSP spec — an `http://host` source does NOT\n * authorize a `ws://host` connection (the schemes are distinct match\n * tokens). So an app that allow-lists `http://localhost:4241` for `fetch`/\n * `XHR` but not `ws://localhost:4241` will emit a `connect-src` violation\n * the instant the socket upgrades — exactly the trap every infra config\n * would otherwise have to remember to work around by hand.\n *\n * Transform (idempotent, dedupe-safe):\n * `http://host[:port]` → also allow `ws://host[:port]`\n * `https://host[:port]` → also allow `wss://host[:port]`\n * bare scheme `http:` → also allow `ws:`\n * bare scheme `https:` → also allow `wss:`\n *\n * Keyword / non-HTTP sources (`'self'`, `'none'`, `data:`, `blob:`, an\n * already-`ws://` origin, …) are passed through untouched. `'self'` is\n * deliberately NOT expanded: the browser tab is served from the frontend\n * origin, never the backend API origin, so a same-origin `ws` derivation\n * from `'self'` would authorize the wrong host. The backend origin is\n * always listed explicitly, which is what this widens.\n */\nfunction augmentConnectSrcWithWebSocketOrigins(\n sources: readonly string[] | undefined,\n): readonly string[] | undefined {\n if (!sources || sources.length === 0) {\n return sources;\n }\n\n const derived: string[] = [];\n for (const source of sources) {\n if (source.startsWith('https://')) {\n derived.push(`wss://${source.slice('https://'.length)}`);\n } else if (source.startsWith('http://')) {\n derived.push(`ws://${source.slice('http://'.length)}`);\n } else if (source === 'https:') {\n derived.push('wss:');\n } else if (source === 'http:') {\n derived.push('ws:');\n }\n }\n\n return mergeSourceLists(sources, derived);\n}\n\nfunction mergeSourceLists(\n a: readonly string[] | undefined,\n b: readonly string[] | undefined,\n): readonly string[] {\n if (!a || a.length === 0) {\n return b ?? [];\n }\n if (!b || b.length === 0) {\n return a;\n }\n\n const seen = new Set(a);\n const out: string[] = [...a];\n for (const source of b) {\n if (!seen.has(source)) {\n seen.add(source);\n out.push(source);\n }\n }\n return out;\n}\n\n/**\n * Resolves the generic layered CSP model shared by all frontend surfaces:\n * platform baseline, app-static config, env-selected overrides, then the\n * declared providers' own footprints (#332).\n *\n * The provider layer is fourth on purpose. The first three describe what the\n * APPLICATION decided; the fourth describes what the things the application\n * declared actually need in order to work. Placing it last means a provider\n * cannot be silently dropped by an app-level `REPLACE_BASELINE`, and placing it\n * before the WebSocket derivation means a provider's `connect-src` origin gets\n * its `wss://` companion exactly like the backend API's.\n *\n * This lives with the CSP schemas/defaults so consumers do not depend on any\n * concrete frontend package to process security config.\n */\nexport function resolveCspPolicy(\n input: ResolveCspPolicyInput,\n): ResolvedCspPolicy | null {\n const { frontendType, appCsp, envOverride } = input;\n\n if (!appCsp || !appCsp.enabled) {\n return null;\n }\n\n const baseline: CspBaselineDirectiveMap = CSP_BASELINES[frontendType];\n let merged: ResolvedCspDirectiveMap;\n\n if (appCsp.mergeStrategy === CspMergeStrategy.REPLACE_BASELINE) {\n merged = appCsp.directives;\n } else {\n const out: Partial<Record<CspDirectiveName, readonly string[]>> = {};\n const allKeys = new Set<CspDirectiveName>([\n ...(Object.keys(baseline) as CspDirectiveName[]),\n ...(Object.keys(appCsp.directives) as CspDirectiveName[]),\n ]);\n\n for (const key of allKeys) {\n out[key] = mergeSourceLists(baseline[key], appCsp.directives[key]);\n }\n\n merged = out;\n }\n\n if (envOverride?.extraDirectives) {\n const out: Partial<Record<CspDirectiveName, readonly string[]>> = {\n ...merged,\n };\n\n for (const key of Object.keys(envOverride.extraDirectives) as CspDirectiveName[]) {\n out[key] = mergeSourceLists(merged[key], envOverride.extraDirectives[key]);\n }\n\n merged = out;\n }\n\n // Provider layer (#332) — the origins the providers DECLARED FOR THIS SERVICE\n // need, merged after the app-static and env layers and before the WebSocket\n // derivation below (so a provider's `connect-src` origin gets its `wss://`\n // companion for free, exactly like the backend API's).\n //\n // Additive in every merge strategy, including REPLACE_BASELINE. That strategy\n // exists so an app can discard the platform BASELINE when it is wrong for the\n // surface; a provider the same app declared is a dependency it chose, not a\n // default it is overriding, and silently dropping its origins would produce a\n // policy that blocks a feature the app asked for — in production only.\n const providerFootprints = input.providerCspFootprints ?? [];\n if (providerFootprints.length > 0) {\n const out: Partial<Record<CspDirectiveName, readonly string[]>> = { ...merged };\n\n for (const footprint of providerFootprints) {\n for (const [bucket, directive] of Object.entries(PROVIDER_CSP_BUCKET_DIRECTIVES) as ReadonlyArray<\n readonly [ProviderFrontendCspOriginBucket, CspDirectiveName]\n >) {\n const origins = footprint[bucket];\n if (origins.length === 0) continue;\n out[directive] = mergeSourceLists(out[directive], origins);\n }\n }\n\n merged = out;\n }\n\n // Vite dev-mode loosening (auto-applied for local SAAS_APP).\n //\n // Vite's dev server REQUIRES both `'unsafe-eval'` (lazy module +\n // sourcemap transforms) and `'unsafe-inline'` (HMR client bootstrap\n // injects a literal inline `<script>`) to function. Under the tight\n // SAAS_APP baseline (`script-src 'self'`), those produce ~120+ CSP\n // violations per page load that drown out real signal (e.g. the\n // Google-Fonts gotcha that the loosened style-src/font-src now allow).\n //\n // The framework SHIPS this knowledge — every Wildo SaaS app uses\n // Vite — so we auto-loosen for `'local'` + `SAAS_APP` here rather\n // than forcing every infra config to re-author the same opt-in. An\n // explicit `viteDevLoosening: false` override keeps tight `script-src`\n // when an author is actively debugging a real CSP issue and willing\n // to accept the Vite noise. Production builds emit `<script\n // type=\"module\">` only and never `eval()`, so production envs never\n // trigger the auto-loosening — `viteDevLoosening` defaults to FALSE\n // there even if the env id is non-`local`.\n const isViteDevAutoTarget =\n input.environmentId === WildoEnvironment.LOCAL &&\n frontendType === AppFrontendType.SAAS_APP;\n const viteDevLoosening = envOverride?.viteDevLoosening ?? isViteDevAutoTarget;\n if (viteDevLoosening) {\n merged = {\n ...merged,\n 'script-src': mergeSourceLists(\n merged['script-src'],\n [\"'unsafe-inline'\", \"'unsafe-eval'\"],\n ),\n };\n }\n\n // Auto-derive the `ws://` / `wss://` companion origins for every HTTP(S)\n // origin the app allow-listed in `connect-src`. Applied LAST so it covers\n // origins contributed by the baseline, app-static config, AND env override\n // alike (e.g. the local `http://localhost:4241` and the staging/prod\n // `https://api.<app>.wildo.app` backend origins). Without this, the\n // Socket.IO transport upgrade to a raw WebSocket against the backend origin\n // trips a `connect-src` violation on every surface. See the helper JSDoc for\n // the scheme-matching rationale.\n const connectSrcWithWs = augmentConnectSrcWithWebSocketOrigins(merged['connect-src']);\n if (connectSrcWithWs !== merged['connect-src']) {\n merged = {\n ...merged,\n 'connect-src': connectSrcWithWs,\n };\n }\n\n return {\n directives: merged,\n reportOnly: envOverride?.reportOnly ?? appCsp.reportOnly,\n reportUri: envOverride?.reportUri ?? appCsp.reportUri,\n };\n}\n\nfunction serializeDirectives(directives: ResolvedCspDirectiveMap): string {\n return Object.entries(directives)\n .filter(([, sources]) => sources && sources.length > 0)\n .map(([name, sources]) => `${name} ${(sources ?? []).join(' ')}`)\n .join('; ');\n}\n\nfunction stripMetaInvalidDirectives(\n directives: ResolvedCspDirectiveMap,\n): ResolvedCspDirectiveMap {\n const out: Partial<Record<CspDirectiveName, readonly string[]>> = {};\n\n for (const [name, sources] of Object.entries(directives)) {\n if (!META_INVALID_DIRECTIVES.has(name)) {\n out[name as CspDirectiveName] = sources;\n }\n }\n\n return out;\n}\n\nfunction withReportUri(\n directives: ResolvedCspDirectiveMap,\n reportUri: string | undefined,\n): ResolvedCspDirectiveMap {\n if (!reportUri) {\n return directives;\n }\n\n return {\n ...directives,\n ['report-uri' as CspDirectiveName]: [reportUri],\n };\n}\n\nexport function emitCspArtifacts(policy: ResolvedCspPolicy): CspEmitArtifacts {\n const nginxHeaderName = policy.reportOnly\n ? 'Content-Security-Policy-Report-Only'\n : 'Content-Security-Policy';\n const nginxPolicyValue = serializeDirectives(\n withReportUri(policy.directives, policy.reportUri),\n );\n\n return {\n nginxHeaderName,\n nginxPolicyValue,\n nginxAddHeaderLine: `add_header ${nginxHeaderName} \"${nginxPolicyValue}\" always;`,\n metaTag: policy.reportOnly\n ? null\n : {\n tagName: 'meta',\n attributes: {\n 'http-equiv': 'Content-Security-Policy',\n content: serializeDirectives(stripMetaInvalidDirectives(policy.directives)),\n },\n },\n };\n}\n\n/**\n * A single static-host `_headers` block that delivers the resolved CSP as a\n * real response header at the `/*` (all-paths) scope.\n *\n * Format matches the `_headers` convention consumed by Cloudflare Pages /\n * Netlify / Vercel (and the `saas-website` `X-Robots-Tag` `_headers` emitter):\n * a path line, then two-space-indented `Header-Name: value` lines. This is the\n * PORTABLE, provider-agnostic edge-CSP delivery — a CDN-served frontend (which\n * has no nginx to `add_header`) ships this file in its bucket and any\n * `_headers`-aware host applies it.\n *\n * Uses the FULL header value (including the header-only `frame-ancestors` and\n * `report-uri` directives) — a `_headers` line is a genuine response header, so\n * nothing is stripped (unlike the `<meta http-equiv>` fallback). Report-only\n * policies are honoured (the header name flips to\n * `Content-Security-Policy-Report-Only`, valid on a real header channel).\n *\n * The caller composes this block with any other `_headers` blocks (e.g. the\n * website's per-path `X-Robots-Tag`) into one file, separated by a blank line.\n */\nexport function emitCspHeadersFileBlock(policy: ResolvedCspPolicy): string {\n const { nginxHeaderName, nginxPolicyValue } = emitCspArtifacts(policy);\n return `/*\\n ${nginxHeaderName}: ${nginxPolicyValue}`;\n}\n\n/**\n * Provider-agnostic descriptor of the response-header MODIFICATION a CDN vendor\n * must install to deliver the resolved CSP at the edge. A concrete vendor\n * adapter (e.g. Cloudflare) maps this to its own API shape — for Cloudflare, a\n * `http_response_headers_transform` ruleset rule whose action sets\n * `headerName` to `value`.\n *\n * Same FULL header name + value as the nginx / `_headers` channels (a CDN sets\n * a real header, so `frame-ancestors` / `report-uri` are valid and retained).\n */\nexport interface CspEdgeHeaderModification {\n /** Cloudflare ruleset phase this modification belongs to. */\n readonly phase: 'http_response_headers_transform';\n /** The header operation — always `set` (overwrite any origin value). */\n readonly operation: 'set';\n /** Response-header name (report-only-aware, same as the nginx channel). */\n readonly headerName: string;\n /** Serialized policy value (identical to `nginxPolicyValue`). */\n readonly value: string;\n}\n\n/**\n * Derive the edge response-header modification carrying the resolved CSP, for a\n * CDN vendor's live-provisioning adapter to install. Thin over\n * {@link emitCspArtifacts} so the directive serialization is the single source\n * of truth across nginx / `_headers` / CDN channels.\n */\nexport function emitCspEdgeHeaderModification(policy: ResolvedCspPolicy): CspEdgeHeaderModification {\n const { nginxHeaderName, nginxPolicyValue } = emitCspArtifacts(policy);\n return {\n phase: 'http_response_headers_transform',\n operation: 'set',\n headerName: nginxHeaderName,\n value: nginxPolicyValue,\n };\n}\n\nexport interface RewriteNginxResult {\n readonly totalPairs: number;\n readonly pairsRewritten: number;\n readonly fileWritten: boolean;\n}\n\nexport function rewriteNginxCspMarkerPairs(\n filePath: string,\n addHeaderLine: string,\n): RewriteNginxResult {\n const original = readFileSync(filePath, 'utf-8');\n const { rewritten, totalPairs, pairsChanged } = rewriteNginxCspMarkerPairsString(\n original,\n addHeaderLine,\n filePath,\n );\n const fileWritten = rewritten !== original;\n\n if (fileWritten) {\n writeFileSync(filePath, rewritten, 'utf-8');\n }\n\n return {\n totalPairs,\n pairsRewritten: pairsChanged,\n fileWritten,\n };\n}\n\nexport function rewriteNginxCspMarkerPairsString(\n source: string,\n addHeaderLine: string,\n filePath = '<in-memory>',\n): {\n readonly rewritten: string;\n readonly totalPairs: number;\n readonly pairsChanged: number;\n} {\n const usesCrlf = source.includes('\\r\\n');\n const newline = usesCrlf ? '\\r\\n' : '\\n';\n const lines = source.split(newline);\n\n let totalPairs = 0;\n let pairsChanged = 0;\n let openBeginIndex: number | null = null;\n let openIndent = '';\n\n for (let index = 0; index < lines.length; index += 1) {\n const trimmed = lines[index].trim();\n\n if (trimmed === NGINX_CSP_BEGIN_MARKER) {\n if (openBeginIndex !== null) {\n throw new Error(\n `[csp-emit] ${filePath}:${index + 1} found a second '${NGINX_CSP_BEGIN_MARKER}' before the previous '${NGINX_CSP_END_MARKER}' (line ${openBeginIndex + 1})`,\n );\n }\n\n openBeginIndex = index;\n openIndent = lines[index].slice(0, lines[index].indexOf('#'));\n continue;\n }\n\n if (trimmed === NGINX_CSP_END_MARKER) {\n if (openBeginIndex === null) {\n throw new Error(\n `[csp-emit] ${filePath}:${index + 1} found '${NGINX_CSP_END_MARKER}' without a matching '${NGINX_CSP_BEGIN_MARKER}'`,\n );\n }\n\n totalPairs += 1;\n\n const existingBody = lines.slice(openBeginIndex + 1, index);\n const canonicalBody = [`${openIndent}${addHeaderLine}`];\n const existingNonBlank = existingBody.filter((line) => line.trim().length > 0);\n const canonicalNonBlank = canonicalBody.filter((line) => line.trim().length > 0);\n const bodyMatches =\n existingNonBlank.length === canonicalNonBlank.length &&\n existingNonBlank.every((line, bodyIndex) => line === canonicalNonBlank[bodyIndex]);\n\n if (!bodyMatches) {\n lines.splice(openBeginIndex + 1, index - openBeginIndex - 1, ...canonicalBody);\n index = openBeginIndex + canonicalBody.length + 1;\n pairsChanged += 1;\n }\n\n openBeginIndex = null;\n openIndent = '';\n }\n }\n\n if (openBeginIndex !== null) {\n throw new Error(\n `[csp-emit] ${filePath} has an unclosed '${NGINX_CSP_BEGIN_MARKER}' starting at line ${openBeginIndex + 1}`,\n );\n }\n\n return { rewritten: lines.join(newline), totalPairs, pairsChanged };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"csp-emit.js","sourceRoot":"","sources":["../../../../src/project-config/shared/csp-emit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACtD,OAAO,EACL,eAAe,EACf,+BAA+B,GAEhC,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EACL,aAAa,GAEd,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,gBAAgB,GAIjB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AA2BzD;;;;;;;;;;;;;;;;;;;G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;IACJ,CAAC;IAED,OAAO,EAAE,SAAS,EAAE,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,UAAU,EAAE,YAAY,EAAE,CAAC;AACtE,CAAC","sourcesContent":["import { readFileSync, writeFileSync } from 'node:fs';\nimport {\n AppFrontendType,\n ProviderFrontendCspOriginBucket,\n type ProviderFrontendCspFootprint,\n} from '@wildo-ai/saas-models/public-runtime';\n\nimport {\n CSP_BASELINES,\n type CspBaselineDirectiveMap,\n} from './csp-defaults';\nimport {\n CspMergeStrategy,\n type CspDirectiveName,\n type EnvCspOverride,\n type WildoCspConfig,\n} from './csp.schemas';\nimport { WildoEnvironment } from './environment.schemas';\n\nexport type ResolvedCspDirectiveMap = Readonly<\n Partial<Record<CspDirectiveName, readonly string[]>>\n>;\n\nexport interface ResolvedCspPolicy {\n readonly directives: ResolvedCspDirectiveMap;\n readonly reportOnly: boolean;\n readonly reportUri: string | undefined;\n}\n\nexport interface CspEmitArtifacts {\n readonly nginxHeaderName: string;\n readonly nginxPolicyValue: string;\n readonly nginxAddHeaderLine: string;\n readonly metaTag:\n | {\n readonly tagName: 'meta';\n readonly attributes: {\n readonly 'http-equiv': string;\n readonly content: string;\n };\n }\n | null;\n}\n\n/**\n * Where each of a provider's declared origin buckets lands in the policy.\n *\n * THE ONE PLACE the mapping exists. A provider declares what it is REACHING\n * — a script it loads, an API it calls, an iframe it embeds — and which\n * directive grades that fetch is framework knowledge, so a provider author\n * never has to learn the CSP directive taxonomy and a change to it is a change\n * here rather than in every provider package.\n *\n * The bucket names are also why `ProviderFrontendCspFootprint` does not restate\n * `CSP_DIRECTIVE_NAMES`: that vocabulary already has one named source, in this\n * package, and `@wildo-ai/saas-models` — where the footprint has to live,\n * because it rides on the wire — depends on nothing of ours.\n *\n * Total over the footprint's buckets: adding a bucket without deciding its\n * directive is a compile error here, which is the coupling this shape exists\n * for. A bucket with no mapping would be authored, serialized, read, and\n * silently contribute nothing — in production only, since CSP is report-only\n * in development.\n */\nconst PROVIDER_CSP_BUCKET_DIRECTIVES = {\n [ProviderFrontendCspOriginBucket.SCRIPT]: 'script-src',\n [ProviderFrontendCspOriginBucket.CONNECT]: 'connect-src',\n [ProviderFrontendCspOriginBucket.FRAME]: 'frame-src',\n [ProviderFrontendCspOriginBucket.IMG]: 'img-src',\n [ProviderFrontendCspOriginBucket.STYLE]: 'style-src',\n [ProviderFrontendCspOriginBucket.FONT]: 'font-src',\n [ProviderFrontendCspOriginBucket.WORKER]: 'worker-src',\n [ProviderFrontendCspOriginBucket.MEDIA]: 'media-src',\n} as const satisfies Readonly<Record<ProviderFrontendCspOriginBucket, CspDirectiveName>>;\n\n/** The directives a provider bucket can write — the keys `PROVIDER_CSP_DIRECTIVE_FALLBACKS` must be total over. */\ntype ProviderWritableCspDirective = (typeof PROVIDER_CSP_BUCKET_DIRECTIVES)[ProviderFrontendCspOriginBucket];\n\n/**\n * The directives a fetch falls back to when the directive a provider bucket maps to is ABSENT, most\n * specific first and excluding the directive itself — CSP Level 3's fetch-directive fallback list,\n * restricted to the directives `PROVIDER_CSP_BUCKET_DIRECTIVES` can write.\n *\n * spec-cite: CSP Level 3 (W3C Working Draft) §6.8.3 \"Get fetch directive fallback list\" —\n * https://www.w3.org/TR/CSP3/#directive-fallback-list. `script-src` and `style-src` are not keys of that\n * algorithm; they are the second step of the `-elem`/`-attr` chains, whose next step is `default-src`.\n * The algorithm also puts `child-src` before `script-src` for workers and before `default-src` for\n * frames; it is omitted here because `CSP_DIRECTIVE_NAMES` does not admit it, so a composed policy can\n * never state it and that step can never be the one in force.\n *\n * ## Why the provider layer needs it (#1702)\n *\n * Adding a source list for a directive the policy does not state does not ADD to what the page may do —\n * it REPLACES the fallback that was governing it. None of the three baselines states `worker-src` or\n * `media-src`, so a provider declaring `workerOrigins: ['blob:']` would otherwise have produced\n * `worker-src blob:` and silently revoked the page's own `'self'` workers, which `default-src 'self'` had\n * been admitting. Seeding the new directive from the list it was falling back to keeps the provider layer\n * additive, which is its whole contract. The same was already true, and latent, for `frame-src`.\n */\nconst PROVIDER_CSP_DIRECTIVE_FALLBACKS: Readonly<Record<ProviderWritableCspDirective, readonly CspDirectiveName[]>> = {\n 'script-src': ['default-src'],\n 'connect-src': ['default-src'],\n 'frame-src': ['default-src'],\n 'img-src': ['default-src'],\n 'style-src': ['default-src'],\n 'font-src': ['default-src'],\n 'worker-src': ['script-src', 'default-src'],\n 'media-src': ['default-src'],\n};\n\nexport interface ResolveCspPolicyInput {\n readonly frontendType: AppFrontendType;\n readonly appCsp: WildoCspConfig | undefined;\n readonly envOverride?: EnvCspOverride;\n /**\n * The CSP footprints of the providers DECLARED for this service — the fourth\n * layer, added by #332.\n *\n * Without it, a marketing site that wants an embedded meeting or a SaaS app\n * that wants a Drive picker means hand-editing script / frame / connect\n * origins per application, per service, per environment; and getting it wrong\n * is invisible until production, because development is report-only. The\n * caller reads these from the service's materialized provider block, which is\n * DATA precisely so that no frontend module has to be executed to obtain them.\n *\n * Providers declared for ANOTHER service must not appear here: the point of\n * the layer is that a Zoom origin admitted for the marketing site is not\n * thereby admitted for the SaaS app.\n *\n * A footprint's `derivedOrigins` must ALREADY BE RESOLVED into its buckets by\n * the caller. This resolver sees no `publicConfig` — it composes a policy, it\n * does not read a provider's configuration — and the one caller that has both\n * halves is `CspSyncService`, which reads each entry out of the materialized\n * block.\n */\n readonly providerCspFootprints?: ReadonlyArray<ProviderFrontendCspFootprint>;\n /**\n * Environment id this CSP is being resolved for (e.g. `'local'`,\n * `'staging'`, `'production'`, or any custom slug). Optional for\n * back-compat — when `undefined`, no env-aware auto-loosening applies\n * (the resolver behaves exactly as it did pre-`viteDevLoosening`).\n *\n * Required when the caller wants the framework to auto-apply\n * `viteDevLoosening` for `'local'` + `SAAS_APP`. The CLI's\n * `CspSyncService` already knows the env id and SHOULD pass it.\n */\n readonly environmentId?: string;\n}\n\nexport const NGINX_CSP_BEGIN_MARKER = '# >>> wildo csp begin';\nexport const NGINX_CSP_END_MARKER = '# <<< wildo csp end';\n\nconst META_INVALID_DIRECTIVES: ReadonlySet<string> = new Set([\n 'frame-ancestors',\n 'report-uri',\n 'report-to',\n 'sandbox',\n]);\n\n/**\n * Derives the WebSocket-scheme companion origins for every HTTP(S) origin\n * present in a `connect-src` source list, and returns the list widened to\n * include them.\n *\n * Why the framework ships this rather than making each app author it:\n * every Wildo backend serves its realtime channel (Socket.IO) on the SAME\n * origin as its HTTP API. Socket.IO opens the handshake over polling and\n * then UPGRADES to a raw `ws://` / `wss://` connection to that origin. The\n * CSP `connect-src` directive grades WebSocket connections by their `ws`/\n * `wss` scheme, and — per the CSP spec — an `http://host` source does NOT\n * authorize a `ws://host` connection (the schemes are distinct match\n * tokens). So an app that allow-lists `http://localhost:4241` for `fetch`/\n * `XHR` but not `ws://localhost:4241` will emit a `connect-src` violation\n * the instant the socket upgrades — exactly the trap every infra config\n * would otherwise have to remember to work around by hand.\n *\n * Transform (idempotent, dedupe-safe):\n * `http://host[:port]` → also allow `ws://host[:port]`\n * `https://host[:port]` → also allow `wss://host[:port]`\n * bare scheme `http:` → also allow `ws:`\n * bare scheme `https:` → also allow `wss:`\n *\n * Keyword / non-HTTP sources (`'self'`, `'none'`, `data:`, `blob:`, an\n * already-`ws://` origin, …) are passed through untouched. `'self'` is\n * deliberately NOT expanded: the browser tab is served from the frontend\n * origin, never the backend API origin, so a same-origin `ws` derivation\n * from `'self'` would authorize the wrong host. The backend origin is\n * always listed explicitly, which is what this widens.\n */\nfunction augmentConnectSrcWithWebSocketOrigins(\n sources: readonly string[] | undefined,\n): readonly string[] | undefined {\n if (!sources || sources.length === 0) {\n return sources;\n }\n\n const derived: string[] = [];\n for (const source of sources) {\n if (source.startsWith('https://')) {\n derived.push(`wss://${source.slice('https://'.length)}`);\n } else if (source.startsWith('http://')) {\n derived.push(`ws://${source.slice('http://'.length)}`);\n } else if (source === 'https:') {\n derived.push('wss:');\n } else if (source === 'http:') {\n derived.push('ws:');\n }\n }\n\n return mergeSourceLists(sources, derived);\n}\n\nfunction mergeSourceLists(\n a: readonly string[] | undefined,\n b: readonly string[] | undefined,\n): readonly string[] {\n if (!a || a.length === 0) {\n return b ?? [];\n }\n if (!b || b.length === 0) {\n return a;\n }\n\n const seen = new Set(a);\n const out: string[] = [...a];\n for (const source of b) {\n if (!seen.has(source)) {\n seen.add(source);\n out.push(source);\n }\n }\n return out;\n}\n\n/**\n * Resolves the generic layered CSP model shared by all frontend surfaces:\n * platform baseline, app-static config, env-selected overrides, then the\n * declared providers' own footprints (#332).\n *\n * The provider layer is fourth on purpose. The first three describe what the\n * APPLICATION decided; the fourth describes what the things the application\n * declared actually need in order to work. Placing it last means a provider\n * cannot be silently dropped by an app-level `REPLACE_BASELINE`, and placing it\n * before the WebSocket derivation means a provider's `connect-src` origin gets\n * its `wss://` companion exactly like the backend API's.\n *\n * This lives with the CSP schemas/defaults so consumers do not depend on any\n * concrete frontend package to process security config.\n */\nexport function resolveCspPolicy(\n input: ResolveCspPolicyInput,\n): ResolvedCspPolicy | null {\n const { frontendType, appCsp, envOverride } = input;\n\n if (!appCsp || !appCsp.enabled) {\n return null;\n }\n\n const baseline: CspBaselineDirectiveMap = CSP_BASELINES[frontendType];\n let merged: ResolvedCspDirectiveMap;\n\n if (appCsp.mergeStrategy === CspMergeStrategy.REPLACE_BASELINE) {\n merged = appCsp.directives;\n } else {\n const out: Partial<Record<CspDirectiveName, readonly string[]>> = {};\n const allKeys = new Set<CspDirectiveName>([\n ...(Object.keys(baseline) as CspDirectiveName[]),\n ...(Object.keys(appCsp.directives) as CspDirectiveName[]),\n ]);\n\n for (const key of allKeys) {\n out[key] = mergeSourceLists(baseline[key], appCsp.directives[key]);\n }\n\n merged = out;\n }\n\n if (envOverride?.extraDirectives) {\n const out: Partial<Record<CspDirectiveName, readonly string[]>> = {\n ...merged,\n };\n\n for (const key of Object.keys(envOverride.extraDirectives) as CspDirectiveName[]) {\n out[key] = mergeSourceLists(merged[key], envOverride.extraDirectives[key]);\n }\n\n merged = out;\n }\n\n // Provider layer (#332) — the origins the providers DECLARED FOR THIS SERVICE\n // need, merged after the app-static and env layers and before the WebSocket\n // derivation below (so a provider's `connect-src` origin gets its `wss://`\n // companion for free, exactly like the backend API's).\n //\n // Additive in every merge strategy, including REPLACE_BASELINE. That strategy\n // exists so an app can discard the platform BASELINE when it is wrong for the\n // surface; a provider the same app declared is a dependency it chose, not a\n // default it is overriding, and silently dropping its origins would produce a\n // policy that blocks a feature the app asked for — in production only.\n const providerFootprints = input.providerCspFootprints ?? [];\n if (providerFootprints.length > 0) {\n const out: Partial<Record<CspDirectiveName, readonly string[]>> = { ...merged };\n\n for (const footprint of providerFootprints) {\n for (const [bucket, directive] of Object.entries(PROVIDER_CSP_BUCKET_DIRECTIVES) as ReadonlyArray<\n readonly [ProviderFrontendCspOriginBucket, ProviderWritableCspDirective]\n >) {\n // `?? []`: a footprint read off an artifact older than a bucket lacks the key.\n const origins = footprint[bucket] ?? [];\n if (origins.length === 0) continue;\n // An absent directive is seeded from the one it was falling back to, so adding a provider's\n // origin never REVOKES what the fallback admitted — see `PROVIDER_CSP_DIRECTIVE_FALLBACKS`.\n const current = out[directive] ?? PROVIDER_CSP_DIRECTIVE_FALLBACKS[directive]\n .map((fallback) => out[fallback])\n .find((sources) => sources !== undefined);\n out[directive] = mergeSourceLists(current, origins);\n }\n }\n\n merged = out;\n }\n\n // Vite dev-mode loosening (auto-applied for local SAAS_APP).\n //\n // Vite's dev server REQUIRES both `'unsafe-eval'` (lazy module +\n // sourcemap transforms) and `'unsafe-inline'` (HMR client bootstrap\n // injects a literal inline `<script>`) to function. Under the tight\n // SAAS_APP baseline (`script-src 'self'`), those produce ~120+ CSP\n // violations per page load that drown out real signal (e.g. the\n // Google-Fonts gotcha that the loosened style-src/font-src now allow).\n //\n // The framework SHIPS this knowledge — every Wildo SaaS app uses\n // Vite — so we auto-loosen for `'local'` + `SAAS_APP` here rather\n // than forcing every infra config to re-author the same opt-in. An\n // explicit `viteDevLoosening: false` override keeps tight `script-src`\n // when an author is actively debugging a real CSP issue and willing\n // to accept the Vite noise. Production builds emit `<script\n // type=\"module\">` only and never `eval()`, so production envs never\n // trigger the auto-loosening — `viteDevLoosening` defaults to FALSE\n // there even if the env id is non-`local`.\n const isViteDevAutoTarget =\n input.environmentId === WildoEnvironment.LOCAL &&\n frontendType === AppFrontendType.SAAS_APP;\n const viteDevLoosening = envOverride?.viteDevLoosening ?? isViteDevAutoTarget;\n if (viteDevLoosening) {\n merged = {\n ...merged,\n 'script-src': mergeSourceLists(\n merged['script-src'],\n [\"'unsafe-inline'\", \"'unsafe-eval'\"],\n ),\n };\n }\n\n // Auto-derive the `ws://` / `wss://` companion origins for every HTTP(S)\n // origin the app allow-listed in `connect-src`. Applied LAST so it covers\n // origins contributed by the baseline, app-static config, AND env override\n // alike (e.g. the local `http://localhost:4241` and the staging/prod\n // `https://api.<app>.wildo.app` backend origins). Without this, the\n // Socket.IO transport upgrade to a raw WebSocket against the backend origin\n // trips a `connect-src` violation on every surface. See the helper JSDoc for\n // the scheme-matching rationale.\n const connectSrcWithWs = augmentConnectSrcWithWebSocketOrigins(merged['connect-src']);\n if (connectSrcWithWs !== merged['connect-src']) {\n merged = {\n ...merged,\n 'connect-src': connectSrcWithWs,\n };\n }\n\n return {\n directives: merged,\n reportOnly: envOverride?.reportOnly ?? appCsp.reportOnly,\n reportUri: envOverride?.reportUri ?? appCsp.reportUri,\n };\n}\n\nfunction serializeDirectives(directives: ResolvedCspDirectiveMap): string {\n return Object.entries(directives)\n .filter(([, sources]) => sources && sources.length > 0)\n .map(([name, sources]) => `${name} ${(sources ?? []).join(' ')}`)\n .join('; ');\n}\n\nfunction stripMetaInvalidDirectives(\n directives: ResolvedCspDirectiveMap,\n): ResolvedCspDirectiveMap {\n const out: Partial<Record<CspDirectiveName, readonly string[]>> = {};\n\n for (const [name, sources] of Object.entries(directives)) {\n if (!META_INVALID_DIRECTIVES.has(name)) {\n out[name as CspDirectiveName] = sources;\n }\n }\n\n return out;\n}\n\nfunction withReportUri(\n directives: ResolvedCspDirectiveMap,\n reportUri: string | undefined,\n): ResolvedCspDirectiveMap {\n if (!reportUri) {\n return directives;\n }\n\n return {\n ...directives,\n ['report-uri' as CspDirectiveName]: [reportUri],\n };\n}\n\nexport function emitCspArtifacts(policy: ResolvedCspPolicy): CspEmitArtifacts {\n const nginxHeaderName = policy.reportOnly\n ? 'Content-Security-Policy-Report-Only'\n : 'Content-Security-Policy';\n const nginxPolicyValue = serializeDirectives(\n withReportUri(policy.directives, policy.reportUri),\n );\n\n return {\n nginxHeaderName,\n nginxPolicyValue,\n nginxAddHeaderLine: `add_header ${nginxHeaderName} \"${nginxPolicyValue}\" always;`,\n metaTag: policy.reportOnly\n ? null\n : {\n tagName: 'meta',\n attributes: {\n 'http-equiv': 'Content-Security-Policy',\n content: serializeDirectives(stripMetaInvalidDirectives(policy.directives)),\n },\n },\n };\n}\n\n/**\n * A single static-host `_headers` block that delivers the resolved CSP as a\n * real response header at the `/*` (all-paths) scope.\n *\n * Format matches the `_headers` convention consumed by Cloudflare Pages /\n * Netlify / Vercel (and the `saas-website` `X-Robots-Tag` `_headers` emitter):\n * a path line, then two-space-indented `Header-Name: value` lines. This is the\n * PORTABLE, provider-agnostic edge-CSP delivery — a CDN-served frontend (which\n * has no nginx to `add_header`) ships this file in its bucket and any\n * `_headers`-aware host applies it.\n *\n * Uses the FULL header value (including the header-only `frame-ancestors` and\n * `report-uri` directives) — a `_headers` line is a genuine response header, so\n * nothing is stripped (unlike the `<meta http-equiv>` fallback). Report-only\n * policies are honoured (the header name flips to\n * `Content-Security-Policy-Report-Only`, valid on a real header channel).\n *\n * The caller composes this block with any other `_headers` blocks (e.g. the\n * website's per-path `X-Robots-Tag`) into one file, separated by a blank line.\n */\nexport function emitCspHeadersFileBlock(policy: ResolvedCspPolicy): string {\n const { nginxHeaderName, nginxPolicyValue } = emitCspArtifacts(policy);\n return `/*\\n ${nginxHeaderName}: ${nginxPolicyValue}`;\n}\n\n/**\n * Provider-agnostic descriptor of the response-header MODIFICATION a CDN vendor\n * must install to deliver the resolved CSP at the edge. A concrete vendor\n * adapter (e.g. Cloudflare) maps this to its own API shape — for Cloudflare, a\n * `http_response_headers_transform` ruleset rule whose action sets\n * `headerName` to `value`.\n *\n * Same FULL header name + value as the nginx / `_headers` channels (a CDN sets\n * a real header, so `frame-ancestors` / `report-uri` are valid and retained).\n */\nexport interface CspEdgeHeaderModification {\n /** Cloudflare ruleset phase this modification belongs to. */\n readonly phase: 'http_response_headers_transform';\n /** The header operation — always `set` (overwrite any origin value). */\n readonly operation: 'set';\n /** Response-header name (report-only-aware, same as the nginx channel). */\n readonly headerName: string;\n /** Serialized policy value (identical to `nginxPolicyValue`). */\n readonly value: string;\n}\n\n/**\n * Derive the edge response-header modification carrying the resolved CSP, for a\n * CDN vendor's live-provisioning adapter to install. Thin over\n * {@link emitCspArtifacts} so the directive serialization is the single source\n * of truth across nginx / `_headers` / CDN channels.\n */\nexport function emitCspEdgeHeaderModification(policy: ResolvedCspPolicy): CspEdgeHeaderModification {\n const { nginxHeaderName, nginxPolicyValue } = emitCspArtifacts(policy);\n return {\n phase: 'http_response_headers_transform',\n operation: 'set',\n headerName: nginxHeaderName,\n value: nginxPolicyValue,\n };\n}\n\nexport interface RewriteNginxResult {\n readonly totalPairs: number;\n readonly pairsRewritten: number;\n readonly fileWritten: boolean;\n}\n\nexport function rewriteNginxCspMarkerPairs(\n filePath: string,\n addHeaderLine: string,\n): RewriteNginxResult {\n const original = readFileSync(filePath, 'utf-8');\n const { rewritten, totalPairs, pairsChanged } = rewriteNginxCspMarkerPairsString(\n original,\n addHeaderLine,\n filePath,\n );\n const fileWritten = rewritten !== original;\n\n if (fileWritten) {\n writeFileSync(filePath, rewritten, 'utf-8');\n }\n\n return {\n totalPairs,\n pairsRewritten: pairsChanged,\n fileWritten,\n };\n}\n\nexport function rewriteNginxCspMarkerPairsString(\n source: string,\n addHeaderLine: string,\n filePath = '<in-memory>',\n): {\n readonly rewritten: string;\n readonly totalPairs: number;\n readonly pairsChanged: number;\n} {\n const usesCrlf = source.includes('\\r\\n');\n const newline = usesCrlf ? '\\r\\n' : '\\n';\n const lines = source.split(newline);\n\n let totalPairs = 0;\n let pairsChanged = 0;\n let openBeginIndex: number | null = null;\n let openIndent = '';\n\n for (let index = 0; index < lines.length; index += 1) {\n const trimmed = lines[index].trim();\n\n if (trimmed === NGINX_CSP_BEGIN_MARKER) {\n if (openBeginIndex !== null) {\n throw new Error(\n `[csp-emit] ${filePath}:${index + 1} found a second '${NGINX_CSP_BEGIN_MARKER}' before the previous '${NGINX_CSP_END_MARKER}' (line ${openBeginIndex + 1})`,\n );\n }\n\n openBeginIndex = index;\n openIndent = lines[index].slice(0, lines[index].indexOf('#'));\n continue;\n }\n\n if (trimmed === NGINX_CSP_END_MARKER) {\n if (openBeginIndex === null) {\n throw new Error(\n `[csp-emit] ${filePath}:${index + 1} found '${NGINX_CSP_END_MARKER}' without a matching '${NGINX_CSP_BEGIN_MARKER}'`,\n );\n }\n\n totalPairs += 1;\n\n const existingBody = lines.slice(openBeginIndex + 1, index);\n const canonicalBody = [`${openIndent}${addHeaderLine}`];\n const existingNonBlank = existingBody.filter((line) => line.trim().length > 0);\n const canonicalNonBlank = canonicalBody.filter((line) => line.trim().length > 0);\n const bodyMatches =\n existingNonBlank.length === canonicalNonBlank.length &&\n existingNonBlank.every((line, bodyIndex) => line === canonicalNonBlank[bodyIndex]);\n\n if (!bodyMatches) {\n lines.splice(openBeginIndex + 1, index - openBeginIndex - 1, ...canonicalBody);\n index = openBeginIndex + canonicalBody.length + 1;\n pairsChanged += 1;\n }\n\n openBeginIndex = null;\n openIndent = '';\n }\n }\n\n if (openBeginIndex !== null) {\n throw new Error(\n `[csp-emit] ${filePath} has an unclosed '${NGINX_CSP_BEGIN_MARKER}' starting at line ${openBeginIndex + 1}`,\n );\n }\n\n return { rewritten: lines.join(newline), totalPairs, pairsChanged };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"csp.schemas.d.ts","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"csp.schemas.d.ts","sourceRoot":"","sources":["../../../../src/project-config/shared/csp.schemas.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4FG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,mBAAmB,+MAetB,CAAC;AAEX,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,mBAAmB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEpE;;;;;;;;;;;;;GAaG;AACH,oBAAY,gBAAgB;IAC1B,eAAe,oBAAoB;IACnC,gBAAgB,qBAAqB;CACtC;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,2BAA2B,8RAOvC,CAAC;AACF,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAEhF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,eAAO,MAAM,oBAAoB;IAC/B;;;;;OAKG;;IAEH;;;;;;;;;;;OAWG;;IAEH;;;;OAIG;;IAIH;;;OAGG;;IAEH;;;;;;;OAOG;;kBAEH,CAAC;AACH,iEAAiE;AACjE,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAClE,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAEvE;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,oBAAoB;IAC/B;;;;;OAKG;;IAEH;;;;;;;;;;;;;;;;;;;;;;;OAuBG;;IAEH;;;;;;OAMG;;IAEH;;;OAGG;;kBAEH,CAAC;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAClE,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"csp.schemas.js","sourceRoot":"","sources":["../../../../../src/project-config/shared/csp.schemas.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4FG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,aAAa;IACb,YAAY;IACZ,WAAW;IACX,SAAS;IACT,aAAa;IACb,UAAU;IACV,WAAW;IACX,iBAAiB;IACjB,YAAY;IACZ,aAAa;IACb,UAAU;IACV,cAAc;IACd,WAAW;IACX,YAAY;CACJ,CAAC;AAIX;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAN,IAAY,gBAGX;AAHD,WAAY,gBAAgB;IAC1B,uDAAmC,CAAA;IACnC,yDAAqC,CAAA;AACvC,CAAC,EAHW,gBAAgB,KAAhB,gBAAgB,QAG3B;AAED;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC,YAAY,CACvD,MAAM,CAAC,WAAW,CAChB,mBAAmB,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;IAChC,IAAI;IACJ,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;CACtC,CAAC,CACiE,CACtE,CAAC;AAGF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,YAAY,CAAC;IACjD;;;;;OAKG;IACH,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;IACnC;;;;;;;;;;;OAWG;IACH,UAAU,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;IACtC;;;;OAIG;IACH,aAAa,EAAE,CAAC;SACb,IAAI,CAAC,gBAAgB,CAAC;SACtB,OAAO,CAAC,gBAAgB,CAAC,eAAe,CAAC;IAC5C;;;OAGG;IACH,UAAU,EAAE,2BAA2B,CAAC,OAAO,CAAC,EAAE,CAAC;IACnD;;;;;;;OAOG;IACH,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;CACxC,CAAC,CAAC;AAKH;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,YAAY,CAAC;IACjD;;;;;OAKG;IACH,eAAe,EAAE,2BAA2B,CAAC,OAAO,CAAC,EAAE,CAAC;IACxD;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,gBAAgB,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IACxC;;;;;;OAMG;IACH,UAAU,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IAClC;;;OAGG;IACH,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;CACxC,CAAC,CAAC","sourcesContent":["/**\n * Content-Security-Policy authoring schema for per-frontend opt-in.\n *\n * # Where this fits in the layered CSP cake\n *\n * 1. Platform default — `./csp-defaults.ts` ships per-`AppFrontendType`\n * baselines (`SAAS_APP`, `STATIC_WEBSITE`, `TECH_DOC`). The baseline\n * is opinionated but conservative: `default-src 'self'` plus the\n * narrowest set of relaxations each frontend kind genuinely needs\n * to render (e.g., Docusaurus 3.x's `'unsafe-inline'` script /\n * style requirement for `TECH_DOC`).\n * 2. App-static — this `WildoCspConfigSchema`, authored on each\n * service-definition's `csp?` field. `SAAS_APP` authors this on\n * `wildo.saas.config.ts > services.<key>.csp`; `STATIC_WEBSITE` authors\n * it on `wildo.website.config.ts`; `TECH_DOC` authors it on\n * `wildo.tech-doc.config.ts`.\n * 3. Env-specific — `EnvCspOverrideSchema` below, authored under\n * `wildo.infra.<env>.config.ts.csp?[serviceKey]`. `WildoInfraEnvConfigSchema`\n * declares that field, so the layer is live. Its build-time consumer is\n * `wildo dev sync-csp`, which reads `parsed.csp[serviceKey]` when emitting\n * generated frontend CSP artifacts.\n * 4. Declared providers — NOT authored here at all (#332). Each frontend\n * provider declares the origins it needs to reach on its own module, that\n * footprint travels as data into the materialized frontend-services\n * artifact, and `resolveCspPolicy` merges the footprints of the providers\n * declared FOR THIS SERVICE. Layers 1–3 say what the application decided;\n * layer 4 says what the things it declared actually need in order to work,\n * which is why it is additive even under `replace-baseline`.\n *\n * # Resolution semantics (consumed by `platform-config-lib/src/project-config/shared/csp-emit.ts`)\n *\n * - `enabled: false` (default) => no policy emitted; the resolver\n * returns `null` and both nginx + meta channels stay silent. The\n * opt-in shape (vs opt-out) is deliberate — frontends that have not\n * audited their third-party surface should not ship a half-baked\n * CSP that breaks features without protecting anything.\n * - `enabled: true` with no `directives` override => baseline emitted\n * verbatim (see `./csp-defaults.ts`).\n * - `enabled: true` with `directives` AND `mergeStrategy: 'extend-baseline'`\n * (default) => per-directive ADDITIVE merge: each authored source\n * list is concatenated to the baseline's source list for that\n * directive (de-duplicated, baseline order preserved, app sources\n * appended in author order). Directives the baseline doesn't ship\n * are added wholesale.\n * - `enabled: true` with `mergeStrategy: 'replace-baseline'` =>\n * authored `directives` map REPLACES the baseline entirely; missing\n * directives are simply absent from the policy. Use only when the\n * baseline is fundamentally wrong for the surface (e.g., a\n * `STATIC_WEBSITE` that actually serves an embedded SaaS app and\n * wants the tighter `SAAS_APP`-style policy from scratch). The\n * escape hatch exists; the merge default exists for the common\n * case (additive tightening / loosening).\n * - `reportOnly: true` => header name flips to\n * `Content-Security-Policy-Report-Only` AND the `<meta http-equiv>`\n * channel goes silent (browsers reject the report-only header via\n * meta — W3C CSP3 §4.2.1). `reportOnly: false` (default once the\n * pilot triages clean) emits the enforcing header AND the meta\n * tag (with header-only directives stripped from the meta tag —\n * see `META_INVALID_DIRECTIVES` in `csp-emit.ts`).\n * - `reportUri` => header-only directive value (the meta tag would\n * ignore it). The resolver feeds it to the nginx channel only.\n *\n * # Why the `directives` keys are an explicit closed set vs a free-form `Record<string, ...>`\n *\n * CSP grew organically over a decade and a half. The closed set below\n * (`default-src` / `script-src` / `style-src` / `img-src` / `connect-src`\n * / `font-src` / `frame-src` / `frame-ancestors` / `object-src` /\n * `form-action` / `base-uri` / `manifest-src` / `media-src` / `worker-src`)\n * covers every directive the platform's three frontend kinds genuinely\n * use today. Forcing authors to spell directive names through the schema\n * surface (vs `Record<string, string[]>`) catches typos at parse time\n * (`script-source` !== `script-src`) and gives IDE autocompletion. Adding\n * a new directive is a one-line schema edit when a real consumer asks\n * for it; meanwhile the default-deny stance prevents authors from\n * accidentally shipping a directive name the browser silently ignores.\n *\n * # Author-friendly source lists\n *\n * Each directive's value is `string[]`. The resolver does NOT validate\n * the contents of the source list (that would require importing a CSP\n * grammar — out of scope for this commit). Common shapes:\n *\n * - `\"'self'\"` — single-quoted keyword, MUST keep the quotes.\n * - `'data:'`, `'blob:'` — scheme sources.\n * - `'https://api.example.com'` — origin source.\n * - `\"'unsafe-inline'\"`, `\"'unsafe-eval'\"` — single-quoted keywords.\n * - `\"'nonce-<base64>'\"` — nonce keyword (rendered per-request).\n * - `\"'sha256-<hash>'\"` — hash keyword.\n *\n * The `csp-emit.ts` serializer joins source lists with single spaces\n * and separates directives with `; ` (no leading/trailing semicolon —\n * matches Mozilla / OWASP recommended whitespace).\n */\n\nimport { z } from 'zod';\n\n/**\n * Closed set of directive names we accept on the `csp.directives`\n * authoring map. Adding a new directive name requires:\n *\n * 1. Adding the literal here.\n * 2. Updating any per-`AppFrontendType` baseline that should ship the\n * directive by default in `./csp-defaults.ts`.\n * 3. Verifying the `csp-emit.ts` serializer handles the directive\n * (it does — the serializer is generic over directive names — so\n * step 3 is usually a no-op).\n *\n * The `META_INVALID_DIRECTIVES` set in `csp-emit.ts` lists the\n * directives the browser ignores when emitted via `<meta http-equiv>`\n * (`frame-ancestors`, `report-uri`, `report-to`, `sandbox`); they're\n * stripped from the meta-channel output but remain on the nginx\n * channel. Keep that set in sync if a new header-only directive lands\n * here.\n */\nexport const CSP_DIRECTIVE_NAMES = [\n 'default-src',\n 'script-src',\n 'style-src',\n 'img-src',\n 'connect-src',\n 'font-src',\n 'frame-src',\n 'frame-ancestors',\n 'object-src',\n 'form-action',\n 'base-uri',\n 'manifest-src',\n 'media-src',\n 'worker-src',\n] as const;\n\nexport type CspDirectiveName = (typeof CSP_DIRECTIVE_NAMES)[number];\n\n/**\n * Author-side merge strategy for the app-static layer over the baseline.\n *\n * - `'extend-baseline'` (default) — per-directive ADDITIVE merge:\n * each authored source list is APPENDED to the baseline source\n * list for that directive. Directives the baseline doesn't ship\n * are added wholesale. Common case: an app needs to add ONE extra\n * `connect-src` origin without re-authoring the rest of the policy.\n * - `'replace-baseline'` — authored `directives` map REPLACES the\n * baseline entirely. Use when the baseline is fundamentally wrong\n * for the surface (e.g., a tighter or fundamentally different\n * posture). Escape hatch — the merge default is the right answer\n * in 95% of cases.\n */\nexport enum CspMergeStrategy {\n EXTEND_BASELINE = 'extend-baseline',\n REPLACE_BASELINE = 'replace-baseline',\n}\n\n/**\n * Author-side directive overrides — partial map keyed by the closed\n * directive-name set above. Each value is a source list of strings\n * (joined with single spaces by the serializer).\n *\n * Authoring `directives: { 'connect-src': ['https://api.example.com'] }`\n * with the default `'extend-baseline'` strategy APPENDS that origin to\n * the baseline `connect-src` source list (which already contains\n * `'self'` for every baseline) — it does NOT replace the baseline's\n * `connect-src`. Use `mergeStrategy: 'replace-baseline'` to opt out of\n * additive merging.\n */\nexport const CspDirectivesOverrideSchema = z.strictObject(\n Object.fromEntries(\n CSP_DIRECTIVE_NAMES.map((name) => [\n name,\n z.array(z.string().min(1)).optional(),\n ]),\n ) as Record<CspDirectiveName, z.ZodOptional<z.ZodArray<z.ZodString>>>,\n);\nexport type CspDirectivesOverride = z.infer<typeof CspDirectivesOverrideSchema>;\n\n/**\n * @wildo_source:part:start saas.config.content-security-policy facet:layer:shared facet:audience:app-developer\n *\n * Declaring a Content-Security-Policy for one of the application's frontends.\n *\n * ⚠️ **Every browser surface ships a policy; what differs is what happens when you author none.** On\n * the application (`services.<key>.csp`) an omitted block resolves at sync to `enabled: true,\n * reportOnly: true` — a policy that reports violations and blocks nothing. A website or technical-doc\n * config with no block is refused at sync, naming the file. A policy that resolves DISABLED is refused\n * on every surface, so `enabled: false` cannot switch the header off.\n *\n * ## The generated file is the only one read\n *\n * Author the static posture here, add per-environment entries under `csp.<serviceKey>` in that\n * environment's infrastructure configuration, then run `wildo dev sync-csp --env <env>` (starting\n * development runs it for you). Each surface reads ONLY the generated artifact — hand-editing a\n * surface's own policy file changes nothing and is overwritten on the next sync.\n *\n * ## `reportOnly` is a posture, not a formality\n *\n * `reportOnly: true` emits the report-only header: the browser reports violations and BLOCKS\n * NOTHING. Flipping it is one field. Note also that a `report-uri` is supported by the schema and the\n * emitter and no baseline ships a collector, so with nothing authored there the reports a browser\n * generates have nowhere to go — report-only plus no collector is a policy that neither blocks nor\n * tells you anything.\n *\n * Nonces and hashes are not generated per request or at build time. A source list may name one by\n * hand, but there is no generation, which is why a baseline that must admit inline script still does.\n *\n * Per-frontend CSP block. Authored on each service-definition's `csp?`\n * field. All three surfaces carry it: `wildo.tech-doc.config.ts.csp?`,\n * `wildo.website.config.ts.csp?`, and `services.<key>.csp` on the\n * `SAAS_APP` service definition.\n *\n * An AUTHORED block that omits `enabled` parses as `enabled: false`, which the resolver turns into no\n * policy and the sync then refuses — so author `enabled: true` explicitly whenever you write a block.\n *\n * `z.strictObject` (Zod 4) is intentional — typos like `enable: true`\n * (no `d`) or `directive: { … }` (no plural) MUST surface as parse\n * errors, not silently strip to `enabled: false` (i.e. CSP off, the\n * worst possible default). Same framework-mindset enforcement as\n * `WildoAuthConfigSchema`.\n */\nexport const WildoCspConfigSchema = z.strictObject({\n /**\n * `true` => baseline (+ overrides) emitted on both channels per `reportOnly`.\n * `false` — also the parse default for an authored block — makes the resolver return `null`, and\n * `wildo dev sync-csp` refuses that for every CSP-capable surface. It is not a way to turn the\n * header off.\n */\n enabled: z.boolean().default(false),\n /**\n * `true` => header name flips to `Content-Security-Policy-Report-Only`\n * AND the `<meta http-equiv>` channel goes silent (browsers reject the\n * report-only header via meta — W3C CSP3 §4.2.1). Use during the\n * pilot to triage console-surfaced violations without breaking real\n * traffic. Flip to `false` once the directive overrides settle.\n *\n * Default: `false` (enforcing). Authors opting into CSP for the first\n * time SHOULD set `reportOnly: true` for the first PR; the schema\n * default is intentionally enforcing so the steady state (post-pilot)\n * doesn't require a per-app authored `reportOnly: false`.\n */\n reportOnly: z.boolean().default(false),\n /**\n * Merge strategy for authored `directives` over the baseline. Default:\n * `'extend-baseline'` (per-directive additive merge — see\n * `CspMergeStrategy`).\n */\n mergeStrategy: z\n .enum(CspMergeStrategy)\n .default(CspMergeStrategy.EXTEND_BASELINE),\n /**\n * Per-directive overrides, keyed by directive name. Default: empty\n * map (baseline emitted verbatim).\n */\n directives: CspDirectivesOverrideSchema.default({}),\n /**\n * Optional `report-uri` directive value (header-only — meta tag\n * ignores it; the resolver feeds it to the nginx channel only).\n * No `report-to` field today — `report-to` requires the parallel\n * Reporting API endpoint config which the platform doesn't ship; add\n * when the violation-collector lands (`auth-hardening.md` \"Cheap\n * Bonuses — CSP violation monitoring endpoint\").\n */\n reportUri: z.string().min(1).optional(),\n});\n/** @wildo_source:part:end saas.config.content-security-policy */\nexport type WildoCspConfig = z.infer<typeof WildoCspConfigSchema>;\nexport type WildoCspConfigInput = z.input<typeof WildoCspConfigSchema>;\n\n/**\n * Env-specific overrides — authored under\n * `wildo.infra.<env>.config.ts.csp?[serviceKey]`. The loader merges\n * these on top of the app-static layer (which itself is on top of the\n * baseline).\n *\n * `WildoInfraEnvConfigSchema` declares `csp` as a record of these,\n * keyed by service key, and the resolver in `csp-emit.ts` consumes it.\n *\n * `extraDirectives` is ADDITIVE only — env-layer entries are APPENDED\n * to whatever the app-static layer produced for that directive. There\n * is no `'replace-baseline'`-equivalent at the env layer because env\n * config exists to LOOSEN policies for specific deployments (Sentry\n * origin in staging, dev hot-reload `'unsafe-eval'`), not to replace\n * an app's chosen posture. If an env genuinely needs a different\n * posture the right answer is to fix the app-static layer.\n */\nexport const EnvCspOverrideSchema = z.strictObject({\n /**\n * Per-directive ADDITIVE merge. Each entry's source list is\n * APPENDED to the app-static layer's source list for that directive\n * (de-duplicated, app order preserved, env sources appended in\n * author order). No replace semantics at this layer.\n */\n extraDirectives: CspDirectivesOverrideSchema.default({}),\n /**\n * Vite dev-mode CSP loosening: adds BOTH `'unsafe-inline'` and\n * `'unsafe-eval'` to `script-src`. Vite's dev server injects an\n * inline `<script>` for the HMR client bootstrap AND uses `eval()`\n * for lazy module / sourcemap transforms — both block under a strict\n * `script-src 'self'` policy and produce ~120+ CSP violations per\n * page load. Production Vite builds emit `<script type=\"module\">`\n * only and use no `eval()`, so this loosening is dev-only by design.\n *\n * AUTO-DEFAULT: `true` when the resolved env id is `'local'` AND the\n * frontend type is `SAAS_APP` (the only Vite-bundled frontend kind in\n * the framework). The framework applies the loosening automatically so\n * every Wildo app gets a clean dev console without per-app\n * configuration; opting in app-by-app would scatter the same\n * framework-shipped Vite knowledge across N infrastructure files.\n *\n * EXPLICIT OPT-OUT: set to `false` to keep tight `script-src` in\n * local dev. Useful only when actively debugging a real CSP issue\n * and willing to accept Vite-induced noise. Production envs ignore\n * this flag's auto-default and require explicit opt-in (extremely\n * unusual — a production app that needs `'unsafe-inline'` /\n * `'unsafe-eval'` is almost always a sign of a misconfigured asset\n * pipeline).\n */\n viteDevLoosening: z.boolean().optional(),\n /**\n * Env-layer override of the app-static `reportOnly` flag. When\n * present (not `undefined`), takes precedence over the app-static\n * value. Common shape: app-static ships `reportOnly: false`\n * (enforcing in prod), env-layer flips to `reportOnly: true` for\n * staging while the violation collector ramps up.\n */\n reportOnly: z.boolean().optional(),\n /**\n * Env-layer override of the app-static `reportUri` (e.g., per-env\n * collector endpoint).\n */\n reportUri: z.string().min(1).optional(),\n});\nexport type EnvCspOverride = z.infer<typeof EnvCspOverrideSchema>;\nexport type EnvCspOverrideInput = z.input<typeof EnvCspOverrideSchema>;\n"]}
|
|
1
|
+
{"version":3,"file":"csp.schemas.js","sourceRoot":"","sources":["../../../../src/project-config/shared/csp.schemas.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4FG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,aAAa;IACb,YAAY;IACZ,WAAW;IACX,SAAS;IACT,aAAa;IACb,UAAU;IACV,WAAW;IACX,iBAAiB;IACjB,YAAY;IACZ,aAAa;IACb,UAAU;IACV,cAAc;IACd,WAAW;IACX,YAAY;CACJ,CAAC;AAIX;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAN,IAAY,gBAGX;AAHD,WAAY,gBAAgB;IAC1B,uDAAmC,CAAA;IACnC,yDAAqC,CAAA;AACvC,CAAC,EAHW,gBAAgB,KAAhB,gBAAgB,QAG3B;AAED;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC,YAAY,CACvD,MAAM,CAAC,W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,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;CACxC,CAAC,CAAC","sourcesContent":["/**\n * Content-Security-Policy authoring schema for per-frontend opt-in.\n *\n * # Where this fits in the layered CSP cake\n *\n * 1. Platform default — `./csp-defaults.ts` ships per-`AppFrontendType`\n * baselines (`SAAS_APP`, `STATIC_WEBSITE`, `TECH_DOC`). The baseline\n * is opinionated but conservative: `default-src 'self'` plus the\n * narrowest set of relaxations each frontend kind genuinely needs\n * to render (e.g., Docusaurus 3.x's `'unsafe-inline'` script /\n * style requirement for `TECH_DOC`).\n * 2. App-static — this `WildoCspConfigSchema`, authored on each\n * service-definition's `csp?` field. `SAAS_APP` authors this on\n * `wildo.saas.config.ts > services.<key>.csp`; `STATIC_WEBSITE` authors\n * it on `wildo.website.config.ts`; `TECH_DOC` authors it on\n * `wildo.tech-doc.config.ts`.\n * 3. Env-specific — `EnvCspOverrideSchema` below, authored under\n * `wildo.infra.<env>.config.ts.csp?[serviceKey]`. `WildoInfraEnvConfigSchema`\n * declares that field, so the layer is live. Its build-time consumer is\n * `wildo dev sync-csp`, which reads `parsed.csp[serviceKey]` when emitting\n * generated frontend CSP artifacts.\n * 4. Declared providers — NOT authored here at all (#332). Each frontend\n * provider declares the origins it needs to reach on its own module, that\n * footprint travels as data into the materialized frontend-services\n * artifact, and `resolveCspPolicy` merges the footprints of the providers\n * declared FOR THIS SERVICE. Layers 1–3 say what the application decided;\n * layer 4 says what the things it declared actually need in order to work,\n * which is why it is additive even under `replace-baseline`.\n *\n * # Resolution semantics (consumed by `platform-config-lib/src/project-config/shared/csp-emit.ts`)\n *\n * - `enabled: false` (default) => no policy emitted; the resolver\n * returns `null` and both nginx + meta channels stay silent. The\n * opt-in shape (vs opt-out) is deliberate — frontends that have not\n * audited their third-party surface should not ship a half-baked\n * CSP that breaks features without protecting anything.\n * - `enabled: true` with no `directives` override => baseline emitted\n * verbatim (see `./csp-defaults.ts`).\n * - `enabled: true` with `directives` AND `mergeStrategy: 'extend-baseline'`\n * (default) => per-directive ADDITIVE merge: each authored source\n * list is concatenated to the baseline's source list for that\n * directive (de-duplicated, baseline order preserved, app sources\n * appended in author order). Directives the baseline doesn't ship\n * are added wholesale.\n * - `enabled: true` with `mergeStrategy: 'replace-baseline'` =>\n * authored `directives` map REPLACES the baseline entirely; missing\n * directives are simply absent from the policy. Use only when the\n * baseline is fundamentally wrong for the surface (e.g., a\n * `STATIC_WEBSITE` that actually serves an embedded SaaS app and\n * wants the tighter `SAAS_APP`-style policy from scratch). The\n * escape hatch exists; the merge default exists for the common\n * case (additive tightening / loosening).\n * - `reportOnly: true` => header name flips to\n * `Content-Security-Policy-Report-Only` AND the `<meta http-equiv>`\n * channel goes silent (browsers reject the report-only header via\n * meta — W3C CSP3 §4.2.1). `reportOnly: false` (default once the\n * pilot triages clean) emits the enforcing header AND the meta\n * tag (with header-only directives stripped from the meta tag —\n * see `META_INVALID_DIRECTIVES` in `csp-emit.ts`).\n * - `reportUri` => header-only directive value (the meta tag would\n * ignore it). The resolver feeds it to the nginx channel only.\n *\n * # Why the `directives` keys are an explicit closed set vs a free-form `Record<string, ...>`\n *\n * CSP grew organically over a decade and a half. The closed set below\n * (`default-src` / `script-src` / `style-src` / `img-src` / `connect-src`\n * / `font-src` / `frame-src` / `frame-ancestors` / `object-src` /\n * `form-action` / `base-uri` / `manifest-src` / `media-src` / `worker-src`)\n * covers every directive the platform's three frontend kinds genuinely\n * use today. Forcing authors to spell directive names through the schema\n * surface (vs `Record<string, string[]>`) catches typos at parse time\n * (`script-source` !== `script-src`) and gives IDE autocompletion. Adding\n * a new directive is a one-line schema edit when a real consumer asks\n * for it; meanwhile the default-deny stance prevents authors from\n * accidentally shipping a directive name the browser silently ignores.\n *\n * # Author-friendly source lists\n *\n * Each directive's value is `string[]`. The resolver does NOT validate\n * the contents of the source list (that would require importing a CSP\n * grammar — out of scope for this commit). Common shapes:\n *\n * - `\"'self'\"` — single-quoted keyword, MUST keep the quotes.\n * - `'data:'`, `'blob:'` — scheme sources.\n * - `'https://api.example.com'` — origin source.\n * - `\"'unsafe-inline'\"`, `\"'unsafe-eval'\"` — single-quoted keywords.\n * - `\"'nonce-<base64>'\"` — nonce keyword (rendered per-request).\n * - `\"'sha256-<hash>'\"` — hash keyword.\n *\n * The `csp-emit.ts` serializer joins source lists with single spaces\n * and separates directives with `; ` (no leading/trailing semicolon —\n * matches Mozilla / OWASP recommended whitespace).\n */\n\nimport { z } from 'zod';\n\n/**\n * Closed set of directive names we accept on the `csp.directives`\n * authoring map. Adding a new directive name requires:\n *\n * 1. Adding the literal here.\n * 2. Updating any per-`AppFrontendType` baseline that should ship the\n * directive by default in `./csp-defaults.ts`.\n * 3. Verifying the `csp-emit.ts` serializer handles the directive\n * (it does — the serializer is generic over directive names — so\n * step 3 is usually a no-op).\n *\n * The `META_INVALID_DIRECTIVES` set in `csp-emit.ts` lists the\n * directives the browser ignores when emitted via `<meta http-equiv>`\n * (`frame-ancestors`, `report-uri`, `report-to`, `sandbox`); they're\n * stripped from the meta-channel output but remain on the nginx\n * channel. Keep that set in sync if a new header-only directive lands\n * here.\n */\nexport const CSP_DIRECTIVE_NAMES = [\n 'default-src',\n 'script-src',\n 'style-src',\n 'img-src',\n 'connect-src',\n 'font-src',\n 'frame-src',\n 'frame-ancestors',\n 'object-src',\n 'form-action',\n 'base-uri',\n 'manifest-src',\n 'media-src',\n 'worker-src',\n] as const;\n\nexport type CspDirectiveName = (typeof CSP_DIRECTIVE_NAMES)[number];\n\n/**\n * Author-side merge strategy for the app-static layer over the baseline.\n *\n * - `'extend-baseline'` (default) — per-directive ADDITIVE merge:\n * each authored source list is APPENDED to the baseline source\n * list for that directive. Directives the baseline doesn't ship\n * are added wholesale. Common case: an app needs to add ONE extra\n * `connect-src` origin without re-authoring the rest of the policy.\n * - `'replace-baseline'` — authored `directives` map REPLACES the\n * baseline entirely. Use when the baseline is fundamentally wrong\n * for the surface (e.g., a tighter or fundamentally different\n * posture). Escape hatch — the merge default is the right answer\n * in 95% of cases.\n */\nexport enum CspMergeStrategy {\n EXTEND_BASELINE = 'extend-baseline',\n REPLACE_BASELINE = 'replace-baseline',\n}\n\n/**\n * Author-side directive overrides — partial map keyed by the closed\n * directive-name set above. Each value is a source list of strings\n * (joined with single spaces by the serializer).\n *\n * Authoring `directives: { 'connect-src': ['https://api.example.com'] }`\n * with the default `'extend-baseline'` strategy APPENDS that origin to\n * the baseline `connect-src` source list (which already contains\n * `'self'` for every baseline) — it does NOT replace the baseline's\n * `connect-src`. Use `mergeStrategy: 'replace-baseline'` to opt out of\n * additive merging.\n */\nexport const CspDirectivesOverrideSchema = z.strictObject(\n Object.fromEntries(\n CSP_DIRECTIVE_NAMES.map((name) => [\n name,\n z.array(z.string().min(1)).optional(),\n ]),\n ) as Record<CspDirectiveName, z.ZodOptional<z.ZodArray<z.ZodString>>>,\n);\nexport type CspDirectivesOverride = z.infer<typeof CspDirectivesOverrideSchema>;\n\n/**\n * @wildo_source:part:start saas.config.content-security-policy facet:layer:shared facet:audience:app-developer\n *\n * Declaring a Content-Security-Policy for one of the application's frontends.\n *\n * ⚠️ **Every browser surface ships a policy; what differs is what happens when you author none.** On\n * the application (`services.<key>.csp`) an omitted block resolves at sync to `enabled: true,\n * reportOnly: true` — a policy that reports violations and blocks nothing. A website or technical-doc\n * config with no block is refused at sync, naming the file. A policy that resolves DISABLED is refused\n * on every surface, so `enabled: false` cannot switch the header off.\n *\n * ## The generated file is the only one read\n *\n * Author the static posture here, add per-environment entries under `csp.<serviceKey>` in that\n * environment's infrastructure configuration, then run `wildo dev sync-csp --env <env>` (starting\n * development runs it for you). Each surface reads ONLY the generated artifact — hand-editing a\n * surface's own policy file changes nothing and is overwritten on the next sync.\n *\n * ## `reportOnly` is a posture, not a formality\n *\n * `reportOnly: true` emits the report-only header: the browser reports violations and BLOCKS\n * NOTHING. Flipping it is one field. Note also that a `report-uri` is supported by the schema and the\n * emitter and no baseline ships a collector, so with nothing authored there the reports a browser\n * generates have nowhere to go — report-only plus no collector is a policy that neither blocks nor\n * tells you anything.\n *\n * Nonces and hashes are not generated per request or at build time. A source list may name one by\n * hand, but there is no generation, which is why a baseline that must admit inline script still does.\n *\n * Per-frontend CSP block. Authored on each service-definition's `csp?`\n * field. All three surfaces carry it: `wildo.tech-doc.config.ts.csp?`,\n * `wildo.website.config.ts.csp?`, and `services.<key>.csp` on the\n * `SAAS_APP` service definition.\n *\n * An AUTHORED block that omits `enabled` parses as `enabled: false`, which the resolver turns into no\n * policy and the sync then refuses — so author `enabled: true` explicitly whenever you write a block.\n *\n * `z.strictObject` (Zod 4) is intentional — typos like `enable: true`\n * (no `d`) or `directive: { … }` (no plural) MUST surface as parse\n * errors, not silently strip to `enabled: false` (i.e. CSP off, the\n * worst possible default). Same framework-mindset enforcement as\n * `WildoAuthConfigSchema`.\n */\nexport const WildoCspConfigSchema = z.strictObject({\n /**\n * `true` => baseline (+ overrides) emitted on both channels per `reportOnly`.\n * `false` — also the parse default for an authored block — makes the resolver return `null`, and\n * `wildo dev sync-csp` refuses that for every CSP-capable surface. It is not a way to turn the\n * header off.\n */\n enabled: z.boolean().default(false),\n /**\n * `true` => header name flips to `Content-Security-Policy-Report-Only`\n * AND the `<meta http-equiv>` channel goes silent (browsers reject the\n * report-only header via meta — W3C CSP3 §4.2.1). Use during the\n * pilot to triage console-surfaced violations without breaking real\n * traffic. Flip to `false` once the directive overrides settle.\n *\n * Default: `false` (enforcing). Authors opting into CSP for the first\n * time SHOULD set `reportOnly: true` for the first PR; the schema\n * default is intentionally enforcing so the steady state (post-pilot)\n * doesn't require a per-app authored `reportOnly: false`.\n */\n reportOnly: z.boolean().default(false),\n /**\n * Merge strategy for authored `directives` over the baseline. Default:\n * `'extend-baseline'` (per-directive additive merge — see\n * `CspMergeStrategy`).\n */\n mergeStrategy: z\n .enum(CspMergeStrategy)\n .default(CspMergeStrategy.EXTEND_BASELINE),\n /**\n * Per-directive overrides, keyed by directive name. Default: empty\n * map (baseline emitted verbatim).\n */\n directives: CspDirectivesOverrideSchema.default({}),\n /**\n * Optional `report-uri` directive value (header-only — meta tag\n * ignores it; the resolver feeds it to the nginx channel only).\n * No `report-to` field today — `report-to` requires the parallel\n * Reporting API endpoint config which the platform doesn't ship; add\n * when the violation-collector lands (`auth-hardening.md` \"Cheap\n * Bonuses — CSP violation monitoring endpoint\").\n */\n reportUri: z.string().min(1).optional(),\n});\n/** @wildo_source:part:end saas.config.content-security-policy */\nexport type WildoCspConfig = z.infer<typeof WildoCspConfigSchema>;\nexport type WildoCspConfigInput = z.input<typeof WildoCspConfigSchema>;\n\n/**\n * Env-specific overrides — authored under\n * `wildo.infra.<env>.config.ts.csp?[serviceKey]`. The loader merges\n * these on top of the app-static layer (which itself is on top of the\n * baseline).\n *\n * `WildoInfraEnvConfigSchema` declares `csp` as a record of these,\n * keyed by service key, and the resolver in `csp-emit.ts` consumes it.\n *\n * `extraDirectives` is ADDITIVE only — env-layer entries are APPENDED\n * to whatever the app-static layer produced for that directive. There\n * is no `'replace-baseline'`-equivalent at the env layer because env\n * config exists to LOOSEN policies for specific deployments (Sentry\n * origin in staging, dev hot-reload `'unsafe-eval'`), not to replace\n * an app's chosen posture. If an env genuinely needs a different\n * posture the right answer is to fix the app-static layer.\n */\nexport const EnvCspOverrideSchema = z.strictObject({\n /**\n * Per-directive ADDITIVE merge. Each entry's source list is\n * APPENDED to the app-static layer's source list for that directive\n * (de-duplicated, app order preserved, env sources appended in\n * author order). No replace semantics at this layer.\n */\n extraDirectives: CspDirectivesOverrideSchema.default({}),\n /**\n * Vite dev-mode CSP loosening: adds BOTH `'unsafe-inline'` and\n * `'unsafe-eval'` to `script-src`. Vite's dev server injects an\n * inline `<script>` for the HMR client bootstrap AND uses `eval()`\n * for lazy module / sourcemap transforms — both block under a strict\n * `script-src 'self'` policy and produce ~120+ CSP violations per\n * page load. Production Vite builds emit `<script type=\"module\">`\n * only and use no `eval()`, so this loosening is dev-only by design.\n *\n * AUTO-DEFAULT: `true` when the resolved env id is `'local'` AND the\n * frontend type is `SAAS_APP` (the only Vite-bundled frontend kind in\n * the framework). The framework applies the loosening automatically so\n * every Wildo app gets a clean dev console without per-app\n * configuration; opting in app-by-app would scatter the same\n * framework-shipped Vite knowledge across N infrastructure files.\n *\n * EXPLICIT OPT-OUT: set to `false` to keep tight `script-src` in\n * local dev. Useful only when actively debugging a real CSP issue\n * and willing to accept Vite-induced noise. Production envs ignore\n * this flag's auto-default and require explicit opt-in (extremely\n * unusual — a production app that needs `'unsafe-inline'` /\n * `'unsafe-eval'` is almost always a sign of a misconfigured asset\n * pipeline).\n */\n viteDevLoosening: z.boolean().optional(),\n /**\n * Env-layer override of the app-static `reportOnly` flag. When\n * present (not `undefined`), takes precedence over the app-static\n * value. Common shape: app-static ships `reportOnly: false`\n * (enforcing in prod), env-layer flips to `reportOnly: true` for\n * staging while the violation collector ramps up.\n */\n reportOnly: z.boolean().optional(),\n /**\n * Env-layer override of the app-static `reportUri` (e.g., per-env\n * collector endpoint).\n */\n reportUri: z.string().min(1).optional(),\n});\nexport type EnvCspOverride = z.infer<typeof EnvCspOverrideSchema>;\nexport type EnvCspOverrideInput = z.input<typeof EnvCspOverrideSchema>;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-services.schemas.d.ts","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"data-services.schemas.d.ts","sourceRoot":"","sources":["../../../../src/project-config/shared/data-services.schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,eAAO,MAAM,qBAAqB;;;;IAEhC;;;;;;;OAOG;;;;;;;;;;kBAQH,CAAC;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEpE;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,YAAY,EAAE,eAAe,GAAG,SAAS,GACxC,MAAM,GAAG,SAAS,CAsBpB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-services.schemas.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"data-services.schemas.js","sourceRoot":"","sources":["../../../../src/project-config/shared/data-services.schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,8BAA8B,GAAG,CAAC,CAAC,YAAY,CAAC;IACpD,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;CAClC,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,YAAY,CAAC;IAClD,OAAO,EAAE,8BAA8B,CAAC,QAAQ,EAAE;IAClD;;;;;;;OAOG;IACH,KAAK,EAAE,CAAC,CAAC,YAAY,CAAC;QACpB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;KAC7B,CAAC,CAAC,QAAQ,EAAE;IACb,EAAE,EAAE,CAAC,CAAC,YAAY,CAAC;QACjB,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;KAChC,CAAC,CAAC,QAAQ,EAAE;IACb,UAAU,EAAE,8BAA8B,CAAC,QAAQ,EAAE;CACtD,CAAC,CAAC;AAGH;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CACnC,YAAyC;IAEzC,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,kBAAkB,GAAG;QACzB,YAAY,CAAC,OAAO,EAAE,cAAc;QACpC,YAAY,CAAC,UAAU,EAAE,cAAc;KACxC,CAAC,MAAM,CAAC,CAAC,KAAK,EAAmB,EAAE,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC;IAE1D,MAAM,cAAc,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,kBAAkB,CAAC,CAAC,CAAC;IACxD,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAChC,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC9B,MAAM,IAAI,KAAK,CACb,0FAA0F,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CACtH,CAAC;IACJ,CAAC;IAED,OAAO,cAAc,CAAC,CAAC,CAAC,CAAC;AAC3B,CAAC","sourcesContent":["import { z } from 'zod';\n\nconst AppDatabaseBackedServiceSchema = z.strictObject({\n databasePrefix: z.string().min(1),\n});\n\n/**\n * App-level data service configuration.\n *\n * Declares how the app uses each backing service. Each block is OPTIONAL and\n * carries a single semantic responsibility:\n *\n * - `mongodb.databasePrefix` / `postgresql.databasePrefix` — feed\n * `deriveAppDatabaseName(...)` to compute the canonical app database name\n * surfaced as `MONGODB_DATABASE` in the per-app `.env`.\n * - `redis.keyPrefix` — emitted as `REDIS_KEY_PREFIX` in the app `.env` and\n * consumed by `RedisService` as the canonical app-level key namespace\n * (replaces the legacy username-derived `appPrefix`). All keys written by\n * the app become `${keyPrefix}org:${orgId}:${key}` or `${keyPrefix}global:${key}`.\n * - `s3.bucketPrefix` — emitted as `STORAGE_BUCKET_PREFIX` in the app `.env`\n * and consumed by `WildoManagedStorageProvider`, prepended to every\n * application object key (extra layer above the existing `applicationId`\n * namespace). The actual MinIO bucket name remains infra-controlled via\n * `STORAGE_BUCKET`.\n *\n * Slice 3.6 audit decisions (2026-04-13):\n * - DELETED the (formerly authored) `rabbitmq.vhost` field. Vhost is an\n * infra/topology concern already authored on the infra side via\n * `wildo.infra.<env>.config.ts > backingServices.rabbitmq.vhost` (Slice\n * 3.2). Authoring it on both seams would silently desync (last writer\n * wins) and would conflict with the framework-mindset rule of one source\n * of truth per concept. A strict-rejection test pins this deletion so any\n * re-introduction surfaces as a parse error rather than a silent strip.\n * - REPLACE semantics for `redis.keyPrefix`: the new env-driven prefix\n * becomes the canonical app namespace; the legacy\n * `secrets.database.redis.username`-derived prefix is retired.\n * - PREPEND semantics for `s3.bucketPrefix`: object keys become\n * `${bucketPrefix}/${applicationId}/...` rather than modifying the bucket\n * name itself (which would be an infra concern, not an app concern).\n *\n * Used in `wildo.saas.config.ts`.\n */\nexport const AppDataServicesSchema = z.strictObject({\n mongodb: AppDatabaseBackedServiceSchema.optional(),\n /**\n * Slice 3 deep-review M-7 (2026-04-13): per-service inner blocks are\n * `z.strictObject` so a typoed authoring (e.g. `redis: { keyPrefxi: ... }`,\n * `s3: { bucektPrefix: ... }`) is rejected at parse time rather than\n * silently stripped — which would otherwise produce an app `.env` with no\n * `REDIS_KEY_PREFIX` / `STORAGE_BUCKET_PREFIX` and downstream consumers\n * falling back to defaults without warning.\n */\n redis: z.strictObject({\n keyPrefix: z.string().min(1),\n }).optional(),\n s3: z.strictObject({\n bucketPrefix: z.string().min(1),\n }).optional(),\n postgresql: AppDatabaseBackedServiceSchema.optional(),\n});\nexport type AppDataServices = z.infer<typeof AppDataServicesSchema>;\n\n/**\n * Resolve the canonical application database name across supported database engines.\n *\n * Framework semantics treat the application database name as a cross-engine concept,\n * not a MongoDB-only field. When multiple database engines are configured, they must\n * agree on the same prefix or the runtime target would become ambiguous.\n */\nexport function deriveAppDatabaseName(\n dataServices: AppDataServices | undefined,\n): string | undefined {\n if (!dataServices) {\n return undefined;\n }\n\n const configuredPrefixes = [\n dataServices.mongodb?.databasePrefix,\n dataServices.postgresql?.databasePrefix,\n ].filter((value): value is string => value !== undefined);\n\n const uniquePrefixes = [...new Set(configuredPrefixes)];\n if (uniquePrefixes.length === 0) {\n return undefined;\n }\n\n if (uniquePrefixes.length > 1) {\n throw new Error(\n `Application database prefixes must match across configured database engines. Received: ${uniquePrefixes.join(', ')}`,\n );\n }\n\n return uniquePrefixes[0];\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env-example-defaults.d.ts","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"env-example-defaults.d.ts","sourceRoot":"","sources":["../../../../src/project-config/shared/env-example-defaults.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,MAAM,WAAW,2BAA2B;IAC1C,cAAc,EAAE,MAAM,CAAC;IACvB,mCAAmC,EAAE,MAAM,CAAC;IAC5C,yBAAyB,EAAE,MAAM,CAAC;IAClC,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,qCAAqC,EAAE,MAAM,CAAC;IAC9C,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;IACzB,gBAAgB,EAAE,MAAM,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED;;;;GAIG;AACH,wBAAgB,iCAAiC,CAC/C,SAAS,CAAC,EAAE,OAAO,CAAC,2BAA2B,CAAC,GAC/C,2BAA2B,CAiB7B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env-example-defaults.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"env-example-defaults.js","sourceRoot":"","sources":["../../../../src/project-config/shared/env-example-defaults.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAkBhG;;;;GAIG;AACH,MAAM,UAAU,iCAAiC,CAC/C,SAAgD;IAEhD,OAAO;QACL,cAAc,EAAE,2BAA2B;QAC3C,mCAAmC,EAAE,+DAA+D;QACpG,yBAAyB,EAAE,oBAAoB,sBAAsB,CAAC,YAAY,EAAE;QACpF,eAAe,EAAE,aAAa;QAC9B,YAAY,EAAE,mBAAmB;QACjC,qCAAqC,EAAE,oBAAoB,sBAAsB,CAAC,wBAAwB,EAAE;QAC5G,YAAY,EAAE,aAAa,mBAAmB,CAAC,OAAO,EAAE;QACxD,gBAAgB,EAAE,WAAW;QAC7B,gBAAgB,EAAE,SAAS;QAC3B,UAAU,EAAE,WAAW;QACvB,UAAU,EAAE,mBAAmB,CAAC,MAAM;QACtC,aAAa,EAAE,WAAW;QAC1B,aAAa,EAAE,mBAAmB,CAAC,QAAQ;QAC3C,GAAG,SAAS;KACb,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Default context values for the app-backend-env.example.hbs template.\n * Provides fake/placeholder data derived from infrastructure defaults.\n */\n\nimport { INFRA_DEFAULT_PORTS, PLATFORM_DEFAULT_PORTS } from './infrastructure-defaults.schemas';\n\nexport interface AppBackendEnvExampleContext {\n APPLICATION_ID: string;\n PLATFORM_APPLICATION_PRIMARY_SECRET: string;\n PLATFORM_APPS_MANAGER_URL: string;\n APPLICATION_ENV: string;\n SERVICE_NAME: string;\n PLATFORM_CRONTABS_BATCHES_MANAGER_URL: string;\n MONGODB_HOST: string;\n MONGODB_DATABASE: string;\n MONGODB_PROTOCOL: string;\n REDIS_HOST: string;\n REDIS_PORT: number;\n RABBITMQ_HOST: string;\n RABBITMQ_PORT: number;\n}\n\n/**\n * Build the default template context for the app backend .env example.\n * All values are placeholder/local defaults — real values come from\n * secrets.json + config.json via `wildo config sync`.\n */\nexport function buildAppBackendEnvExampleDefaults(\n overrides?: Partial<AppBackendEnvExampleContext>,\n): AppBackendEnvExampleContext {\n return {\n APPLICATION_ID: 'your-app-id-from-platform',\n PLATFORM_APPLICATION_PRIMARY_SECRET: 'your-super-secure-platform-secret-at-least-32-characters-long',\n PLATFORM_APPS_MANAGER_URL: `http://localhost:${PLATFORM_DEFAULT_PORTS.APPS_MANAGER}`,\n APPLICATION_ENV: 'development',\n SERVICE_NAME: 'your-service-name',\n PLATFORM_CRONTABS_BATCHES_MANAGER_URL: `http://localhost:${PLATFORM_DEFAULT_PORTS.CRONTABS_BATCHES_MANAGER}`,\n MONGODB_HOST: `localhost:${INFRA_DEFAULT_PORTS.MONGODB}`,\n MONGODB_DATABASE: 'wildo_app',\n MONGODB_PROTOCOL: 'mongodb',\n REDIS_HOST: 'localhost',\n REDIS_PORT: INFRA_DEFAULT_PORTS.VALKEY,\n RABBITMQ_HOST: 'localhost',\n RABBITMQ_PORT: INFRA_DEFAULT_PORTS.RABBITMQ,\n ...overrides,\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"environment.schemas.d.ts","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"environment.schemas.d.ts","sourceRoot":"","sources":["../../../../src/project-config/shared/environment.schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAGzD;;;;;;;;GAQG;AACH,oBAAY,gBAAgB;IAC1B,KAAK,UAAU;IACf,OAAO,YAAY;IACnB,UAAU,eAAe;CAC1B;AAED,eAAO,MAAM,wBAAwB,aAMlC,CAAC;AACJ,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAE1E;;;;;GAKG;AACH,oBAAY,sBAAsB;IAChC,cAAc,mBAAmB;IACjC,UAAU,eAAe;CAC1B;AAED,oBAAY,iBAAiB;IAC3B,KAAK,UAAU;IACf,MAAM,WAAW;CAClB;AAED,wBAAgB,oBAAoB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAEnE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,oBAAY,qBAAqB;IAC/B,aAAa,kBAAkB;IAC/B,SAAS,cAAc;CACxB;AAED;;;;;;GAMG;AACH,wBAAgB,8BAA8B,CAAC,YAAY,EAAE,iBAAiB,GAAG,qBAAqB,CAO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