@wildo-ai/platform-config-lib 1.1.6 → 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.map +1 -1
- package/dist/esm/bootstrap/bootstrap.contracts.js.map +1 -1
- package/dist/esm/bootstrap/bootstrap.schemas.d.ts.map +1 -1
- package/dist/esm/bootstrap/bootstrap.schemas.js.map +1 -1
- package/dist/esm/bootstrap/platform-runtime-env.contracts.d.ts.map +1 -1
- package/dist/esm/bootstrap/platform-runtime-env.contracts.js.map +1 -1
- package/dist/esm/bootstrap/platform-store-preconnect.d.ts.map +1 -1
- package/dist/esm/bootstrap/platform-store-preconnect.js.map +1 -1
- package/dist/esm/bootstrap/runtime-backing-service-access.d.ts.map +1 -1
- 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.map +1 -1
- 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.map +1 -1
- 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.map +1 -1
- package/dist/esm/lockfile/lockfile-io.js.map +1 -1
- package/dist/esm/lockfile/materialize-infra-section.d.ts.map +1 -1
- package/dist/esm/lockfile/materialize-infra-section.js.map +1 -1
- package/dist/esm/lockfile/wildo-saas-lock.shared.schemas.d.ts.map +1 -1
- 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.map +1 -1
- package/dist/esm/project-config/application-public-pricing-catalog.loader.js.map +1 -1
- 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.map +1 -1
- 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.map +1 -1
- 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.map +1 -1
- package/dist/esm/project-config/index.js.map +1 -1
- package/dist/esm/project-config/loader.d.ts.map +1 -1
- 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.map +1 -1
- package/dist/esm/project-config/npm-version-range.js.map +1 -1
- 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.map +1 -1
- package/dist/esm/project-config/provider-companion-discovery.js.map +1 -1
- package/dist/esm/project-config/provider-runtime-artifacts.d.ts.map +1 -1
- 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.map +1 -1
- package/dist/esm/project-config/shared/backing-service-servability.js.map +1 -1
- package/dist/esm/project-config/shared/backing-services.schemas.d.ts.map +1 -1
- 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.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.map +1 -1
- package/dist/esm/project-config/shared/infra-providers.schemas.js.map +1 -1
- package/dist/esm/project-config/shared/infra-service.schemas.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.map +1 -1
- package/dist/esm/project-config/static-asset-import-noop.js.map +1 -1
- 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.map +1 -1
- package/dist/esm/registry/index.js.map +1 -1
- package/dist/esm/registry/local-checkout-source.d.ts.map +1 -1
- package/dist/esm/registry/local-checkout-source.js.map +1 -1
- package/dist/esm/registry/lockfile-modules-section.schemas.d.ts.map +1 -1
- package/dist/esm/registry/lockfile-modules-section.schemas.js.map +1 -1
- package/dist/esm/registry/module-artifact.schemas.d.ts.map +1 -1
- package/dist/esm/registry/module-artifact.schemas.js.map +1 -1
- package/dist/esm/registry/module-manifest.schemas.d.ts.map +1 -1
- package/dist/esm/registry/module-manifest.schemas.js.map +1 -1
- package/dist/esm/registry/module-search.schemas.d.ts.map +1 -1
- package/dist/esm/registry/module-search.schemas.js.map +1 -1
- package/dist/esm/registry/registry-config.schemas.d.ts.map +1 -1
- package/dist/esm/registry/registry-config.schemas.js.map +1 -1
- package/dist/esm/registry/registry-defaults.constants.d.ts.map +1 -1
- package/dist/esm/registry/registry-defaults.constants.js.map +1 -1
- package/dist/esm/registry/registry-errors.d.ts.map +1 -1
- package/dist/esm/registry/registry-errors.js.map +1 -1
- package/dist/esm/registry/registry-keys.schemas.d.ts.map +1 -1
- package/dist/esm/registry/registry-keys.schemas.js.map +1 -1
- 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.map +1 -1
- package/dist/esm/workspace-scope/workspace-homes.schemas.js.map +1 -1
- package/dist/esm/workspace-scope/workspace-scope-detector.d.ts.map +1 -1
- package/dist/esm/workspace-scope/workspace-scope-detector.js.map +1 -1
- package/dist/esm/workspace-scope/workspace-scope.schemas.d.ts.map +1 -1
- package/dist/esm/workspace-scope/workspace-scope.schemas.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/package.json +7 -7
- package/dist/esm/registry/companion-api.schemas.d.ts +0 -0
- package/dist/esm/registry/companion-api.schemas.d.ts.map +0 -0
- package/dist/esm/registry/companion-api.schemas.js.map +0 -0
|
@@ -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,GAAG;IACrC,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;IAClD,CAAC,+BAA+B,CAAC,MAAM,CAAC,EAAE,YAAY;IACtD,CAAC,+BAA+B,CAAC,KAAK,CAAC,EAAE,WAAW;CACkC,CAAC;AAKzF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,gCAAgC,GAAgF;IAC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,MAAM,GAAG,CAAC,CAAC,CAAC;YACjF,MAAM,WAAW,GACf,gBAAgB,CAAC,MAAM,KAAK,iBAAiB,CAAC,MAAM;gBACpD,gBAAgB,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE,CAAC,IAAI,KAAK,iBAAiB,CAAC,SAAS,CAAC,CAAC,CAAC;YAErF,IAAI,CAAC,WAAW,EAAE,CAAC;gBACjB,KAAK,CAAC,MAAM,CAAC,cAAc,GAAG,CAAC,EAAE,KAAK,GAAG,cAAc,GAAG,CAAC,EAAE,GAAG,aAAa,CAAC,CAAC;gBAC/E,KAAK,GAAG,cAAc,GAAG,aAAa,CAAC,MAAM,GAAG,CAAC,CAAC;gBAClD,YAAY,IAAI,CAAC,CAAC;YACpB,CAAC;YAED,cAAc,GAAG,IAAI,CAAC;YACtB,UAAU,GAAG,EAAE,CAAC;QAClB,CAAC;IACH,CAAC;IAED,IAAI,cAAc,KAAK,IAAI,EAAE,CAAC;QAC5B,MAAM,IAAI,KAAK,CACb,cAAc,QAAQ,qBAAqB,sBAAsB,sBAAsB,cAAc,GAAG,CAAC,EAAE,CAC5G,CAAC;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
|
+
{"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,GAAG;IACrC,CAAC,+BAA+B,CAAC,MAAM,CAAC,EAAE,YAAY;IACtD,CAAC,+BAA+B,CAAC,OAAO,CAAC,EAAE,aAAa;IACxD,CAAC,+BAA+B,CAAC,KAAK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\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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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"}
|
|
@@ -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,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 +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","sourceRo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AO,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,CAOrG;AAED;;;;;GAKG;AACH,oBAAY,2BAA2B;IACrC,OAAO,YAAY;CACpB;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,2BAA2B;;;;;;iBAetC,CAAC;AACH,MAAM,MAAM,qBAAqB,GAAG,C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H,iCAAiC,EAAE,sCAAsC,GAAG,SAAS,GACpF,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC,CAoBrD;AAED,oBAAY,cAAc;IACxB,OAAO,YAAY;IACnB,UAAU,eAAe;CAC1B;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,mCAAmC,EAAE,cAA0C,CAAC;AAE7F;;;;;;GAMG;AACH,wBAAgB,gCAAgC,CAAC,mBAAmB,EAAE;IAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,cAAc,CAAA;CAAE,GAAG,SAAS,GAAG,cAAc,CAEtI;AAED,oBAAY,qBAAqB;IAC/B,UAAU,eAAe;IACzB,WAAW,gBAAgB;IAC3B,MAAM,WAAW;CAClB;AAED;;GAEG;AACH,eAAO,MAAM,6BAA6B;;;;kBAIxC,CAAC;AAEH;;;;;;;GAOG;AACH,eAAO,MAAM,0BAA0B;;;;;kBAKrC,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,2BAA2B;;;;;;;;;+BAGtC,CAAC;AACH,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAChF,oEAAoE;AAEpE;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,MAAM,EACf,aAAa,EAAE,MAAM,GACpB,MAAM,CAYR;AAED,wBAAgB,gCAAgC,CAC9C,OAAO,EAAE,MAAM,EACf,aAAa,EAAE,MAAM,GACpB,MAAM,CAER;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,kCAAkC;;;;iBAgB7C,CAAC;AAEH,MAAM,MAAM,4BAA4B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kCAAkC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"environment.schemas.js","sourceRoot":"","sources":["../../../../../src/project-config/shared/environment.schemas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,CAAC;IACD,IAAI,CAAC,uBAAuB,EAAE,CAAC;QAC7B,MAAM,IAAI,KAAK,CAAC,8DAA8D,CAAC,CAAC;IAClF,CAAC;IAED,OAAO,GAAG,iBAAiB,IAAI,uBAAuB,EAAE,CAAC;AAC3D,CAAC;AAED,MAAM,UAAU,gCAAgC,CAC9C,OAAe,EACf,aAAqB;IAErB,OAAO,GAAG,yBAAyB,CAAC,OAAO,EAAE,aAAa,CAAC,OAAO,CAAC;AACrE,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,CAAC,MAAM,kCAAkC,GAAG,CAAC,CAAC,MAAM,CAAC;IACzD;;;OAGG;IACH,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IAC/C;;;OAGG;IACH,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IAC3C;;;OAGG;IACH,mBAAmB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;CACzD,CAAC,CAAC","sourcesContent":["import { z } from 'zod';\nimport { EngineCapability } from '@wildo-ai/saas-models';\nimport { InfraServiceK8sSchema } from './infra-service.schemas';\n\n/**\n * @wildo_source:part:start platform.config.environment.deployment facet:layer:platform facet:family:infra\n *\n * Convenience environment ids kept for common local/staging/production setups.\n *\n * The project model is no longer limited to a fixed environment set: remote\n * environment ids can be any slug-like value. Use `WildoEnvironmentIdSchema`\n * for authoritative validation.\n */\nexport enum WildoEnvironment {\n LOCAL = 'local',\n STAGING = 'staging',\n PRODUCTION = 'production',\n}\n\nexport const WildoEnvironmentIdSchema = z\n .string()\n .min(1)\n .regex(\n /^[a-z0-9]+(?:-[a-z0-9]+)*$/,\n 'environment ids must be lowercase alphanumeric with optional hyphen-separated segments',\n );\nexport type WildoEnvironmentId = z.infer<typeof WildoEnvironmentIdSchema>;\n\n/**\n * Deployment runtime targets for CI/CD workflows and infra config.\n *\n * Single source of truth for deployment runtime targets, used by both\n * platform-config-lib (developer-facing config) and wildo-cli (operational).\n */\nexport enum WildoDeploymentRuntime {\n DOCKER_COMPOSE = 'docker-compose',\n KUBERNETES = 'kubernetes',\n}\n\nexport enum WildoLocationType {\n LOCAL = 'local',\n REMOTE = 'remote',\n}\n\nexport function isLocalEnvironmentId(environmentId: string): boolean {\n return environmentId === WildoEnvironment.LOCAL;\n}\n\n/**\n * Where a docker-compose backing service keeps its DATA.\n *\n * The two members are not a performance knob with a fast and a slow setting — they answer a\n * question about ownership, and the cost follows from the answer:\n *\n * - `HOST_PATH` — the data lives at an explicit path on the host\n * (`<saas-root>/.wildo-saas/local_data/<service>/`), bind-mounted into the container. The\n * operator chooses the disk, backups target a known directory, and the tree is the same one the\n * Kind k8s lane hostPath-mounts at `/mnt/local-data/<service>/`. That control is why it is the\n * REMOTE default: a production operator who has provisioned a dedicated data volume must be able\n * to put the database on it, and a named volume would silently land it under\n * `/var/lib/docker/volumes/` on the root disk.\n * - `DOCKER_VOLUME` — the data lives in a Docker named volume, inside the container runtime's own\n * storage. Nobody outside Docker addresses it, which is exactly what makes it right for a\n * disposable development stack.\n *\n * ## Why LOCAL defaults to `DOCKER_VOLUME`\n *\n * On Linux a bind mount is a native path and costs nothing. On macOS and Windows the container\n * runtime is a VM, and a host bind mount crosses a filesystem bridge — VirtioFS on macOS, 9p/\n * VirtioFS through WSL2 on Windows. Databases do small fsync'd random writes, so every one of them\n * becomes a round trip out of the VM.\n *\n * Measured on macOS (Apple Virtualization, 6 vCPU) on 2026-09-22 with the eight self-hosted backing\n * services bind-mounted: the VM process held **13,786 host file descriptors** open across 14,168\n * files and burned **383% CPU** in Docker Desktop's file-sharing process — sustained, a 321%\n * average over 2 days 5 hours — while the containers themselves used 0.7 of a core and container\n * block-IO accounting stayed flat, because none of that traffic reaches the VM's own block device.\n * Roughly four cores of pure filesystem translation for 0.7 of a core of database work.\n *\n * The default is uniform across all three development operating systems rather than \"volumes on\n * macOS and Windows, host paths on Linux\", so every developer and CI run exercise the same stack\n * and a bug reproduces the same way everywhere. It costs a Linux developer nothing: a named volume\n * is a native directory there too.\n *\n * Both members are authorable per environment (`localDataStorage`), so a remote operator who wants\n * volumes and a local developer who wants to read the files from their file manager each say so.\n *\n * NOTE this governs DATA directories only. The two small secret FILES compose mounts read-only —\n * immudb's state-signing key and mongot's sync-source password — are materialized from\n * `secrets.json` onto the host and stay host mounts under every mode. They are read once at\n * startup, so they carry none of the cost above, and they have nowhere else to come from.\n */\nexport enum WildoLocalDataStorage {\n DOCKER_VOLUME = 'docker-volume',\n HOST_PATH = 'host-path',\n}\n\n/**\n * The `localDataStorage` an environment gets when it authors none.\n *\n * Total over {@link WildoLocationType} rather than a conditional on one member, so a location type\n * added to the vocabulary tomorrow is a compile error here instead of silently inheriting whichever\n * branch happened to be the `else`.\n */\nexport function resolveDefaultLocalDataStorage(locationType: WildoLocationType): WildoLocalDataStorage {\n switch (locationType) {\n case WildoLocationType.LOCAL:\n return WildoLocalDataStorage.DOCKER_VOLUME;\n case WildoLocationType.REMOTE:\n return WildoLocalDataStorage.HOST_PATH;\n }\n}\n\n/**\n * Ingress controller installed by Wildo's local and remote Kubernetes workflows.\n * Import from `@wildo-ai/platform-config-lib`. Traefik owns both application\n * routing and HTTP-01 challenge routing; selecting another controller is not\n * supported by the generated installation contract.\n */\nexport enum WildoKubernetesIngressClass {\n TRAEFIK = 'traefik',\n}\n\n/**\n * K8s-internal cluster topology. Holds ONLY values that are genuinely\n * specific to a Kubernetes deployment: namespace, ingress class and\n * per-service workload replica counts.\n *\n * The external/public hostname (where browsers and reverse proxies hit\n * us) is NOT here — it lives at the top level of `WildoInfraEnvConfig`\n * as `publicDomain` because it applies to BOTH `KUBERNETES` and\n * `DOCKER_COMPOSE` runtimes. See `external-public-domain-rename.md`\n * for the rationale (the previous `baseDomain` field on this object\n * conflated K8s-internal and reverse-proxy concerns).\n */\nexport const WildoKubernetesConfigSchema = z.object({\n namespace: z.string().min(1),\n /**\n * Workload replica overrides keyed by authored SaaS service key (for example\n * backendApi, app or website), never by generated image/deployment name.\n * Platform service keys have their own renderer. Worker replicas remain in\n * the worker declaration; a key without a generated application target is\n * reported by application deployment generation rather than guessed.\n */\n services: z.record(z.string(), InfraServiceK8sSchema).optional(),\n // Derive the literal from the named runtime vocabulary while accepting the\n // natural authored spelling `ingressClass: 'traefik'` without an enum import.\n ingressClass: z.literal(`${WildoKubernetesIngressClass.TRAEFIK}`, {\n error: 'Wildo Kubernetes deployments support ingressClass traefik only; omit the field or select traefik.',\n }).optional(),\n});\nexport type WildoKubernetesConfig = z.infer<typeof WildoKubernetesConfigSchema>;\n\n/**\n * cert-manager `ClusterIssuer` selection for remote TLS. Both issuers are\n * always provisioned in the cluster (see `cluster-issuer.yaml.hbs`); this\n * picks which one an application's ingress annotation\n * (`cert-manager.io/cluster-issuer`) points at — i.e. which ACME endpoint\n * issues its per-ingress certificate.\n *\n * - `LETSENCRYPT_PROD` — real, browser-trusted certificates. The default,\n * because a remote deployment implies a real domain that browsers must\n * trust. Subject to Let's Encrypt production rate limits\n * (50 certs / registered domain / week).\n * - `LETSENCRYPT_STAGING` — untrusted test certificates with far higher\n * rate limits. Opt into this **while validating DNS + ingress on a new\n * cluster** so a misconfigured first deploy cannot exhaust the prod\n * quota, then flip to prod once issuance succeeds.\n */\nexport enum WildoTlsIssuer {\n LETSENCRYPT_PROD = 'letsencrypt-prod',\n LETSENCRYPT_STAGING = 'letsencrypt-staging',\n}\n\nexport const WildoRemoteProviderSchema = z.object({\n provider: z.string().min(1),\n registryEndpoint: z.string().min(1),\n region: z.string().min(1).optional(),\n /**\n * ACME registration email for Let's Encrypt (`ClusterIssuer.spec.acme.email`).\n * Optional at the schema level so non-TLS remote configs parse, but a\n * remote Kubernetes environment that terminates TLS should author it —\n * Let's Encrypt uses it for expiry warnings and account recovery.\n */\n acmeEmail: z.email().optional(),\n /**\n * Which cert-manager `ClusterIssuer` this environment's ingresses use.\n * Defaults to `LETSENCRYPT_PROD` downstream when unset. See {@link WildoTlsIssuer}.\n */\n tlsIssuer: z.enum(WildoTlsIssuer).optional(),\n});\nexport type WildoRemoteProvider = z.infer<typeof WildoRemoteProviderSchema>;\n\nexport const WildoLoggingConfigSchema = z.object({\n level: z.enum(['debug', 'info', 'warn', 'error']).default('info'),\n formattedConsoleErrors: z.boolean().optional(),\n});\nexport type WildoLoggingConfig = z.infer<typeof WildoLoggingConfigSchema>;\n\n/**\n * Per-environment OTLP telemetry (traces + metrics + logs) posture (Slice 2 Phase 5).\n *\n * `env-vars-builder` projects this block onto the standard `OTEL_*` env vars that the\n * `otel-preload.ts` SDK (in `saas-backend-lib`) reads BEFORE app code:\n * - `enabled` → `OTEL_ENABLED` (the master gate) + drives the `--import` preload wiring.\n * - `endpoint` → `OTEL_EXPORTER_OTLP_ENDPOINT` (the OTLP/HTTP collector/ingest URL).\n * The provider auth header (`OTEL_EXPORTER_OTLP_HEADERS`) is NOT authored here — it is\n * derived by `env-vars-builder` from the selected `OBSERVABILITY_TELEMETRY` provider's\n * secret (e.g. a BetterStack source token). Persisted into `PlatformEnvConfigJson.observability`\n * and hydrated back by `hydrateEnvironmentFromConfig`, mirroring `logging`.\n */\nexport const WildoObservabilityConfigSchema = z.object({\n /**\n * Master switch for OTLP telemetry. `true` → emit `OTEL_ENABLED=true` + wire the\n * `--import @wildo-ai/saas-backend-lib/otel-preload` preload; the preload starts the SDK.\n * `false`/omitted → a complete no-op (the preload self-gates).\n */\n enabled: z.boolean().default(false),\n /**\n * OTLP/HTTP endpoint (`OTEL_EXPORTER_OTLP_ENDPOINT`). Local dev: the local `otel-collector`\n * (`http://localhost:4318`). Remote: the selected provider's ingesting host (e.g. a BetterStack\n * source URL). When omitted, the OTLP exporters fall back to their own default\n * (`http://localhost:4318`), which is the local collector — convenient for local dev.\n */\n endpoint: z.string().optional(),\n /**\n * LLM-call observability env-layer posture — a SEPARATE signal from OTLP\n * telemetry (fed by the engine `AgentCallTraceSink` into the selected\n * `LLM_OBSERVABILITY` provider, e.g. PostHog `$ai_generation`), colocated\n * here because both are per-environment observability posture. Projected\n * onto the `WILDO_LLM_OBS_*` env vars INDEPENDENTLY of the OTLP `enabled`\n * gate — LLM-obs activation is provider-selection-driven, not\n * `OTEL_ENABLED`-driven.\n */\n llmObservability: z.object({\n /**\n * Forward prompt + completion content (`$ai_input` / `$ai_output_choices`)\n * to the LLM-observability provider (→ `WILDO_LLM_OBS_CAPTURE_CONTENT`).\n * Default FALSE: content is user/app data (PII) shipped to a third party —\n * opt in per environment (local dev typically true; production a\n * deliberate decision).\n */\n captureContent: z.boolean().default(false),\n /**\n * Fraction (0..1) of agent calls forwarded (→ `WILDO_LLM_OBS_SAMPLE_RATE`).\n * Omitted = capture every call.\n */\n sampleRate: z.number().min(0).max(1).optional(),\n /**\n * NON-SECRET env for the selected LLM-observability provider — connection\n * details the provider module reads from the runtime env (e.g. PostHog's\n * `POSTHOG_HOST` ingestion host and `POSTHOG_PROJECT_ID`). Projected\n * verbatim into the runtime env; the env-key names are provider-owned,\n * same vocabulary as `secrets.json → providerEnv`. Secrets (API keys)\n * do NOT belong here — they stay in `secrets.json → providerEnv`, which\n * also WINS on a key collision (secrets are the more specific layer).\n * This is the checked-in home for provider config that is not sensitive.\n */\n providerEnv: z.record(z.string(), z.string()).optional(),\n }).optional(),\n});\nexport type WildoObservabilityConfig = z.infer<typeof WildoObservabilityConfigSchema>;\n\n/**\n * Per-environment external-provider SELECTION override (2026-07-10).\n *\n * The app-wide primary/substitute selection for an `EngineCapability` lives in\n * `wildo.saas.config.ts` (`providers.scopes.backend.selection[capability]`) —\n * a single value shared by every environment. This block lets an environment\n * OVERRIDE that primary (and its substitutes) without touching the shared SaaS\n * config, so e.g. LOCAL can select the non-sending `email-preview` provider\n * for `EMAIL_TRANSACTIONAL` while staging/production keep `resend`.\n *\n * Semantics (mirrors the SaaS-side selection policy):\n * - `primary` — the ref that wins for this capability in this environment.\n * - `whenUnavailable` — ordered substitutes, used when a preceding ref is not AVAILABLE at\n * resolution time (undeclared, disabled, unconfigured). NOT failover: nothing retries a\n * second provider when a call to the first one fails.\n *\n * The referenced provider must still be DECLARED in\n * `providers.scopes.backend.providers` and available for the capability — the\n * backend's availability/enabled filtering is unchanged, so an override that\n * names an undeclared or capability-disabled provider resolves to nothing\n * (same fail-closed behaviour as an equivalent SaaS-side selection). FAN_OUT\n * capabilities ignore the override (every declared provider is active — a\n * primary/substitute is meaningless), matching the SaaS-side rule.\n *\n * `env-vars-builder` serializes this block to the `WILDO_PROVIDER_SELECTION_OVERRIDES`\n * backend env var (JSON); `ExternalProvidersRegistryBackendService` reads it and\n * applies it over the SaaS-config selection at capability-resolution time.\n * Persisted into `PlatformEnvConfigJson.providerSelection` and hydrated back by\n * `hydrateEnvironmentFromConfig`, mirroring `logging` / `observability`.\n */\nexport const WildoProviderSelectionOverrideEntrySchema = z.strictObject({\n primary: z.string().min(1),\n whenUnavailable: z.array(z.string().min(1)).optional(),\n});\nexport type WildoProviderSelectionOverrideEntry = z.infer<typeof WildoProviderSelectionOverrideEntrySchema>;\n\nexport const WildoProviderSelectionOverridesSchema = z.partialRecord(\n z.enum(EngineCapability),\n WildoProviderSelectionOverrideEntrySchema,\n);\nexport type WildoProviderSelectionOverrides = z.infer<typeof WildoProviderSelectionOverridesSchema>;\n\n/**\n * Per-environment provider CONFIGURATION values — the half of `providerConfigurations` that exists once per\n * DEPLOYMENT rather than once per application.\n *\n * `wildo.saas.config.ts > providerConfigurations` is authored once and reaches every environment. That is right for\n * application POLICY a provider reads (an agent execution profile, which environments it may run in). It is wrong\n * for an IDENTITY the vendor issued against one deployment: an OAuth client ID registered with the authorized\n * redirect URIs of one environment, a frontend SDK DSN or site key, a picker `appId`. Authored in the SaaS config, the\n * local development Google client — whose only redirect URI is `localhost` — would be the client staging and\n * production send users to.\n *\n * This block carries those values for ONE environment, in exactly the SaaS block's\n * `providerRef → protocolKind → key` shape, and {@link overlayEnvironmentProviderConfigurations} lays it over the\n * SaaS block KEY BY KEY. An environment therefore states only what differs and inherits the rest, so the policy half\n * is never restated per environment.\n *\n * It reaches both places a provider configuration is read, because the CLI applies the overlay where it knows the\n * environment: the managed declaration each environment's apps-manager stores (backend readers — the OAuth2\n * connection resolver, email/SMS senders, the provider registry) and the provider runtime artifacts a build bakes in\n * (frontend `publicConfig`, the backend's generated provider module).\n *\n * NOT for secrets. This file is committed; a client secret, API key or signing secret stays in\n * `secrets.json → providerEnv`. The CLI refuses a key named like one of the provider's declared secrets.\n */\nexport const WildoEnvironmentProviderConfigurationsSchema = z.record(\n z.string().min(1),\n z.record(z.string().min(1), z.record(z.string().min(1), z.unknown())),\n);\nexport type WildoEnvironmentProviderConfigurations = z.infer<typeof WildoEnvironmentProviderConfigurationsSchema>;\n\n/**\n * The provider configuration ONE environment runs with: the application-level `providerConfigurations`, with the\n * environment's {@link WildoEnvironmentProviderConfigurationsSchema} values laid over it key by key.\n *\n * Precedence is per key inside one `providerRef → protocolKind` bag, and the environment wins — the more specific\n * layer, as `secrets.json → providerEnv` wins over `observability.llmObservability.providerEnv`. A bag the\n * environment does not mention is carried unchanged; a bag only the environment declares is added. Neither input is\n * mutated.\n *\n * Rejected: replacing a whole provider or protocol bag. That would force an environment to restate every\n * environment-invariant key it shares with the application (an agent execution profile beside a client ID), and a\n * restated copy is one that drifts from the original.\n *\n * Throws when the application layer holds a non-object at a protocol key the environment overlays: there is no key\n * to lay a value over, and silently replacing it would discard the application's value without saying so.\n */\nexport function overlayEnvironmentProviderConfigurations(\n applicationProviderConfigurations: Readonly<Record<string, Readonly<Record<string, unknown>> | undefined>> | undefined,\n environmentProviderConfigurations: WildoEnvironmentProviderConfigurations | undefined,\n): Record<string, Record<string, unknown> | undefined> {\n const resolved: Record<string, Record<string, unknown> | undefined> = {};\n for (const [providerRef, protocols] of Object.entries(applicationProviderConfigurations ?? {})) {\n resolved[providerRef] = protocols === undefined ? undefined : { ...protocols };\n }\n for (const [providerRef, environmentProtocols] of Object.entries(environmentProviderConfigurations ?? {})) {\n const merged: Record<string, unknown> = { ...(resolved[providerRef] ?? {}) };\n for (const [protocolKind, environmentValues] of Object.entries(environmentProtocols)) {\n const applicationValues = merged[protocolKind];\n if (applicationValues !== undefined && (applicationValues === null || typeof applicationValues !== 'object' || Array.isArray(applicationValues))) {\n throw new Error(\n `providerConfigurations.${providerRef}.${protocolKind} is not an object in wildo.saas.config.ts, so the `\n + 'environment\\'s values for it cannot be laid over it key by key.',\n );\n }\n merged[protocolKind] = { ...(applicationValues as Record<string, unknown> | undefined), ...environmentValues };\n }\n resolved[providerRef] = merged;\n }\n return resolved;\n}\n\nexport enum DatabaseEngine {\n MONGODB = 'mongodb',\n POSTGRESQL = 'postgresql',\n}\n\n/**\n * The store an APPLICATION persists to when its environment authors no `applicationDatabase`.\n *\n * PostgreSQL — decided by Paul on 2026-09-24 (#1571), reversing 75cd1934f (\"absence means MongoDB\")\n * and restoring the rule of 2e0194c41. This is the ONLY place the answer is written. Every reader of\n * an application's engine goes through {@link resolveApplicationDatabaseEngine}, because the\n * 2026-09-15 incident was two readers answering silence differently: provisioning chose PostgreSQL,\n * the runtime chose MongoDB, Mongo provisioning was skipped, registration reported success, and the\n * application died at boot with `Command update requires authentication`.\n *\n * Distinct from the PLATFORM's own store (`database` in the infra config) and from the engine's\n * `DEFAULT_PERSISTENCE_ADAPTER` / `DATABASE_DEFAULT_ADAPTER` env default, which also governs\n * platform services and is not what this decides. The application never falls through to that env\n * default: the CLI writes the resolved adapter explicitly.\n */\nexport const DEFAULT_APPLICATION_DATABASE_ENGINE: DatabaseEngine = DatabaseEngine.POSTGRESQL;\n\n/**\n * The engine an application persists to: its authored `applicationDatabase.engine`, or\n * {@link DEFAULT_APPLICATION_DATABASE_ENGINE} when the environment authors none.\n *\n * Takes the declaration rather than a whole config so every carrier of it — the parsed infra config,\n * `config.json`, a bootstrap request — answers through the same function.\n */\nexport function resolveApplicationDatabaseEngine(applicationDatabase: { readonly engine?: DatabaseEngine } | undefined): DatabaseEngine {\n return applicationDatabase?.engine ?? DEFAULT_APPLICATION_DATABASE_ENGINE;\n}\n\nexport enum WildoImageTagStrategy {\n COMMIT_SHA = 'commit-sha',\n BRANCH_NAME = 'branch-name',\n SEMVER = 'semver',\n}\n\n/**\n * Docker Compose deployment — no scaling, no K8s-specific fields.\n */\nexport const DockerComposeDeploymentSchema = z.strictObject({\n branch: z.string().min(1),\n runtime: z.literal(WildoDeploymentRuntime.DOCKER_COMPOSE),\n imageTagStrategy: z.enum(WildoImageTagStrategy).default(WildoImageTagStrategy.COMMIT_SHA),\n});\n\n/**\n * Kubernetes deployment — branch, namespace and tagging.\n *\n * No `registry`: an environment's images live at `remoteProvider.registryEndpoint`, the registry every deploy\n * manifest pulls from and the deploy workflow pushes to. A separate field here could only repeat that value or\n * contradict it — and it did contradict it, sending CI pushes to GHCR while the cluster pulled from the endpoint\n * (#1165). Both deployment shapes are strict, so a leftover `registry` is refused rather than silently ignored.\n */\nexport const KubernetesDeploymentSchema = z.strictObject({\n branch: z.string().min(1),\n runtime: z.literal(WildoDeploymentRuntime.KUBERNETES),\n namespace: z.string().min(1).optional(),\n imageTagStrategy: z.enum(WildoImageTagStrategy).default(WildoImageTagStrategy.COMMIT_SHA),\n});\n\n/**\n * Deployment configuration for CI/CD pipeline integration.\n * Discriminated on `runtime`: the K8s-specific field (`namespace`)\n * is only available when `runtime` is `KUBERNETES`.\n */\nexport const WildoDeploymentConfigSchema = z.discriminatedUnion('runtime', [\n DockerComposeDeploymentSchema,\n KubernetesDeploymentSchema,\n]);\nexport type WildoDeploymentConfig = z.infer<typeof WildoDeploymentConfigSchema>;\n/** @wildo_source:part:end platform.config.environment.deployment */\n\n/**\n * Canonical namespace derivation for platform-managed application resources.\n *\n * Environment ids are part of the namespace because local and arbitrary remote\n * deployments must be isolated through generated names instead of hand-authored\n * checked-in values.\n */\nexport function buildApplicationNamespace(\n appSlug: string,\n environmentId: string,\n): string {\n const normalizedAppSlug = appSlug.trim();\n const normalizedEnvironmentId = environmentId.trim();\n\n if (!normalizedAppSlug) {\n throw new Error('appSlug is required to derive an application namespace');\n }\n if (!normalizedEnvironmentId) {\n throw new Error('environmentId is required to derive an application namespace');\n }\n\n return `${normalizedAppSlug}-${normalizedEnvironmentId}`;\n}\n\nexport function buildApplicationDatabaseUsername(\n appSlug: string,\n environmentId: string,\n): string {\n return `${buildApplicationNamespace(appSlug, environmentId)}_user`;\n}\n\n/**\n * Per-environment origins the DOCUMENTATION site must be built against.\n *\n * ## Why these are authored per environment rather than inferred\n *\n * A documentation bundle is STATIC: whatever origin it is built with is compiled into\n * the shipped JavaScript. The docs site deep-links anonymous readers into the SaaS app to\n * sign in, and exchanges a token against the backend, so a bundle built with the wrong\n * origin does not degrade — it silently points every reader at the wrong host.\n *\n * That is why `docusaurus.config.ts` refuses to complete a PRODUCTION build when these are\n * unset, and falls back to local defaults otherwise. The guard is correct; what was missing\n * was a declared source, so the values had to be remembered on a command line and were\n * therefore absent from every environment definition. Authoring them here puts them where\n * every other per-environment posture already lives, and `wildo config sync` carries them.\n *\n * Projected onto `WILDO_DOCS_API_BASE_URL`, `WILDO_DOCS_APP_URL` and\n * `WILDO_DOCS_FRONTEND_SERVICE_NAME` by `env-vars-builder`, mirroring `providerSelection`.\n *\n * Every member is optional: an application with no documentation site authors nothing, and\n * a local environment relies on the config's own dev defaults rather than restating ports\n * that the runtime already knows.\n */\nexport const WildoDocumentationSiteConfigSchema = z.object({\n /**\n * Backend origin the docs bundle calls for `/auth/token/exchange` and\n * `/auth/cross-frontend-handoff` — e.g. `https://api.example.com`.\n */\n apiBaseUrl: z.string().trim().min(1).optional(),\n /**\n * SaaS application origin the docs site deep-links anonymous readers to for sign-in —\n * e.g. `https://app.example.com`.\n */\n appUrl: z.string().trim().min(1).optional(),\n /**\n * Frontend service name the docs site identifies as when resolving its own providers.\n * Must match the service key declared in `wildo.saas.config.ts#frontendServices`.\n */\n frontendServiceName: z.string().trim().min(1).optional(),\n});\n\nexport type WildoDocumentationSiteConfig = z.infer<typeof WildoDocumentationSiteConfigSchema>;\n"]}
|
|
1
|
+
{"version":3,"file":"environment.schemas.js","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;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEhE;;;;;;;;GAQG;AACH,MAAM,CAAN,IAAY,gBAIX;AAJD,WAAY,gBAAgB;IAC1B,mCAAe,CAAA;IACf,uCAAmB,CAAA;IACnB,6CAAyB,CAAA;AAC3B,CAAC,EAJW,gBAAgB,KAAhB,gBAAgB,QAI3B;AAED,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC;KACtC,MAAM,EAAE;KACR,GAAG,CAAC,CAAC,CAAC;KACN,KAAK,CACJ,4BAA4B,EAC5B,wFAAwF,CACzF,CAAC;AAGJ;;;;;GAKG;AACH,MAAM,CAAN,IAAY,sBAGX;AAHD,WAAY,sBAAsB;IAChC,2DAAiC,CAAA;IACjC,mDAAyB,CAAA;AAC3B,CAAC,EAHW,sBAAsB,KAAtB,sBAAsB,QAGjC;AAED,MAAM,CAAN,IAAY,iBAGX;AAHD,WAAY,iBAAiB;IAC3B,oCAAe,CAAA;IACf,sCAAiB,CAAA;AACnB,CAAC,EAHW,iBAAiB,KAAjB,iBAAiB,QAG5B;AAED,MAAM,UAAU,oBAAoB,CAAC,aAAqB;IACxD,OAAO,aAAa,KAAK,gBAAgB,CAAC,KAAK,CAAC;AAClD,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,MAAM,CAAN,IAAY,qBAGX;AAHD,WAAY,qBAAqB;I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f,aAAqB;IAErB,MAAM,iBAAiB,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IACzC,MAAM,uBAAuB,GAAG,aAAa,CAAC,IAAI,EAAE,CAAC;IAErD,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAC;IAC5E,CAAC;IACD,IAAI,CAAC,uBAAuB,EAAE,CAAC;QAC7B,MAAM,IAAI,KAAK,CAAC,8DAA8D,CAAC,CAAC;IAClF,CAAC;IAED,OAAO,GAAG,iBAAiB,IAAI,uBAAuB,EAAE,CAAC;AAC3D,CAAC;AAED,MAAM,UAAU,gCAAgC,CAC9C,OAAe,EACf,aAAqB;IAErB,OAAO,GAAG,yBAAyB,CAAC,OAAO,EAAE,aAAa,CAAC,OAAO,CAAC;AACrE,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,CAAC,MAAM,kCAAkC,GAAG,CAAC,CAAC,MAAM,CAAC;IACzD;;;OAGG;IACH,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IAC/C;;;OAGG;IACH,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IAC3C;;;OAGG;IACH,mBAAmB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;CACzD,CAAC,CAAC","sourcesContent":["import { z } from 'zod';\nimport { EngineCapability } from '@wildo-ai/saas-models';\nimport { InfraServiceK8sSchema } from './infra-service.schemas';\n\n/**\n * @wildo_source:part:start platform.config.environment.deployment facet:layer:platform facet:family:infra\n *\n * Convenience environment ids kept for common local/staging/production setups.\n *\n * The project model is no longer limited to a fixed environment set: remote\n * environment ids can be any slug-like value. Use `WildoEnvironmentIdSchema`\n * for authoritative validation.\n */\nexport enum WildoEnvironment {\n LOCAL = 'local',\n STAGING = 'staging',\n PRODUCTION = 'production',\n}\n\nexport const WildoEnvironmentIdSchema = z\n .string()\n .min(1)\n .regex(\n /^[a-z0-9]+(?:-[a-z0-9]+)*$/,\n 'environment ids must be lowercase alphanumeric with optional hyphen-separated segments',\n );\nexport type WildoEnvironmentId = z.infer<typeof WildoEnvironmentIdSchema>;\n\n/**\n * Deployment runtime targets for CI/CD workflows and infra config.\n *\n * Single source of truth for deployment runtime targets, used by both\n * platform-config-lib (developer-facing config) and wildo-cli (operational).\n */\nexport enum WildoDeploymentRuntime {\n DOCKER_COMPOSE = 'docker-compose',\n KUBERNETES = 'kubernetes',\n}\n\nexport enum WildoLocationType {\n LOCAL = 'local',\n REMOTE = 'remote',\n}\n\nexport function isLocalEnvironmentId(environmentId: string): boolean {\n return environmentId === WildoEnvironment.LOCAL;\n}\n\n/**\n * Where a docker-compose backing service keeps its DATA.\n *\n * The two members are not a performance knob with a fast and a slow setting — they answer a\n * question about ownership, and the cost follows from the answer:\n *\n * - `HOST_PATH` — the data lives at an explicit path on the host\n * (`<saas-root>/.wildo-saas/local_data/<service>/`), bind-mounted into the container. The\n * operator chooses the disk, backups target a known directory, and the tree is the same one the\n * Kind k8s lane hostPath-mounts at `/mnt/local-data/<service>/`. That control is why it is the\n * REMOTE default: a production operator who has provisioned a dedicated data volume must be able\n * to put the database on it, and a named volume would silently land it under\n * `/var/lib/docker/volumes/` on the root disk.\n * - `DOCKER_VOLUME` — the data lives in a Docker named volume, inside the container runtime's own\n * storage. Nobody outside Docker addresses it, which is exactly what makes it right for a\n * disposable development stack.\n *\n * ## Why LOCAL defaults to `DOCKER_VOLUME`\n *\n * On Linux a bind mount is a native path and costs nothing. On macOS and Windows the container\n * runtime is a VM, and a host bind mount crosses a filesystem bridge — VirtioFS on macOS, 9p/\n * VirtioFS through WSL2 on Windows. Databases do small fsync'd random writes, so every one of them\n * becomes a round trip out of the VM.\n *\n * Measured on macOS (Apple Virtualization, 6 vCPU) on 2026-09-22 with the eight self-hosted backing\n * services bind-mounted: the VM process held **13,786 host file descriptors** open across 14,168\n * files and burned **383% CPU** in Docker Desktop's file-sharing process — sustained, a 321%\n * average over 2 days 5 hours — while the containers themselves used 0.7 of a core and container\n * block-IO accounting stayed flat, because none of that traffic reaches the VM's own block device.\n * Roughly four cores of pure filesystem translation for 0.7 of a core of database work.\n *\n * The default is uniform across all three development operating systems rather than \"volumes on\n * macOS and Windows, host paths on Linux\", so every developer and CI run exercise the same stack\n * and a bug reproduces the same way everywhere. It costs a Linux developer nothing: a named volume\n * is a native directory there too.\n *\n * Both members are authorable per environment (`localDataStorage`), so a remote operator who wants\n * volumes and a local developer who wants to read the files from their file manager each say so.\n *\n * NOTE this governs DATA directories only. The two small secret FILES compose mounts read-only —\n * immudb's state-signing key and mongot's sync-source password — are materialized from\n * `secrets.json` onto the host and stay host mounts under every mode. They are read once at\n * startup, so they carry none of the cost above, and they have nowhere else to come from.\n */\nexport enum WildoLocalDataStorage {\n DOCKER_VOLUME = 'docker-volume',\n HOST_PATH = 'host-path',\n}\n\n/**\n * The `localDataStorage` an environment gets when it authors none.\n *\n * Total over {@link WildoLocationType} rather than a conditional on one member, so a location type\n * added to the vocabulary tomorrow is a compile error here instead of silently inheriting whichever\n * branch happened to be the `else`.\n */\nexport function resolveDefaultLocalDataStorage(locationType: WildoLocationType): WildoLocalDataStorage {\n switch (locationType) {\n case WildoLocationType.LOCAL:\n return WildoLocalDataStorage.DOCKER_VOLUME;\n case WildoLocationType.REMOTE:\n return WildoLocalDataStorage.HOST_PATH;\n }\n}\n\n/**\n * Ingress controller installed by Wildo's local and remote Kubernetes workflows.\n * Import from `@wildo-ai/platform-config-lib`. Traefik owns both application\n * routing and HTTP-01 challenge routing; selecting another controller is not\n * supported by the generated installation contract.\n */\nexport enum WildoKubernetesIngressClass {\n TRAEFIK = 'traefik',\n}\n\n/**\n * K8s-internal cluster topology. Holds ONLY values that are genuinely\n * specific to a Kubernetes deployment: namespace, ingress class and\n * per-service workload replica counts.\n *\n * The external/public hostname (where browsers and reverse proxies hit\n * us) is NOT here — it lives at the top level of `WildoInfraEnvConfig`\n * as `publicDomain` because it applies to BOTH `KUBERNETES` and\n * `DOCKER_COMPOSE` runtimes. See `external-public-domain-rename.md`\n * for the rationale (the previous `baseDomain` field on this object\n * conflated K8s-internal and reverse-proxy concerns).\n */\nexport const WildoKubernetesConfigSchema = z.object({\n namespace: z.string().min(1),\n /**\n * Workload replica overrides keyed by authored SaaS service key (for example\n * backendApi, app or website), never by generated image/deployment name.\n * Platform service keys have their own renderer. Worker replicas remain in\n * the worker declaration; a key without a generated application target is\n * reported by application deployment generation rather than guessed.\n */\n services: z.record(z.string(), InfraServiceK8sSchema).optional(),\n // Derive the literal from the named runtime vocabulary while accepting the\n // natural authored spelling `ingressClass: 'traefik'` without an enum import.\n ingressClass: z.literal(`${WildoKubernetesIngressClass.TRAEFIK}`, {\n error: 'Wildo Kubernetes deployments support ingressClass traefik only; omit the field or select traefik.',\n }).optional(),\n});\nexport type WildoKubernetesConfig = z.infer<typeof WildoKubernetesConfigSchema>;\n\n/**\n * cert-manager `ClusterIssuer` selection for remote TLS. Both issuers are\n * always provisioned in the cluster (see `cluster-issuer.yaml.hbs`); this\n * picks which one an application's ingress annotation\n * (`cert-manager.io/cluster-issuer`) points at — i.e. which ACME endpoint\n * issues its per-ingress certificate.\n *\n * - `LETSENCRYPT_PROD` — real, browser-trusted certificates. The default,\n * because a remote deployment implies a real domain that browsers must\n * trust. Subject to Let's Encrypt production rate limits\n * (50 certs / registered domain / week).\n * - `LETSENCRYPT_STAGING` — untrusted test certificates with far higher\n * rate limits. Opt into this **while validating DNS + ingress on a new\n * cluster** so a misconfigured first deploy cannot exhaust the prod\n * quota, then flip to prod once issuance succeeds.\n */\nexport enum WildoTlsIssuer {\n LETSENCRYPT_PROD = 'letsencrypt-prod',\n LETSENCRYPT_STAGING = 'letsencrypt-staging',\n}\n\nexport const WildoRemoteProviderSchema = z.object({\n provider: z.string().min(1),\n registryEndpoint: z.string().min(1),\n region: z.string().min(1).optional(),\n /**\n * ACME registration email for Let's Encrypt (`ClusterIssuer.spec.acme.email`).\n * Optional at the schema level so non-TLS remote configs parse, but a\n * remote Kubernetes environment that terminates TLS should author it —\n * Let's Encrypt uses it for expiry warnings and account recovery.\n */\n acmeEmail: z.email().optional(),\n /**\n * Which cert-manager `ClusterIssuer` this environment's ingresses use.\n * Defaults to `LETSENCRYPT_PROD` downstream when unset. See {@link WildoTlsIssuer}.\n */\n tlsIssuer: z.enum(WildoTlsIssuer).optional(),\n});\nexport type WildoRemoteProvider = z.infer<typeof WildoRemoteProviderSchema>;\n\nexport const WildoLoggingConfigSchema = z.object({\n level: z.enum(['debug', 'info', 'warn', 'error']).default('info'),\n formattedConsoleErrors: z.boolean().optional(),\n});\nexport type WildoLoggingConfig = z.infer<typeof WildoLoggingConfigSchema>;\n\n/**\n * Per-environment OTLP telemetry (traces + metrics + logs) posture (Slice 2 Phase 5).\n *\n * `env-vars-builder` projects this block onto the standard `OTEL_*` env vars that the\n * `otel-preload.ts` SDK (in `saas-backend-lib`) reads BEFORE app code:\n * - `enabled` → `OTEL_ENABLED` (the master gate) + drives the `--import` preload wiring.\n * - `endpoint` → `OTEL_EXPORTER_OTLP_ENDPOINT` (the OTLP/HTTP collector/ingest URL).\n * The provider auth header (`OTEL_EXPORTER_OTLP_HEADERS`) is NOT authored here — it is\n * derived by `env-vars-builder` from the selected `OBSERVABILITY_TELEMETRY` provider's\n * secret (e.g. a BetterStack source token). Persisted into `PlatformEnvConfigJson.observability`\n * and hydrated back by `hydrateEnvironmentFromConfig`, mirroring `logging`.\n */\nexport const WildoObservabilityConfigSchema = z.object({\n /**\n * Master switch for OTLP telemetry. `true` → emit `OTEL_ENABLED=true` + wire the\n * `--import @wildo-ai/saas-backend-lib/otel-preload` preload; the preload starts the SDK.\n * `false`/omitted → a complete no-op (the preload self-gates).\n */\n enabled: z.boolean().default(false),\n /**\n * OTLP/HTTP endpoint (`OTEL_EXPORTER_OTLP_ENDPOINT`). Local dev: the local `otel-collector`\n * (`http://localhost:4318`). Remote: the selected provider's ingesting host (e.g. a BetterStack\n * source URL). When omitted, the OTLP exporters fall back to their own default\n * (`http://localhost:4318`), which is the local collector — convenient for local dev.\n */\n endpoint: z.string().optional(),\n /**\n * LLM-call observability env-layer posture — a SEPARATE signal from OTLP\n * telemetry (fed by the engine `AgentCallTraceSink` into the selected\n * `LLM_OBSERVABILITY` provider, e.g. PostHog `$ai_generation`), colocated\n * here because both are per-environment observability posture. Projected\n * onto the `WILDO_LLM_OBS_*` env vars INDEPENDENTLY of the OTLP `enabled`\n * gate — LLM-obs activation is provider-selection-driven, not\n * `OTEL_ENABLED`-driven.\n */\n llmObservability: z.object({\n /**\n * Forward prompt + completion content (`$ai_input` / `$ai_output_choices`)\n * to the LLM-observability provider (→ `WILDO_LLM_OBS_CAPTURE_CONTENT`).\n * Default FALSE: content is user/app data (PII) shipped to a third party —\n * opt in per environment (local dev typically true; production a\n * deliberate decision).\n */\n captureContent: z.boolean().default(false),\n /**\n * Fraction (0..1) of agent calls forwarded (→ `WILDO_LLM_OBS_SAMPLE_RATE`).\n * Omitted = capture every call.\n */\n sampleRate: z.number().min(0).max(1).optional(),\n /**\n * NON-SECRET env for the selected LLM-observability provider — connection\n * details the provider module reads from the runtime env (e.g. PostHog's\n * `POSTHOG_HOST` ingestion host and `POSTHOG_PROJECT_ID`). Projected\n * verbatim into the runtime env; the env-key names are provider-owned,\n * same vocabulary as `secrets.json → providerEnv`. Secrets (API keys)\n * do NOT belong here — they stay in `secrets.json → providerEnv`, which\n * also WINS on a key collision (secrets are the more specific layer).\n * This is the checked-in home for provider config that is not sensitive.\n */\n providerEnv: z.record(z.string(), z.string()).optional(),\n }).optional(),\n});\nexport type WildoObservabilityConfig = z.infer<typeof WildoObservabilityConfigSchema>;\n\n/**\n * Per-environment external-provider SELECTION override (2026-07-10).\n *\n * The app-wide primary/substitute selection for an `EngineCapability` lives in\n * `wildo.saas.config.ts` (`providers.scopes.backend.selection[capability]`) —\n * a single value shared by every environment. This block lets an environment\n * OVERRIDE that primary (and its substitutes) without touching the shared SaaS\n * config, so e.g. LOCAL can select the non-sending `email-preview` provider\n * for `EMAIL_TRANSACTIONAL` while staging/production keep `resend`.\n *\n * Semantics (mirrors the SaaS-side selection policy):\n * - `primary` — the ref that wins for this capability in this environment.\n * - `whenUnavailable` — ordered substitutes, used when a preceding ref is not AVAILABLE at\n * resolution time (undeclared, disabled, unconfigured). NOT failover: nothing retries a\n * second provider when a call to the first one fails.\n *\n * The referenced provider must still be DECLARED in\n * `providers.scopes.backend.providers` and available for the capability — the\n * backend's availability/enabled filtering is unchanged, so an override that\n * names an undeclared or capability-disabled provider resolves to nothing\n * (same fail-closed behaviour as an equivalent SaaS-side selection). FAN_OUT\n * capabilities ignore the override (every declared provider is active — a\n * primary/substitute is meaningless), matching the SaaS-side rule.\n *\n * `env-vars-builder` serializes this block to the `WILDO_PROVIDER_SELECTION_OVERRIDES`\n * backend env var (JSON); `ExternalProvidersRegistryBackendService` reads it and\n * applies it over the SaaS-config selection at capability-resolution time.\n * Persisted into `PlatformEnvConfigJson.providerSelection` and hydrated back by\n * `hydrateEnvironmentFromConfig`, mirroring `logging` / `observability`.\n */\nexport const WildoProviderSelectionOverrideEntrySchema = z.strictObject({\n primary: z.string().min(1),\n whenUnavailable: z.array(z.string().min(1)).optional(),\n});\nexport type WildoProviderSelectionOverrideEntry = z.infer<typeof WildoProviderSelectionOverrideEntrySchema>;\n\nexport const WildoProviderSelectionOverridesSchema = z.partialRecord(\n z.enum(EngineCapability),\n WildoProviderSelectionOverrideEntrySchema,\n);\nexport type WildoProviderSelectionOverrides = z.infer<typeof WildoProviderSelectionOverridesSchema>;\n\n/**\n * Per-environment provider CONFIGURATION values — the half of `providerConfigurations` that exists once per\n * DEPLOYMENT rather than once per application.\n *\n * `wildo.saas.config.ts > providerConfigurations` is authored once and reaches every environment. That is right for\n * application POLICY a provider reads (an agent execution profile, which environments it may run in). It is wrong\n * for an IDENTITY the vendor issued against one deployment: an OAuth client ID registered with the authorized\n * redirect URIs of one environment, a frontend SDK DSN or site key, a picker `appId`. Authored in the SaaS config, the\n * local development Google client — whose only redirect URI is `localhost` — would be the client staging and\n * production send users to.\n *\n * This block carries those values for ONE environment, in exactly the SaaS block's\n * `providerRef → protocolKind → key` shape, and {@link overlayEnvironmentProviderConfigurations} lays it over the\n * SaaS block KEY BY KEY. An environment therefore states only what differs and inherits the rest, so the policy half\n * is never restated per environment.\n *\n * It reaches both places a provider configuration is read, because the CLI applies the overlay where it knows the\n * environment: the managed declaration each environment's apps-manager stores (backend readers — the OAuth2\n * connection resolver, email/SMS senders, the provider registry) and the provider runtime artifacts a build bakes in\n * (frontend `publicConfig`, the backend's generated provider module).\n *\n * NOT for secrets. This file is committed; a client secret, API key or signing secret stays in\n * `secrets.json → providerEnv`. The CLI refuses a key named like one of the provider's declared secrets.\n */\nexport const WildoEnvironmentProviderConfigurationsSchema = z.record(\n z.string().min(1),\n z.record(z.string().min(1), z.record(z.string().min(1), z.unknown())),\n);\nexport type WildoEnvironmentProviderConfigurations = z.infer<typeof WildoEnvironmentProviderConfigurationsSchema>;\n\n/**\n * The provider configuration ONE environment runs with: the application-level `providerConfigurations`, with the\n * environment's {@link WildoEnvironmentProviderConfigurationsSchema} values laid over it key by key.\n *\n * Precedence is per key inside one `providerRef → protocolKind` bag, and the environment wins — the more specific\n * layer, as `secrets.json → providerEnv` wins over `observability.llmObservability.providerEnv`. A bag the\n * environment does not mention is carried unchanged; a bag only the environment declares is added. Neither input is\n * mutated.\n *\n * Rejected: replacing a whole provider or protocol bag. That would force an environment to restate every\n * environment-invariant key it shares with the application (an agent execution profile beside a client ID), and a\n * restated copy is one that drifts from the original.\n *\n * Throws when the application layer holds a non-object at a protocol key the environment overlays: there is no key\n * to lay a value over, and silently replacing it would discard the application's value without saying so.\n */\nexport function overlayEnvironmentProviderConfigurations(\n applicationProviderConfigurations: Readonly<Record<string, Readonly<Record<string, unknown>> | undefined>> | undefined,\n environmentProviderConfigurations: WildoEnvironmentProviderConfigurations | undefined,\n): Record<string, Record<string, unknown> | undefined> {\n const resolved: Record<string, Record<string, unknown> | undefined> = {};\n for (const [providerRef, protocols] of Object.entries(applicationProviderConfigurations ?? {})) {\n resolved[providerRef] = protocols === undefined ? undefined : { ...protocols };\n }\n for (const [providerRef, environmentProtocols] of Object.entries(environmentProviderConfigurations ?? {})) {\n const merged: Record<string, unknown> = { ...(resolved[providerRef] ?? {}) };\n for (const [protocolKind, environmentValues] of Object.entries(environmentProtocols)) {\n const applicationValues = merged[protocolKind];\n if (applicationValues !== undefined && (applicationValues === null || typeof applicationValues !== 'object' || Array.isArray(applicationValues))) {\n throw new Error(\n `providerConfigurations.${providerRef}.${protocolKind} is not an object in wildo.saas.config.ts, so the `\n + 'environment\\'s values for it cannot be laid over it key by key.',\n );\n }\n merged[protocolKind] = { ...(applicationValues as Record<string, unknown> | undefined), ...environmentValues };\n }\n resolved[providerRef] = merged;\n }\n return resolved;\n}\n\nexport enum DatabaseEngine {\n MONGODB = 'mongodb',\n POSTGRESQL = 'postgresql',\n}\n\n/**\n * The store an APPLICATION persists to when its environment authors no `applicationDatabase`.\n *\n * PostgreSQL — decided by Paul on 2026-09-24 (#1571), reversing 75cd1934f (\"absence means MongoDB\")\n * and restoring the rule of 2e0194c41. This is the ONLY place the answer is written. Every reader of\n * an application's engine goes through {@link resolveApplicationDatabaseEngine}, because the\n * 2026-09-15 incident was two readers answering silence differently: provisioning chose PostgreSQL,\n * the runtime chose MongoDB, Mongo provisioning was skipped, registration reported success, and the\n * application died at boot with `Command update requires authentication`.\n *\n * Distinct from the PLATFORM's own store (`database` in the infra config) and from the engine's\n * `DEFAULT_PERSISTENCE_ADAPTER` / `DATABASE_DEFAULT_ADAPTER` env default, which also governs\n * platform services and is not what this decides. The application never falls through to that env\n * default: the CLI writes the resolved adapter explicitly.\n */\nexport const DEFAULT_APPLICATION_DATABASE_ENGINE: DatabaseEngine = DatabaseEngine.POSTGRESQL;\n\n/**\n * The engine an application persists to: its authored `applicationDatabase.engine`, or\n * {@link DEFAULT_APPLICATION_DATABASE_ENGINE} when the environment authors none.\n *\n * Takes the declaration rather than a whole config so every carrier of it — the parsed infra config,\n * `config.json`, a bootstrap request — answers through the same function.\n */\nexport function resolveApplicationDatabaseEngine(applicationDatabase: { readonly engine?: DatabaseEngine } | undefined): DatabaseEngine {\n return applicationDatabase?.engine ?? DEFAULT_APPLICATION_DATABASE_ENGINE;\n}\n\nexport enum WildoImageTagStrategy {\n COMMIT_SHA = 'commit-sha',\n BRANCH_NAME = 'branch-name',\n SEMVER = 'semver',\n}\n\n/**\n * Docker Compose deployment — no scaling, no K8s-specific fields.\n */\nexport const DockerComposeDeploymentSchema = z.strictObject({\n branch: z.string().min(1),\n runtime: z.literal(WildoDeploymentRuntime.DOCKER_COMPOSE),\n imageTagStrategy: z.enum(WildoImageTagStrategy).default(WildoImageTagStrategy.COMMIT_SHA),\n});\n\n/**\n * Kubernetes deployment — branch, namespace and tagging.\n *\n * No `registry`: an environment's images live at `remoteProvider.registryEndpoint`, the registry every deploy\n * manifest pulls from and the deploy workflow pushes to. A separate field here could only repeat that value or\n * contradict it — and it did contradict it, sending CI pushes to GHCR while the cluster pulled from the endpoint\n * (#1165). Both deployment shapes are strict, so a leftover `registry` is refused rather than silently ignored.\n */\nexport const KubernetesDeploymentSchema = z.strictObject({\n branch: z.string().min(1),\n runtime: z.literal(WildoDeploymentRuntime.KUBERNETES),\n namespace: z.string().min(1).optional(),\n imageTagStrategy: z.enum(WildoImageTagStrategy).default(WildoImageTagStrategy.COMMIT_SHA),\n});\n\n/**\n * Deployment configuration for CI/CD pipeline integration.\n * Discriminated on `runtime`: the K8s-specific field (`namespace`)\n * is only available when `runtime` is `KUBERNETES`.\n */\nexport const WildoDeploymentConfigSchema = z.discriminatedUnion('runtime', [\n DockerComposeDeploymentSchema,\n KubernetesDeploymentSchema,\n]);\nexport type WildoDeploymentConfig = z.infer<typeof WildoDeploymentConfigSchema>;\n/** @wildo_source:part:end platform.config.environment.deployment */\n\n/**\n * Canonical namespace derivation for platform-managed application resources.\n *\n * Environment ids are part of the namespace because local and arbitrary remote\n * deployments must be isolated through generated names instead of hand-authored\n * checked-in values.\n */\nexport function buildApplicationNamespace(\n appSlug: string,\n environmentId: string,\n): string {\n const normalizedAppSlug = appSlug.trim();\n const normalizedEnvironmentId = environmentId.trim();\n\n if (!normalizedAppSlug) {\n throw new Error('appSlug is required to derive an application namespace');\n }\n if (!normalizedEnvironmentId) {\n throw new Error('environmentId is required to derive an application namespace');\n }\n\n return `${normalizedAppSlug}-${normalizedEnvironmentId}`;\n}\n\nexport function buildApplicationDatabaseUsername(\n appSlug: string,\n environmentId: string,\n): string {\n return `${buildApplicationNamespace(appSlug, environmentId)}_user`;\n}\n\n/**\n * Per-environment origins the DOCUMENTATION site must be built against.\n *\n * ## Why these are authored per environment rather than inferred\n *\n * A documentation bundle is STATIC: whatever origin it is built with is compiled into\n * the shipped JavaScript. The docs site deep-links anonymous readers into the SaaS app to\n * sign in, and exchanges a token against the backend, so a bundle built with the wrong\n * origin does not degrade — it silently points every reader at the wrong host.\n *\n * That is why `docusaurus.config.ts` refuses to complete a PRODUCTION build when these are\n * unset, and falls back to local defaults otherwise. The guard is correct; what was missing\n * was a declared source, so the values had to be remembered on a command line and were\n * therefore absent from every environment definition. Authoring them here puts them where\n * every other per-environment posture already lives, and `wildo config sync` carries them.\n *\n * Projected onto `WILDO_DOCS_API_BASE_URL`, `WILDO_DOCS_APP_URL` and\n * `WILDO_DOCS_FRONTEND_SERVICE_NAME` by `env-vars-builder`, mirroring `providerSelection`.\n *\n * Every member is optional: an application with no documentation site authors nothing, and\n * a local environment relies on the config's own dev defaults rather than restating ports\n * that the runtime already knows.\n */\nexport const WildoDocumentationSiteConfigSchema = z.object({\n /**\n * Backend origin the docs bundle calls for `/auth/token/exchange` and\n * `/auth/cross-frontend-handoff` — e.g. `https://api.example.com`.\n */\n apiBaseUrl: z.string().trim().min(1).optional(),\n /**\n * SaaS application origin the docs site deep-links anonymous readers to for sign-in —\n * e.g. `https://app.example.com`.\n */\n appUrl: z.string().trim().min(1).optional(),\n /**\n * Frontend service name the docs site identifies as when resolving its own providers.\n * Must match the service key declared in `wildo.saas.config.ts#frontendServices`.\n */\n frontendServiceName: z.string().trim().min(1).optional(),\n});\n\nexport type WildoDocumentationSiteConfig = z.infer<typeof WildoDocumentationSiteConfigSchema>;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"infra-providers.schemas.d.ts","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"infra-providers.schemas.d.ts","sourceRoot":"","sources":["../../../../src/project-config/shared/infra-providers.schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,6CAA6C,CAAC;AAC/F,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAChF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE/D;;;;;;GAMG;AACH,oBAAY,eAAe;IACzB,iBAAiB,sBAAsB;IACvC,mBAAmB,wBAAwB;IAC3C,iBAAiB,sBAAsB;IACvC,cAAc,mBAAmB;IACjC,kBAAkB,uBAAuB;IACzC,cAAc,mBAAmB;IACjC,aAAa,kBAAkB;IAC/B;;;OAGG;IACH,iBAAiB,sBAAsB;IACvC;;;OAGG;IACH,cAAc,mBAAmB;CAClC;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,kCAAkC,EAAE,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC,CAkBjG,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,2BAA2B,EAAE,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