@wildo-ai/wildo-cli 1.1.14 → 1.1.15

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.
Files changed (142) hide show
  1. package/dist/src/commands/generate/email-command.utils.d.ts +2 -0
  2. package/dist/src/commands/generate/email-command.utils.d.ts.map +1 -1
  3. package/dist/src/commands/generate/email-command.utils.js +5 -0
  4. package/dist/src/commands/generate/email-command.utils.js.map +1 -1
  5. package/dist/src/commands/init.command.d.ts.map +1 -1
  6. package/dist/src/commands/init.command.js +7 -2
  7. package/dist/src/commands/init.command.js.map +1 -1
  8. package/dist/src/commands/local/deregister.command.d.ts.map +1 -1
  9. package/dist/src/commands/local/deregister.command.js +4 -0
  10. package/dist/src/commands/local/deregister.command.js.map +1 -1
  11. package/dist/src/commands/local/dev.command.d.ts +6 -0
  12. package/dist/src/commands/local/dev.command.d.ts.map +1 -1
  13. package/dist/src/commands/local/dev.command.js +72 -0
  14. package/dist/src/commands/local/dev.command.js.map +1 -1
  15. package/dist/src/commands/local/jobs-command.utils.d.ts +24 -0
  16. package/dist/src/commands/local/jobs-command.utils.d.ts.map +1 -0
  17. package/dist/src/commands/local/jobs-command.utils.js +44 -0
  18. package/dist/src/commands/local/jobs-command.utils.js.map +1 -0
  19. package/dist/src/commands/local/jobs-run.command.d.ts +7 -0
  20. package/dist/src/commands/local/jobs-run.command.d.ts.map +1 -0
  21. package/dist/src/commands/local/jobs-run.command.js +92 -0
  22. package/dist/src/commands/local/jobs-run.command.js.map +1 -0
  23. package/dist/src/commands/local/jobs.command.d.ts +7 -0
  24. package/dist/src/commands/local/jobs.command.d.ts.map +1 -0
  25. package/dist/src/commands/local/jobs.command.js +59 -0
  26. package/dist/src/commands/local/jobs.command.js.map +1 -0
  27. package/dist/src/commands/local/tunnel.command.d.ts +84 -0
  28. package/dist/src/commands/local/tunnel.command.d.ts.map +1 -0
  29. package/dist/src/commands/local/tunnel.command.js +274 -0
  30. package/dist/src/commands/local/tunnel.command.js.map +1 -0
  31. package/dist/src/services/application/app-bootstrap.service.d.ts +41 -1
  32. package/dist/src/services/application/app-bootstrap.service.d.ts.map +1 -1
  33. package/dist/src/services/application/app-bootstrap.service.js +49 -3
  34. package/dist/src/services/application/app-bootstrap.service.js.map +1 -1
  35. package/dist/src/services/application/app-runtime-targets.service.d.ts.map +1 -1
  36. package/dist/src/services/application/app-runtime-targets.service.js +9 -1
  37. package/dist/src/services/application/app-runtime-targets.service.js.map +1 -1
  38. package/dist/src/services/application/application-dependency-alignment.service.d.ts +20 -0
  39. package/dist/src/services/application/application-dependency-alignment.service.d.ts.map +1 -1
  40. package/dist/src/services/application/application-dependency-alignment.service.js +32 -2
  41. package/dist/src/services/application/application-dependency-alignment.service.js.map +1 -1
  42. package/dist/src/services/application/local-tunnel.service.d.ts +153 -0
  43. package/dist/src/services/application/local-tunnel.service.d.ts.map +1 -0
  44. package/dist/src/services/application/local-tunnel.service.js +294 -0
  45. package/dist/src/services/application/local-tunnel.service.js.map +1 -0
  46. package/dist/src/services/application/provider-runtime-sync.service.d.ts.map +1 -1
  47. package/dist/src/services/application/provider-runtime-sync.service.js +3 -0
  48. package/dist/src/services/application/provider-runtime-sync.service.js.map +1 -1
  49. package/dist/src/services/application/saas-skeleton.service.d.ts +7 -0
  50. package/dist/src/services/application/saas-skeleton.service.d.ts.map +1 -1
  51. package/dist/src/services/application/saas-skeleton.service.js +2 -0
  52. package/dist/src/services/application/saas-skeleton.service.js.map +1 -1
  53. package/dist/src/services/catalog/service-address-resolver.service.d.ts +7 -1
  54. package/dist/src/services/catalog/service-address-resolver.service.d.ts.map +1 -1
  55. package/dist/src/services/catalog/service-address-resolver.service.js +6 -3
  56. package/dist/src/services/catalog/service-address-resolver.service.js.map +1 -1
  57. package/dist/src/services/credentials/application-secrets.service.d.ts +6 -0
  58. package/dist/src/services/credentials/application-secrets.service.d.ts.map +1 -1
  59. package/dist/src/services/credentials/application-secrets.service.js +1 -1
  60. package/dist/src/services/credentials/application-secrets.service.js.map +1 -1
  61. package/dist/src/services/credentials/provider-env-vars.utils.d.ts.map +1 -1
  62. package/dist/src/services/credentials/provider-env-vars.utils.js +3 -1
  63. package/dist/src/services/credentials/provider-env-vars.utils.js.map +1 -1
  64. package/dist/src/services/credentials/secrets-writer.service.d.ts +11 -2
  65. package/dist/src/services/credentials/secrets-writer.service.d.ts.map +1 -1
  66. package/dist/src/services/credentials/secrets-writer.service.js +12 -3
  67. package/dist/src/services/credentials/secrets-writer.service.js.map +1 -1
  68. package/dist/src/services/deployment/ci-deploy-generator.service.d.ts.map +1 -1
  69. package/dist/src/services/deployment/ci-deploy-generator.service.js +3 -3
  70. package/dist/src/services/deployment/ci-deploy-generator.service.js.map +1 -1
  71. package/dist/src/services/deployment/docker/docker-compose-generator.service.d.ts +3 -3
  72. package/dist/src/services/deployment/docker/docker-compose-generator.service.d.ts.map +1 -1
  73. package/dist/src/services/deployment/docker/docker-compose-generator.service.js +16 -12
  74. package/dist/src/services/deployment/docker/docker-compose-generator.service.js.map +1 -1
  75. package/dist/src/services/deployment/framework-pod-network-membership.d.ts +6 -0
  76. package/dist/src/services/deployment/framework-pod-network-membership.d.ts.map +1 -1
  77. package/dist/src/services/deployment/framework-pod-network-membership.js +12 -3
  78. package/dist/src/services/deployment/framework-pod-network-membership.js.map +1 -1
  79. package/dist/src/services/deployment/k8s/k8s-manifest-generator.service.d.ts +4 -1
  80. package/dist/src/services/deployment/k8s/k8s-manifest-generator.service.d.ts.map +1 -1
  81. package/dist/src/services/deployment/k8s/k8s-manifest-generator.service.js +17 -7
  82. package/dist/src/services/deployment/k8s/k8s-manifest-generator.service.js.map +1 -1
  83. package/dist/src/services/deployment/k8s/k8s-manifest.schemas.d.ts +7 -0
  84. package/dist/src/services/deployment/k8s/k8s-manifest.schemas.d.ts.map +1 -1
  85. package/dist/src/services/deployment/k8s/k8s-manifest.schemas.js.map +1 -1
  86. package/dist/src/services/deployment/k8s/k8s-secrets-generator.service.d.ts.map +1 -1
  87. package/dist/src/services/deployment/k8s/k8s-secrets-generator.service.js +15 -9
  88. package/dist/src/services/deployment/k8s/k8s-secrets-generator.service.js.map +1 -1
  89. package/dist/src/services/deployment/k8s/kind-pod-host-gateway.d.ts +43 -0
  90. package/dist/src/services/deployment/k8s/kind-pod-host-gateway.d.ts.map +1 -0
  91. package/dist/src/services/deployment/k8s/kind-pod-host-gateway.js +12 -0
  92. package/dist/src/services/deployment/k8s/kind-pod-host-gateway.js.map +1 -0
  93. package/dist/src/services/deployment/k8s/off-cluster-backing-services.d.ts +3 -1
  94. package/dist/src/services/deployment/k8s/off-cluster-backing-services.d.ts.map +1 -1
  95. package/dist/src/services/deployment/k8s/off-cluster-backing-services.js.map +1 -1
  96. package/dist/src/services/deployment/local-dev-late-workspace-members.service.d.ts +124 -0
  97. package/dist/src/services/deployment/local-dev-late-workspace-members.service.d.ts.map +1 -0
  98. package/dist/src/services/deployment/local-dev-late-workspace-members.service.js +249 -0
  99. package/dist/src/services/deployment/local-dev-late-workspace-members.service.js.map +1 -0
  100. package/dist/src/services/environment/authored-infra-config.utils.d.ts +9 -0
  101. package/dist/src/services/environment/authored-infra-config.utils.d.ts.map +1 -1
  102. package/dist/src/services/environment/authored-infra-config.utils.js +20 -1
  103. package/dist/src/services/environment/authored-infra-config.utils.js.map +1 -1
  104. package/dist/src/services/environment/container-host-gateway-listen-host.d.ts +6 -0
  105. package/dist/src/services/environment/container-host-gateway-listen-host.d.ts.map +1 -1
  106. package/dist/src/services/environment/container-host-gateway-listen-host.js +6 -0
  107. package/dist/src/services/environment/container-host-gateway-listen-host.js.map +1 -1
  108. package/dist/src/services/environment/env-configuration-generator.service.d.ts +12 -0
  109. package/dist/src/services/environment/env-configuration-generator.service.d.ts.map +1 -1
  110. package/dist/src/services/environment/env-configuration-generator.service.js +37 -5
  111. package/dist/src/services/environment/env-configuration-generator.service.js.map +1 -1
  112. package/dist/src/services/environment/env-vars-builder.service.d.ts +2 -1
  113. package/dist/src/services/environment/env-vars-builder.service.d.ts.map +1 -1
  114. package/dist/src/services/environment/env-vars-builder.service.js +47 -32
  115. package/dist/src/services/environment/env-vars-builder.service.js.map +1 -1
  116. package/dist/src/services/environment/environment-lifecycle.service.d.ts +7 -4
  117. package/dist/src/services/environment/environment-lifecycle.service.d.ts.map +1 -1
  118. package/dist/src/services/environment/environment-lifecycle.service.js +14 -18
  119. package/dist/src/services/environment/environment-lifecycle.service.js.map +1 -1
  120. package/dist/src/services/environment/environment-setup.service.d.ts.map +1 -1
  121. package/dist/src/services/environment/environment-setup.service.js +17 -6
  122. package/dist/src/services/environment/environment-setup.service.js.map +1 -1
  123. package/dist/src/services/environment/environment.service.d.ts +4 -3
  124. package/dist/src/services/environment/environment.service.d.ts.map +1 -1
  125. package/dist/src/services/environment/environment.service.js +0 -1
  126. package/dist/src/services/environment/environment.service.js.map +1 -1
  127. package/dist/src/services/framework/framework-docker-publish.service.d.ts +55 -15
  128. package/dist/src/services/framework/framework-docker-publish.service.d.ts.map +1 -1
  129. package/dist/src/services/framework/framework-docker-publish.service.js +115 -25
  130. package/dist/src/services/framework/framework-docker-publish.service.js.map +1 -1
  131. package/dist/src/services/security/csp-sync.service.d.ts.map +1 -1
  132. package/dist/src/services/security/csp-sync.service.js +21 -2
  133. package/dist/src/services/security/csp-sync.service.js.map +1 -1
  134. package/dist/tsconfig.build.tsbuildinfo +1 -1
  135. package/package.json +19 -19
  136. package/templates/infra/docker-compose/docker-compose.wildo-platform.yml.hbs +14 -7
  137. package/templates/infra/k8s/platform/platform-crontabs-batches-manager/deployment.yaml.hbs +13 -0
  138. package/templates/saas/skeleton/.wildo-saas/wildo-dev-companion/scripts/dev-supervised.sh +18 -4
  139. package/templates/saas/skeleton/frontend/nginx-config/default.conf.hbs +1 -1
  140. package/templates/saas/skeleton/frontend/src/generated/csp.generated.json.hbs +4 -4
  141. package/templates/saas/skeleton/infrastructure/local/wildo.infra.local.config.ts.hbs +2 -0
  142. package/wildo-framework.info.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"framework-docker-publish.service.js","sourceRoot":"","sources":["../../../../src/services/framework/framework-docker-publish.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AAC5B,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AACtC,OAAO,EACL,sBAAsB,EACtB,6BAA6B,EAC7B,gCAAgC,GAGjC,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,kCAAkC,EAClC,sCAAsC,GACvC,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,uBAAuB,EAAE,MAAM,yDAAyD,CAAC;AAClG,OAAO,EAAE,WAAW,EAAE,MAAM,sDAAsD,CAAC;AAEnF,iIAAiI;AACjI,MAAM,CAAC,MAAM,8BAA8B,GAAG,mCAAmC,CAAC;AAClF,MAAM,CAAC,MAAM,6BAA6B,GAAG,kCAAkC,CAAC;AAChF;;;GAGG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,kCAAkC,CAAC;AAChF,kGAAkG;AAClG,MAAM,CAAC,MAAM,4BAA4B,GAAG,iCAAiC,CAAC;AAE9E;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAG,CAAC,uBAAuB,EAAE,aAAa,CAAU,CAAC;AAElG;;;;GAIG;AACH,MAAM,CAAN,IAAY,qBAYX;AAZD,WAAY,qBAAqB;IAC/B;;;;;;;;;OASG;IACH,0DAAiC,CAAA;AACnC,CAAC,EAZW,qBAAqB,KAArB,qBAAqB,QAYhC;AAED,wHAAwH;AACxH,MAAM,CAAC,MAAM,2BAA2B,GAAG,+BAA+B,CAAC;AAE3E,6HAA6H;AAC7H,MAAM,CAAC,MAAM,0BAA0B,GAAG,6CAA6C,CAAC;AAExF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EAAE,CAAC,CAAC;YAC/H,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;gBAAE,OAAO;YAChC,MAAM,QAAQ,GAAI,MAAM,CAAC,KAA2C,EAAE,IAAI,KAAK,WAAW,CAAC;YAC3F,MAAM,MAAM,GAAG,QAAQ;gBACrB,CAAC,CAAC,qBAAqB,OAAO,yDAAyD;gBACvF,CAAC,CAAC,MAAM,CAAC,MAAM;oBACb,CAAC,CAAC,mBAAmB,MAAM,CAAC,MAAM,EAAE;oBACpC,CAAC,CAAC,aAAa,MAAM,CAAC,MAAM,IAAI,kBAAkB,EAAE,CAAC;YACzD,MAAM,IAAI,GAAG,OAAO,KAAK,qCAAqC,CAAC;YAC/D,GAAG,CAAC,UAAU,KAAK,aAAa,OAAO,OAAO,qCAAqC,KAAK,MAAM,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,gBAAgB,EAAE,CAAC,CAAC;YAClI,IAAI,IAAI;gBAAE,MAAM,IAAI,KAAK,CAAC,UAAU,KAAK,iBAAiB,qCAAqC,cAAc,MAAM,GAAG,CAAC,CAAC;QAC1H,CAAC;IACH,CAAC;IAEO,MAAM,CAAC,gBAAgB,CAAC,KAAa,EAAE,IAAc;QAC3D,MAAM,MAAM,GAAG,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE;YACvC,QAAQ,EAAE,MAAM;YAChB,KAAK,EAAE,SAAS;SACjB,CAAC,CAAC;QACH,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACxB,MAAM,IAAI,KAAK,CAAC,UAAU,KAAK,UAAU,CAAC,CAAC;QAC7C,CAAC;IACH,CAAC;CACF","sourcesContent":["import { spawnSync } from 'child_process';\nimport { existsSync, mkdtempSync, readFileSync, rmSync } from 'fs';\nimport { tmpdir } from 'os';\nimport { join, relative } from 'path';\nimport {\n resolveFrameworkLayout,\n WildoFrameworkDockerImageRole,\n WildoFrameworkDockerImageVariant,\n type FrameworkLayoutPaths,\n type WildoFrameworkReleaseDockerImage,\n} from '@wildo-ai/platform-config-lib';\nimport {\n FRAMEWORK_RELEASE_DOCKER_NAMESPACE,\n FRAMEWORK_RELEASE_DOCKER_REGISTRY_HOST,\n} from '@wildo-ai/platform-config-lib';\nimport { FrameworkReleaseService } from '~wildo-cli/services/framework/framework-release.service';\nimport { DockerUtils } from '~wildo-cli/services/deployment/docker/docker.service';\n\n/** OCI annotation keys (image-spec `annotations.md`, dead-plan-citation: the OCI spec's own file), used here as build labels. */\nexport const FRAMEWORK_IMAGE_REVISION_LABEL = 'org.opencontainers.image.revision';\nexport const FRAMEWORK_IMAGE_CREATED_LABEL = 'org.opencontainers.image.created';\n/**\n * The release the image IS: the immutable tag it is pushed under (the framework version, or a channel's\n * own identity such as `test-<sha>`), so an image pulled by an alias or by digest still names its release.\n */\nexport const FRAMEWORK_IMAGE_VERSION_LABEL = 'org.opencontainers.image.version';\n/** The repository the image is built from: the framework config's `publish.npm.repositoryUrl`. */\nexport const FRAMEWORK_IMAGE_SOURCE_LABEL = 'org.opencontainers.image.source';\n\n/**\n * The BuildKit attestations pushed beside every framework image, inside the same image index: SLSA\n * provenance in `max` mode (the full build definition: Dockerfile, build args, source materials) and an\n * SPDX SBOM of each platform's filesystem. Registries and scanners (Docker Scout, `docker buildx\n * imagetools inspect --format '{{json .Provenance}}'`/`'{{json .SBOM}}'`) read them from there, and\n * `imagetools create` carries them along when an alias is repointed at the index.\n */\nexport const FRAMEWORK_IMAGE_ATTESTATION_ARGS = ['--provenance=mode=max', '--sbom=true'] as const;\n\n/**\n * How a pushed framework image is signed (#3063). Chosen by the environment that runs the lane, never by the lane\n * itself: keyless signing needs a workload identity (the release job's GitHub OIDC token), which a developer machine\n * running the break-glass `wildo fwk release` does not have.\n */\nexport enum FrameworkImageSigning {\n /**\n * `cosign sign --yes <repository>@<digest>`: a short-lived Fulcio certificate bound to the release workflow's identity,\n * the signature recorded in the Rekor transparency log and stored beside the image index in the registry, then\n * `cosign verify` against that identity. Signs the DIGEST of the index buildx pushed, never a tag, so what is signed is\n * exactly what was built. An alias (`latest`) is covered only while it names that same index: `imagetools create` from\n * one index source keeps the index as it is, so its digest is the signed one.\n *\n * The certificate puts the repository, the workflow, its ref, the commit and the run in the public Rekor log for good.\n * The image's own OCI labels already publish the source URL and the revision.\n */\n COSIGN_KEYLESS = 'cosign_keyless',\n}\n\n/** The environment variable a release environment sets to a {@link FrameworkImageSigning} member. Unset: no signing. */\nexport const FRAMEWORK_IMAGE_SIGNING_ENV = 'WILDO_FRAMEWORK_IMAGE_SIGNING';\n\n/** The OIDC issuer of a GitHub Actions workload identity: the issuer of every keyless certificate the release signs with. */\nexport const GITHUB_ACTIONS_OIDC_ISSUER = 'https://token.actions.githubusercontent.com';\n\n/**\n * The identity a keyless signature made in this job carries, as `cosign verify --certificate-identity` takes it:\n * `https://github.com/<owner>/<repo>/<workflow path>@<ref>`, from `GITHUB_WORKFLOW_REF`. Undefined outside Actions.\n */\nexport function githubWorkflowSigningIdentityOf(env: NodeJS.ProcessEnv = process.env): string | undefined {\n const workflowRef = env.GITHUB_WORKFLOW_REF?.trim();\n return workflowRef ? `${env.GITHUB_SERVER_URL?.trim() || 'https://github.com'}/${workflowRef}` : undefined;\n}\n\n/** What became of one image's signature. */\nexport enum FrameworkImageSignatureOutcome {\n /** Signed by digest. */\n SIGNED = 'signed',\n /** The environment asked for no signing (a developer machine running the break-glass release). */\n NOT_REQUESTED = 'not_requested',\n /**\n * Asked for and not proven: no workload identity to sign as (`GITHUB_WORKFLOW_REF` unset), the pushed digest unreadable,\n * cosign absent or refusing to sign, or a signature made that `cosign verify` did not confirm. The image is already public, so\n * the release does not stop on it (a consumer's `cosign verify` reports the missing signature, a false claim is not\n * made); the lane reports it, and the image is signed by hand with the command named in `reason`.\n */\n FAILED = 'failed',\n}\n\n/** The signing the environment asks for, or undefined. An unknown value is refused, never read as \"no signing\". */\nexport function frameworkImageSigningOf(env: NodeJS.ProcessEnv = process.env): FrameworkImageSigning | undefined {\n const raw = env[FRAMEWORK_IMAGE_SIGNING_ENV]?.trim();\n if (!raw) return undefined;\n if (!(Object.values(FrameworkImageSigning) as string[]).includes(raw)) {\n throw new Error(`${FRAMEWORK_IMAGE_SIGNING_ENV}=\"${raw}\" names no image signing; expected one of: ${Object.values(FrameworkImageSigning).join(', ')}.`);\n }\n return raw as FrameworkImageSigning;\n}\n\n/** What the identity labels say: the release and the repository it was built from. */\ninterface FrameworkImageIdentity {\n version: string;\n sourceUrl: string;\n}\n\n/** A `.dockerignore` pattern that names no wildcard — a plain path, rather than a glob pathspec. */\nfunction isPlainIgnorePath(pattern: string): boolean {\n return !/[*?[\\]]/.test(pattern);\n}\n\n/**\n * The git pathspecs covering what a Docker build SENDS from its context, derived from the ignore file\n * the build itself obeys: `<Dockerfile>.dockerignore` when present (BuildKit prefers it), else the\n * context's `.dockerignore`. What the image was built from is then asked of those paths only — whether\n * they were dirty at build time, and how many commits touched them since — instead of the whole\n * repository, which several sessions edit at once and would mark nearly every image dirty.\n *\n * - A deny-all file (`*` then `!path` re-includes) scopes to its re-includes — a plain one as a path, a\n * wildcard one as a `:(glob)` pathspec, since the build sends what it matches; otherwise the whole\n * context is in scope.\n * - Its `**\\/…` exclusions become git `:(exclude,glob)` pathspecs, as `…/**` so a directory pattern\n * excludes the files under it (a bare `**\\/__tests__` glob matches no file — measured). EXCEPT those\n * under `src/`: the image excludes TypeScript source only because it ships the `dist/` compiled from\n * it, and `dist/` is gitignored — so the source IS the tracked form of what the image carries.\n *\n * Paths are relative to the framework root, where git runs. Pure over the ignore file's text, so a\n * new re-include there widens the scope with no edit here.\n */\nexport function dockerContextSourcePathspecs(frameworkRoot: string, contextPath: string, dockerfilePath: string): string[] {\n const contextRelative = relative(frameworkRoot, contextPath) || '.';\n const ignorePath = [`${dockerfilePath}.dockerignore`, join(contextPath, '.dockerignore')].find((candidate) => existsSync(candidate));\n const lines = ignorePath === undefined ? [] : readFileSync(ignorePath, 'utf8').split('\\n')\n .map((line) => line.trim())\n .filter((line) => line.length > 0 && !line.startsWith('#'));\n const inContext = (path: string): string => (contextRelative === '.' ? path : `${contextRelative}/${path}`);\n const includes = lines.includes('*')\n ? lines\n .filter((line) => line.startsWith('!'))\n .map((line) => (isPlainIgnorePath(line.slice(1)) ? inContext(line.slice(1)) : `:(glob)${inContext(line.slice(1))}`))\n : [contextRelative];\n const excludes = lines\n .filter((line) => line.startsWith('**/') && !line.slice(3).startsWith('src/'))\n .flatMap((line) => [`:(exclude,glob)${line}`, `:(exclude,glob)${line}/**`]);\n return [...(includes.length > 0 ? includes : [contextRelative]), ...excludes];\n}\n\nexport interface FrameworkDockerPublishOptions {\n frameworkRoot?: string;\n targets?: string[];\n dryRun?: boolean;\n /**\n * The IMMUTABLE tag every selected image is published under. Defaults to the\n * framework version.\n *\n * A channel that publishes per-commit supplies its own identity here — e.g.\n * `test-<sha>` — because on that channel the commit, not the version, is what\n * makes the artifact unique. Two pushes of the same framework version from\n * different commits must not collide on one tag.\n */\n immutableTag?: string;\n /**\n * MUTABLE aliases repointed at the image after every immutable push has\n * succeeded — `latest`, `test`, `next`.\n *\n * Kept as one list rather than a boolean per alias: an alias is a pointer, and\n * the set of pointers a channel maintains is channel policy, not a fixed\n * vocabulary this service should enumerate.\n */\n aliasTags?: string[];\n}\n\nexport interface FrameworkDockerPublishTargetResult {\n imageName: string;\n /** `<registry host>/<namespace>/<image>`, with no tag: what a digest reference is written against. */\n imageRepository: string;\n imageRef: string;\n /** The image index digest the push wrote (`containerimage.digest` in buildx's metadata file), once pushed. */\n digest?: string;\n /** What became of the image's signature, once pushed (#3063). */\n signature?: { outcome: FrameworkImageSignatureOutcome; reason?: string };\n aliasImageRefs: string[];\n buildContextPath: string;\n dockerfilePath: string;\n commands: string[];\n}\n\nexport interface FrameworkDockerPublishResult {\n frameworkVersion: string;\n namespace: string;\n targets: FrameworkDockerPublishTargetResult[];\n}\n\ninterface FrameworkDockerBuildContract {\n contextPath: string;\n dockerfilePath: string;\n}\n\ninterface FrameworkDockerBuildDefinition {\n role: WildoFrameworkDockerImageRole;\n variant: WildoFrameworkDockerImageVariant;\n resolveContextPath: (layout: FrameworkLayoutPaths) => string;\n resolveDockerfilePath: (layout: FrameworkLayoutPaths) => string;\n}\n\nconst FRAMEWORK_DOCKER_IMAGE_BUILD_DEFINITIONS: Record<string, FrameworkDockerBuildDefinition> = {\n 'wildo-platform': {\n role: WildoFrameworkDockerImageRole.PLATFORM_SERVICE,\n variant: WildoFrameworkDockerImageVariant.DEFAULT,\n resolveContextPath: (layout) => layout.repositoryRoot,\n resolveDockerfilePath: (layout) => layout.platformBaseDockerfilePath,\n },\n 'wildo-backend-base': {\n role: WildoFrameworkDockerImageRole.APPLICATION_BACKEND,\n variant: WildoFrameworkDockerImageVariant.DEFAULT,\n resolveContextPath: (layout) => layout.repositoryRoot,\n resolveDockerfilePath: (layout) => layout.backendBaseDockerfilePath,\n },\n 'wildo-backend-base-java': {\n role: WildoFrameworkDockerImageRole.APPLICATION_BACKEND,\n variant: WildoFrameworkDockerImageVariant.JAVA,\n resolveContextPath: (layout) => layout.repositoryRoot,\n resolveDockerfilePath: (layout) => layout.backendJavaDockerfilePath,\n },\n};\n\n/**\n * Publishes the framework-owned Docker image contract declared in framework\n * config. Each publishable image must resolve to a truthful framework-owned\n * Dockerfile so the release lane stays explicit about what the framework ships.\n */\n/**\n * The platforms every published framework image is built for, as ONE multi-platform\n * manifest list under the immutable tag.\n *\n * Decided 2026-09-03 (Paul): the Apple-Silicon-versus-x86 split is handled by the\n * registry, never by an operator. A host pulls its native image from the same\n * `docker.io/wildoai/<image>:<version>` reference, so compose files and k8s manifests carry\n * no architecture knowledge. The previous lane built `linux/amd64` only, which put every\n * Apple Silicon developer under emulation and could never produce a native arm64 image.\n *\n * Native modules (argon2, sharp, canvas, esbuild) are installed INSIDE each platform's\n * builder stage, so the binaries match by construction — see `Dockerfile.platform-base`.\n * Building the non-native half runs under QEMU on a laptop; if that becomes too slow the\n * same command moves to a CI matrix with native runners, and this list does not change.\n */\nexport const FRAMEWORK_DOCKER_IMAGE_PLATFORMS = ['linux/amd64', 'linux/arm64'] as const;\n\n/**\n * How long one image build may run, and how many times it is tried (#3063).\n *\n * The arm64 half is built under QEMU, and QEMU can crash the emulated Node process (`qemu: uncaught target\n * signal 4 (Illegal instruction)`) with nothing in the build noticing: the 1.1.13 release (framework-release\n * run 43566115901, 2026-11-14) crashed 103 s into the arm64 `pnpm install`, printed nothing for two hours and\n * was cancelled by GitHub's three-hour job limit, with the version tagged and nothing published. The same\n * step took 3 min 54 s in the 1.1.12 release, from the same base image digest and the same QEMU, so the crash\n * is intermittent, and a second attempt is the remedy.\n *\n * A whole build (both platforms, attestations, push) took 8 min 14 s for 1.1.12, so the bound is generous.\n * Two attempts fit inside the release job's limit with the rest of the lane. A retry cannot release half an\n * image: `buildx build --push` writes the tag only after every platform has built, and the tag is the\n * release's own, which nothing names until the npm step that follows.\n */\nexport const FRAMEWORK_DOCKER_IMAGE_BUILD_TIMEOUT_MS = 50 * 60_000;\nexport const FRAMEWORK_DOCKER_IMAGE_BUILD_ATTEMPTS = 2;\n\nexport class FrameworkDockerPublishService {\n static async publishImages(\n options: FrameworkDockerPublishOptions = {},\n ): Promise<FrameworkDockerPublishResult> {\n const resolvedFrameworkRoot = options.frameworkRoot ?? FrameworkReleaseService.getFrameworkRoot();\n await FrameworkReleaseService.assertCliCompatibility(resolvedFrameworkRoot);\n const dryRun = options.dryRun === true;\n const aliasTags = (options.aliasTags ?? []).map((tag) => tag.trim()).filter((tag) => tag.length > 0);\n const frameworkConfig = await FrameworkDockerPublishService.loadFrameworkConfigOrThrow(\n resolvedFrameworkRoot,\n );\n const immutableTag = options.immutableTag?.trim() || frameworkConfig.frameworkVersion;\n // Read before anything is built, so an unknown value refuses a dry run too rather than surfacing after the push.\n const signing = frameworkImageSigningOf();\n const allTargets = frameworkConfig.publish.docker.images;\n const requestedTargets = new Set(options.targets ?? []);\n const selectedTargets = allTargets.filter(\n (image) => requestedTargets.size === 0 || requestedTargets.has(image.imageName),\n );\n\n FrameworkDockerPublishService.assertLockedDockerRegistryIdentity(\n frameworkConfig.publish.docker.registryHost,\n frameworkConfig.publish.docker.namespace,\n );\n\n if (requestedTargets.size > 0) {\n const missingTargets = [...requestedTargets].filter(\n (target) => !selectedTargets.some((image) => image.imageName === target),\n );\n if (missingTargets.length > 0) {\n throw new Error(`Unknown Docker publish target(s): ${missingTargets.join(', ')}.`);\n }\n }\n\n const result: FrameworkDockerPublishResult = {\n frameworkVersion: frameworkConfig.frameworkVersion,\n namespace: frameworkConfig.publish.docker.namespace,\n targets: selectedTargets.map((image) => {\n const buildContract = FrameworkDockerPublishService.resolveBuildContract(\n resolvedFrameworkRoot,\n image,\n );\n /**\n * Fully qualified, including the registry host. A bare\n * `<namespace>/<image>` reference resolves to Docker Hub by default, so\n * omitting the host would push these images somewhere other than the\n * registry the config declares — silently, and only discoverably by a\n * consumer failing to pull.\n */\n const imageRepository = `${frameworkConfig.publish.docker.registryHost}/${frameworkConfig.publish.docker.namespace}/${image.imageName}`;\n const imageRef = `${imageRepository}:${immutableTag}`;\n const aliasImageRefs = aliasTags.map((tag) => `${imageRepository}:${tag}`);\n\n return {\n imageName: image.imageName,\n imageRepository,\n imageRef,\n aliasImageRefs,\n buildContextPath: FrameworkDockerPublishService.asFrameworkRelativePath(\n resolvedFrameworkRoot,\n buildContract.contextPath,\n ),\n dockerfilePath: FrameworkDockerPublishService.asFrameworkRelativePath(\n resolvedFrameworkRoot,\n buildContract.dockerfilePath,\n ),\n commands: FrameworkDockerPublishService.buildCommandPreview(\n buildContract.contextPath,\n buildContract.dockerfilePath,\n imageRepository,\n imageRef,\n aliasImageRefs,\n { version: immutableTag, sourceUrl: frameworkConfig.publish.npm.repositoryUrl },\n signing,\n ),\n };\n }),\n };\n\n if (dryRun || result.targets.length === 0) {\n return result;\n }\n\n FrameworkDockerPublishService.assertDockerReady();\n FrameworkDockerPublishService.loginWithFrameworkSecrets(resolvedFrameworkRoot, frameworkConfig.publish.docker);\n\n for (const target of result.targets) {\n const configuredTarget = selectedTargets.find((image) => image.imageName === target.imageName);\n if (!configuredTarget) {\n throw new Error(`Missing Docker target definition for \"${target.imageName}\".`);\n }\n const buildContract = FrameworkDockerPublishService.resolveBuildContract(\n resolvedFrameworkRoot,\n configuredTarget,\n );\n\n /*\n * ONE buildx invocation builds every platform in `FRAMEWORK_DOCKER_IMAGE_PLATFORMS` and\n * pushes them as a single manifest list under the immutable tag. A multi-platform result\n * cannot be `--load`ed into the local daemon (it is not one image), which is why this is\n * `--push` rather than the old build-then-push pair. No CLI lane builds into the local daemon\n * since #2988 removed `wildo local up --rebuild`, whose image no runtime ran; the registry host's\n * `--fromCheckout` builds there, on the host's own platform.\n *\n * The push carries the SLSA provenance and SBOM attestations (`FRAMEWORK_IMAGE_ATTESTATION_ARGS`)\n * in the same index, and the OCI labels name the release, the repository, the revision and the\n * build instant (`provenanceLabelArgs`).\n */\n // buildx writes the pushed index's digest here (`containerimage.digest`): what the signature is made over.\n const metadataDir = mkdtempSync(join(tmpdir(), 'wildo-image-metadata-'));\n const metadataFile = join(metadataDir, 'metadata.json');\n try {\n FrameworkDockerPublishService.runDockerBuild('buildx build --push', [\n 'buildx',\n 'build',\n '--platform',\n FRAMEWORK_DOCKER_IMAGE_PLATFORMS.join(','),\n '-f',\n buildContract.dockerfilePath,\n '-t',\n target.imageRef,\n ...FrameworkDockerPublishService.provenanceLabelArgs(\n resolvedFrameworkRoot,\n dockerContextSourcePathspecs(resolvedFrameworkRoot, buildContract.contextPath, buildContract.dockerfilePath),\n { version: immutableTag, sourceUrl: frameworkConfig.publish.npm.repositoryUrl },\n ),\n ...FRAMEWORK_IMAGE_ATTESTATION_ARGS,\n '--metadata-file',\n metadataFile,\n '--push',\n buildContract.contextPath,\n ]);\n target.digest = FrameworkDockerPublishService.pushedDigestOf(metadataFile);\n } finally {\n rmSync(metadataDir, { recursive: true, force: true });\n }\n }\n\n /*\n * Aliases are repointed only after EVERY immutable push has succeeded.\n *\n * The previous shape moved each image's alias inside the per-image loop, so\n * a failure on image N left images 1..N-1 already advertising the new\n * release through `latest` while the release as a whole had not happened —\n * a partial release that looks complete to anyone pulling the alias. With\n * one image in the publish set that was unobservable; it returns the moment\n * a second image is re-added, which is exactly when nobody would be looking\n * for it.\n */\n for (const target of result.targets) {\n for (const aliasRef of target.aliasImageRefs) {\n // `imagetools create` repoints the alias at the whole MANIFEST LIST in the registry, its\n // attestation manifests included; a local `docker tag` + `push` would only ever carry the one\n // platform the daemon holds, and no attestation.\n FrameworkDockerPublishService.runDockerCommand('imagetools create alias', [\n 'buildx',\n 'imagetools',\n 'create',\n '-t',\n aliasRef,\n target.imageRef,\n ]);\n }\n }\n\n // Signed by digest once every image is pushed; see FrameworkImageSigning.COSIGN_KEYLESS for what that covers.\n for (const target of result.targets) {\n target.signature = FrameworkDockerPublishService.signImage(target, signing);\n }\n\n return result;\n }\n\n /** The image index digest buildx recorded in its metadata file, or undefined when it recorded none. */\n static pushedDigestOf(metadataFile: string): string | undefined {\n try {\n const metadata = JSON.parse(readFileSync(metadataFile, 'utf8')) as Record<string, unknown>;\n const digest = metadata['containerimage.digest'];\n return typeof digest === 'string' && /^sha256:[0-9a-f]{64}$/.test(digest) ? digest : undefined;\n } catch {\n return undefined;\n }\n }\n\n /**\n * Sign one pushed image as the environment asks (#3063). Never throws: the image is already public, so a signature\n * that cannot be made is reported (FAILED, with the command to run by hand) rather than stopping the release after it\n * published, and a consumer's `cosign verify` sees it missing rather than being told anything false.\n *\n * cosign reads the registry credentials `docker login` wrote (`loginWithFrameworkSecrets`), and in GitHub Actions takes\n * the job's OIDC token on its own (`id-token: write`). SIGNED means the signature then VERIFIED against this job's\n * workflow identity (`cosign verify`), so the outcome is the registry's answer rather than the signing command's exit.\n */\n static signImage(\n target: Pick<FrameworkDockerPublishTargetResult, 'imageRepository' | 'digest'>,\n signing: FrameworkImageSigning | undefined,\n spawn: typeof spawnSync = spawnSync,\n env: NodeJS.ProcessEnv = process.env,\n ): NonNullable<FrameworkDockerPublishTargetResult['signature']> {\n if (signing === undefined) return { outcome: FrameworkImageSignatureOutcome.NOT_REQUESTED };\n if (!target.digest) {\n return { outcome: FrameworkImageSignatureOutcome.FAILED, reason: `buildx recorded no digest for ${target.imageRepository}; sign it by hand: cosign sign --yes ${target.imageRepository}@<digest>` };\n }\n const reference = `${target.imageRepository}@${target.digest}`;\n const identity = githubWorkflowSigningIdentityOf(env);\n if (!identity) {\n return { outcome: FrameworkImageSignatureOutcome.FAILED, reason: `keyless signing needs a GitHub Actions workload identity (GITHUB_WORKFLOW_REF is unset); sign it by hand: cosign sign --yes ${reference}` };\n }\n const failed = (step: string, run: ReturnType<typeof spawnSync>) =>\n `${step}: ${run.error ? run.error.message : `cosign exited ${run.status ?? 'without a status'}`}`;\n const signed = spawn('cosign', ['sign', '--yes', reference], { encoding: 'utf8', stdio: 'inherit' });\n if (signed.status !== 0) {\n return { outcome: FrameworkImageSignatureOutcome.FAILED, reason: `${failed('cosign sign', signed)}; sign it by hand: cosign sign --yes ${reference}` };\n }\n const verifyArgs = ['verify', '--certificate-identity', identity, '--certificate-oidc-issuer', GITHUB_ACTIONS_OIDC_ISSUER, reference];\n const verified = spawn('cosign', verifyArgs, { encoding: 'utf8', stdio: 'inherit' });\n if (verified.status !== 0) {\n return { outcome: FrameworkImageSignatureOutcome.FAILED, reason: `${failed('signed, but cosign verify', verified)}; check it with: cosign ${verifyArgs.join(' ')}` };\n }\n return { outcome: FrameworkImageSignatureOutcome.SIGNED };\n }\n\n /**\n * Log the Docker CLI in to the framework's registry with `docker.publishToken` from the framework secrets file.\n *\n * Every step that WRITES to the registry calls it itself: the image push, and moving the `latest` alias\n * (`wildo fwk publish all` step 8). A resumed release (`--skipDocker`) skips the push, so an alias move that relied\n * on the push's login ran unauthenticated: on a developer machine an earlier `docker login` hid that, and on a fresh\n * CI runner Docker Hub answered 401 (framework-release run 43278280537, 2026-11-12, #3063).\n *\n * @param frameworkRoot the framework checkout whose secrets file and release config are read\n */\n static async loginToRegistry(frameworkRoot: string): Promise<void> {\n const frameworkConfig = await FrameworkDockerPublishService.loadFrameworkConfigOrThrow(frameworkRoot);\n FrameworkDockerPublishService.loginWithFrameworkSecrets(frameworkRoot, frameworkConfig.publish.docker);\n }\n\n /** The login itself; `docker` gives the registry host, and the namespace used as the username when the secrets name none. */\n private static loginWithFrameworkSecrets(frameworkRoot: string, docker: { registryHost: string; namespace: string }): void {\n const secrets = FrameworkReleaseService.loadFrameworkDockerSecrets(frameworkRoot);\n const publishToken = secrets?.publishToken ?? null;\n if (!publishToken) {\n throw new Error(`Docker publish requires docker.publishToken in ${FrameworkReleaseService.resolveFrameworkSecretsPath(frameworkRoot)}.`);\n }\n FrameworkDockerPublishService.runDockerLogin(docker.registryHost, secrets?.publishUsername ?? docker.namespace, publishToken);\n }\n\n private static async loadFrameworkConfigOrThrow(frameworkRoot: string) {\n const frameworkConfig = await FrameworkReleaseService.loadFrameworkConfig(frameworkRoot);\n if (!frameworkConfig) {\n throw new Error(\n `Framework release config not found at ${FrameworkReleaseService.resolveFrameworkConfigPath(frameworkRoot)}`,\n );\n }\n return frameworkConfig;\n }\n\n private static resolveBuildContract(\n frameworkRoot: string,\n target: WildoFrameworkReleaseDockerImage,\n ): FrameworkDockerBuildContract {\n const buildDefinition = FRAMEWORK_DOCKER_IMAGE_BUILD_DEFINITIONS[target.imageName];\n if (!buildDefinition) {\n throw new Error(\n `Docker publish target \"${target.imageName}\" is not mapped to a framework Dockerfile yet.`,\n );\n }\n if (buildDefinition.role !== target.role || buildDefinition.variant !== target.variant) {\n throw new Error(\n `Docker publish target \"${target.imageName}\" must use ${buildDefinition.role}/${buildDefinition.variant}.`,\n );\n }\n\n const frameworkLayout = resolveFrameworkLayout(frameworkRoot);\n const contextPath = buildDefinition.resolveContextPath(frameworkLayout);\n const dockerfilePath = buildDefinition.resolveDockerfilePath(frameworkLayout);\n\n if (!existsSync(dockerfilePath)) {\n throw new Error(\n `Dockerfile for \"${target.imageName}\" not found at ${dockerfilePath}.`,\n );\n }\n\n return { contextPath, dockerfilePath };\n }\n\n /**\n * Both halves of the published image identity are locked, not just the\n * namespace. The registry host is the half that used to be implicit, and an\n * unlocked host is the more dangerous of the two: a wrong namespace fails\n * loudly on push permissions, while a wrong host can succeed and publish the\n * framework to a registry nobody is watching.\n */\n private static assertLockedDockerRegistryIdentity(registryHost: string, namespace: string): void {\n if (registryHost !== FRAMEWORK_RELEASE_DOCKER_REGISTRY_HOST) {\n throw new Error(\n `Docker publish currently supports only the locked registry host \"${FRAMEWORK_RELEASE_DOCKER_REGISTRY_HOST}\".`,\n );\n }\n if (namespace !== FRAMEWORK_RELEASE_DOCKER_NAMESPACE) {\n throw new Error(\n `Docker publish currently supports only the locked namespace \"${FRAMEWORK_RELEASE_DOCKER_NAMESPACE}\".`,\n );\n }\n }\n\n /**\n * The OCI labels stamped on every pushed image: the release it is (`identity.version`, the immutable\n * tag), the repository it comes from (`identity.sourceUrl`), the source revision and the build instant.\n *\n * Read back by `fwk publish all --skipDocker`, which resumes a release whose image is already pushed:\n * existence proves the tag is there, not that it was built from the source now being published, so the\n * resume prints what the image was built from and how many commits touched its inputs since. The\n * revision is HEAD, marked `-dirty` when the image's own inputs (`sourcePathspecs`) held uncommitted\n * edits or untracked files — the image then carries content no commit has. Edits elsewhere in the\n * shared tree do not mark it.\n *\n * The version is the immutable tag even when it is not a semver version (`test-<sha>` on a per-commit\n * channel): it is the one reference that always resolves to this image, so it is what the label names.\n */\n private static provenanceLabelArgs(\n frameworkRoot: string,\n sourcePathspecs: string[],\n identity: FrameworkImageIdentity,\n ): string[] {\n const labels = [\n '--label', `${FRAMEWORK_IMAGE_VERSION_LABEL}=${identity.version}`,\n '--label', `${FRAMEWORK_IMAGE_SOURCE_LABEL}=${identity.sourceUrl}`,\n '--label', `${FRAMEWORK_IMAGE_CREATED_LABEL}=${new Date().toISOString()}`,\n ];\n const head = spawnSync('git', ['rev-parse', 'HEAD'], { cwd: frameworkRoot, encoding: 'utf8' });\n if (head.status === 0 && head.stdout.trim()) {\n const status = spawnSync('git', ['status', '--porcelain', '--untracked-files=all', '--', ...sourcePathspecs], { cwd: frameworkRoot, encoding: 'utf8' });\n const dirty = status.status !== 0 || status.stdout.trim() !== '';\n labels.push('--label', `${FRAMEWORK_IMAGE_REVISION_LABEL}=${head.stdout.trim()}${dirty ? '-dirty' : ''}`);\n }\n return labels;\n }\n\n /**\n * The source pathspecs of a configured image, by name — what `fwk publish all --skipDocker` asks git\n * about. `null` for an image this lane has no build definition for.\n */\n static imageSourcePathspecs(frameworkRoot: string, imageName: string): string[] | null {\n const buildDefinition = FRAMEWORK_DOCKER_IMAGE_BUILD_DEFINITIONS[imageName];\n if (!buildDefinition) return null;\n const frameworkLayout = resolveFrameworkLayout(frameworkRoot);\n return dockerContextSourcePathspecs(\n frameworkRoot,\n buildDefinition.resolveContextPath(frameworkLayout),\n buildDefinition.resolveDockerfilePath(frameworkLayout),\n );\n }\n\n private static buildCommandPreview(\n contextPath: string,\n dockerfilePath: string,\n imageRepository: string,\n imageRef: string,\n aliasImageRefs: string[],\n identity: FrameworkImageIdentity,\n signing: FrameworkImageSigning | undefined,\n ): string[] {\n return [\n `docker buildx build --platform ${FRAMEWORK_DOCKER_IMAGE_PLATFORMS.join(',')} -f \"${dockerfilePath}\" -t \"${imageRef}\" --label ${FRAMEWORK_IMAGE_VERSION_LABEL}=${identity.version} --label ${FRAMEWORK_IMAGE_SOURCE_LABEL}=${identity.sourceUrl} --label ${FRAMEWORK_IMAGE_CREATED_LABEL}=<build instant> --label ${FRAMEWORK_IMAGE_REVISION_LABEL}=<HEAD>[-dirty] ${FRAMEWORK_IMAGE_ATTESTATION_ARGS.join(' ')} --metadata-file <tmp> --push \"${contextPath}\"`,\n ...aliasImageRefs.map((aliasRef) => `docker buildx imagetools create -t \"${aliasRef}\" \"${imageRef}\"`),\n ...(signing === FrameworkImageSigning.COSIGN_KEYLESS\n ? [`cosign sign --yes \"${imageRepository}@<pushed digest>\"`, `cosign verify --certificate-identity <this workflow> --certificate-oidc-issuer ${GITHUB_ACTIONS_OIDC_ISSUER} \"${imageRepository}@<pushed digest>\"`]\n : []),\n ];\n }\n\n private static asFrameworkRelativePath(frameworkRoot: string, absolutePath: string): string {\n return relative(frameworkRoot, absolutePath) || '.';\n }\n\n private static assertDockerReady(): void {\n const dockerState = DockerUtils.checkDockerRunning();\n if (!dockerState.available || !dockerState.running) {\n throw new Error(dockerState.error ?? 'Docker must be running to publish framework images.');\n }\n }\n\n /**\n * `docker login` with no host argument authenticates against Docker Hub, so\n * the registry host must be passed explicitly or the credential is sent to\n * the wrong registry and the later push fails as unauthenticated.\n */\n private static runDockerLogin(registryHost: string, username: string, publishToken: string): void {\n const loginResult = spawnSync(\n 'docker',\n ['login', registryHost, '--username', username, '--password-stdin'],\n {\n input: publishToken,\n encoding: 'utf8',\n stdio: ['pipe', 'inherit', 'inherit'],\n },\n );\n if (loginResult.status !== 0) {\n throw new Error(`Docker login failed for username \"${username}\" at ${registryHost}.`);\n }\n }\n\n /**\n * Run one image build, bounded by `FRAMEWORK_DOCKER_IMAGE_BUILD_TIMEOUT_MS` and tried\n * `FRAMEWORK_DOCKER_IMAGE_BUILD_ATTEMPTS` times. A build that runs out of time is killed (SIGTERM ends the buildx\n * client, and BuildKit cancels the build when its session closes). Every failure says which attempt it was and\n * why, so a release log shows a hang as a hang rather than as silence.\n */\n static runDockerBuild(\n label: string,\n args: string[],\n spawn: typeof spawnSync = spawnSync,\n log: (message: string) => void = (message) => console.error(message),\n ): void {\n const minutes = Math.round(FRAMEWORK_DOCKER_IMAGE_BUILD_TIMEOUT_MS / 60_000);\n for (let attempt = 1; attempt <= FRAMEWORK_DOCKER_IMAGE_BUILD_ATTEMPTS; attempt += 1) {\n const result = spawn('docker', args, { encoding: 'utf8', stdio: 'inherit', timeout: FRAMEWORK_DOCKER_IMAGE_BUILD_TIMEOUT_MS });\n if (result.status === 0) return;\n const timedOut = (result.error as NodeJS.ErrnoException | undefined)?.code === 'ETIMEDOUT';\n const reason = timedOut\n ? `it ran out of its ${minutes} minutes (an emulated platform can hang without a word)`\n : result.signal\n ? `it was ended by ${result.signal}`\n : `it exited ${result.status ?? 'without a status'}`;\n const last = attempt === FRAMEWORK_DOCKER_IMAGE_BUILD_ATTEMPTS;\n log(`Docker ${label}, attempt ${attempt} of ${FRAMEWORK_DOCKER_IMAGE_BUILD_ATTEMPTS}: ${reason}.${last ? '' : ' Trying again.'}`);\n if (last) throw new Error(`Docker ${label} failed after ${FRAMEWORK_DOCKER_IMAGE_BUILD_ATTEMPTS} attempts: ${reason}.`);\n }\n }\n\n private static runDockerCommand(label: string, args: string[]): void {\n const result = spawnSync('docker', args, {\n encoding: 'utf8',\n stdio: 'inherit',\n });\n if (result.status !== 0) {\n throw new Error(`Docker ${label} failed.`);\n }\n }\n}\n"]}
1
+ {"version":3,"file":"framework-docker-publish.service.js","sourceRoot":"","sources":["../../../../src/services/framework/framework-docker-publish.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AAC5B,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AACtC,OAAO,EACL,sBAAsB,EACtB,6BAA6B,EAC7B,gCAAgC,GAGjC,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,kCAAkC,EAClC,sCAAsC,GACvC,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,uBAAuB,EAAE,MAAM,yDAAyD,CAAC;AAClG,OAAO,EAAE,WAAW,EAAE,MAAM,sDAAsD,CAAC;AAEnF,iIAAiI;AACjI,MAAM,CAAC,MAAM,8BAA8B,GAAG,mCAAmC,CAAC;AAClF,MAAM,CAAC,MAAM,6BAA6B,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CAAC,CAAC;YACpC,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;gBAC1B,YAAY,CAAC,KAAK,CAAC,CAAC;gBACpB,OAAO,CAAC,EAAE,IAAI,EAAE,yBAAyB,CAAC,YAAY,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;YACpF,CAAC,CAAC,CAAC;YACH,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE;gBACnC,YAAY,CAAC,KAAK,CAAC,CAAC;gBACpB,IAAI,KAAK;oBAAE,OAAO,CAAC,KAAK,CAAC,CAAC;qBACrB,IAAI,MAAM,KAAK,CAAC;oBAAE,OAAO,CAAC,EAAE,IAAI,EAAE,yBAAyB,CAAC,SAAS,EAAE,CAAC,CAAC;;oBACzE,OAAO,CAAC,EAAE,IAAI,EAAE,yBAAyB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;YAC3E,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;IAEO,MAAM,CAAC,gBAAgB,CAAC,KAAa,EAAE,IAAc;QAC3D,MAAM,MAAM,GAAG,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE;YACvC,QAAQ,EAAE,MAAM;YAChB,KAAK,EAAE,SAAS;SACjB,CAAC,CAAC;QACH,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACxB,MAAM,IAAI,KAAK,CAAC,UAAU,KAAK,UAAU,CAAC,CAAC;QAC7C,CAAC;IACH,CAAC;CACF","sourcesContent":["import { spawn, spawnSync } from 'child_process';\nimport { existsSync, mkdtempSync, readFileSync, rmSync } from 'fs';\nimport { tmpdir } from 'os';\nimport { join, relative } from 'path';\nimport {\n resolveFrameworkLayout,\n WildoFrameworkDockerImageRole,\n WildoFrameworkDockerImageVariant,\n type FrameworkLayoutPaths,\n type WildoFrameworkReleaseDockerImage,\n} from '@wildo-ai/platform-config-lib';\nimport {\n FRAMEWORK_RELEASE_DOCKER_NAMESPACE,\n FRAMEWORK_RELEASE_DOCKER_REGISTRY_HOST,\n} from '@wildo-ai/platform-config-lib';\nimport { FrameworkReleaseService } from '~wildo-cli/services/framework/framework-release.service';\nimport { DockerUtils } from '~wildo-cli/services/deployment/docker/docker.service';\n\n/** OCI annotation keys (image-spec `annotations.md`, dead-plan-citation: the OCI spec's own file), used here as build labels. */\nexport const FRAMEWORK_IMAGE_REVISION_LABEL = 'org.opencontainers.image.revision';\nexport const FRAMEWORK_IMAGE_CREATED_LABEL = 'org.opencontainers.image.created';\n/**\n * The release the image IS: the immutable tag it is pushed under (the framework version, or a channel's\n * own identity such as `test-<sha>`), so an image pulled by an alias or by digest still names its release.\n */\nexport const FRAMEWORK_IMAGE_VERSION_LABEL = 'org.opencontainers.image.version';\n/** The repository the image is built from: the framework config's `publish.npm.repositoryUrl`. */\nexport const FRAMEWORK_IMAGE_SOURCE_LABEL = 'org.opencontainers.image.source';\n\n/**\n * The BuildKit attestations pushed beside every framework image, inside the same image index: SLSA\n * provenance in `max` mode (the full build definition: Dockerfile, build args, source materials) and an\n * SPDX SBOM of each platform's filesystem. Registries and scanners (Docker Scout, `docker buildx\n * imagetools inspect --format '{{json .Provenance}}'`/`'{{json .SBOM}}'`) read them from there, and\n * `imagetools create` carries them along when an alias is repointed at the index.\n */\nexport const FRAMEWORK_IMAGE_ATTESTATION_ARGS = ['--provenance=mode=max', '--sbom=true'] as const;\n\n/**\n * How a pushed framework image is signed (#3063). Chosen by the environment that runs the lane, never by the lane\n * itself: keyless signing needs a workload identity (the release job's GitHub OIDC token), which a developer machine\n * running the break-glass `wildo fwk release` does not have.\n */\nexport enum FrameworkImageSigning {\n /**\n * `cosign sign --yes <repository>@<digest>`: a short-lived Fulcio certificate bound to the release workflow's identity,\n * the signature recorded in the Rekor transparency log and stored beside the image index in the registry, then\n * `cosign verify` against that identity. Signs the DIGEST of the index buildx pushed, never a tag, so what is signed is\n * exactly what was built. An alias (`latest`) is covered only while it names that same index: `imagetools create` from\n * one index source keeps the index as it is, so its digest is the signed one.\n *\n * The certificate puts the repository, the workflow, its ref, the commit and the run in the public Rekor log for good.\n * The image's own OCI labels already publish the source URL and the revision.\n */\n COSIGN_KEYLESS = 'cosign_keyless',\n}\n\n/** The environment variable a release environment sets to a {@link FrameworkImageSigning} member. Unset: no signing. */\nexport const FRAMEWORK_IMAGE_SIGNING_ENV = 'WILDO_FRAMEWORK_IMAGE_SIGNING';\n\n/** The OIDC issuer of a GitHub Actions workload identity: the issuer of every keyless certificate the release signs with. */\nexport const GITHUB_ACTIONS_OIDC_ISSUER = 'https://token.actions.githubusercontent.com';\n\n/**\n * The identity a keyless signature made in this job carries, as `cosign verify --certificate-identity` takes it:\n * `https://github.com/<owner>/<repo>/<workflow path>@<ref>`, from `GITHUB_WORKFLOW_REF`. Undefined outside Actions.\n */\nexport function githubWorkflowSigningIdentityOf(env: NodeJS.ProcessEnv = process.env): string | undefined {\n const workflowRef = env.GITHUB_WORKFLOW_REF?.trim();\n return workflowRef ? `${env.GITHUB_SERVER_URL?.trim() || 'https://github.com'}/${workflowRef}` : undefined;\n}\n\n/** What became of one image's signature. */\nexport enum FrameworkImageSignatureOutcome {\n /** Signed by digest. */\n SIGNED = 'signed',\n /** The environment asked for no signing (a developer machine running the break-glass release). */\n NOT_REQUESTED = 'not_requested',\n /**\n * Asked for and not proven: no workload identity to sign as (`GITHUB_WORKFLOW_REF` unset), the pushed digest unreadable,\n * cosign absent or refusing to sign, or a signature made that `cosign verify` did not confirm. The image is already public, so\n * the release does not stop on it (a consumer's `cosign verify` reports the missing signature, a false claim is not\n * made); the lane reports it, and the image is signed by hand with the command named in `reason`.\n */\n FAILED = 'failed',\n}\n\n/** The signing the environment asks for, or undefined. An unknown value is refused, never read as \"no signing\". */\nexport function frameworkImageSigningOf(env: NodeJS.ProcessEnv = process.env): FrameworkImageSigning | undefined {\n const raw = env[FRAMEWORK_IMAGE_SIGNING_ENV]?.trim();\n if (!raw) return undefined;\n if (!(Object.values(FrameworkImageSigning) as string[]).includes(raw)) {\n throw new Error(`${FRAMEWORK_IMAGE_SIGNING_ENV}=\"${raw}\" names no image signing; expected one of: ${Object.values(FrameworkImageSigning).join(', ')}.`);\n }\n return raw as FrameworkImageSigning;\n}\n\n/** What the identity labels say: the release and the repository it was built from. */\ninterface FrameworkImageIdentity {\n version: string;\n sourceUrl: string;\n}\n\n/** A `.dockerignore` pattern that names no wildcard — a plain path, rather than a glob pathspec. */\nfunction isPlainIgnorePath(pattern: string): boolean {\n return !/[*?[\\]]/.test(pattern);\n}\n\n/**\n * The git pathspecs covering what a Docker build SENDS from its context, derived from the ignore file\n * the build itself obeys: `<Dockerfile>.dockerignore` when present (BuildKit prefers it), else the\n * context's `.dockerignore`. What the image was built from is then asked of those paths only — whether\n * they were dirty at build time, and how many commits touched them since — instead of the whole\n * repository, which several sessions edit at once and would mark nearly every image dirty.\n *\n * - A deny-all file (`*` then `!path` re-includes) scopes to its re-includes — a plain one as a path, a\n * wildcard one as a `:(glob)` pathspec, since the build sends what it matches; otherwise the whole\n * context is in scope.\n * - Its `**\\/…` exclusions become git `:(exclude,glob)` pathspecs, as `…/**` so a directory pattern\n * excludes the files under it (a bare `**\\/__tests__` glob matches no file — measured). EXCEPT those\n * under `src/`: the image excludes TypeScript source only because it ships the `dist/` compiled from\n * it, and `dist/` is gitignored — so the source IS the tracked form of what the image carries.\n *\n * Paths are relative to the framework root, where git runs. Pure over the ignore file's text, so a\n * new re-include there widens the scope with no edit here.\n */\nexport function dockerContextSourcePathspecs(frameworkRoot: string, contextPath: string, dockerfilePath: string): string[] {\n const contextRelative = relative(frameworkRoot, contextPath) || '.';\n const ignorePath = [`${dockerfilePath}.dockerignore`, join(contextPath, '.dockerignore')].find((candidate) => existsSync(candidate));\n const lines = ignorePath === undefined ? [] : readFileSync(ignorePath, 'utf8').split('\\n')\n .map((line) => line.trim())\n .filter((line) => line.length > 0 && !line.startsWith('#'));\n const inContext = (path: string): string => (contextRelative === '.' ? path : `${contextRelative}/${path}`);\n const includes = lines.includes('*')\n ? lines\n .filter((line) => line.startsWith('!'))\n .map((line) => (isPlainIgnorePath(line.slice(1)) ? inContext(line.slice(1)) : `:(glob)${inContext(line.slice(1))}`))\n : [contextRelative];\n const excludes = lines\n .filter((line) => line.startsWith('**/') && !line.slice(3).startsWith('src/'))\n .flatMap((line) => [`:(exclude,glob)${line}`, `:(exclude,glob)${line}/**`]);\n return [...(includes.length > 0 ? includes : [contextRelative]), ...excludes];\n}\n\nexport interface FrameworkDockerPublishOptions {\n frameworkRoot?: string;\n targets?: string[];\n dryRun?: boolean;\n /**\n * The IMMUTABLE tag every selected image is published under. Defaults to the\n * framework version.\n *\n * A channel that publishes per-commit supplies its own identity here — e.g.\n * `test-<sha>` — because on that channel the commit, not the version, is what\n * makes the artifact unique. Two pushes of the same framework version from\n * different commits must not collide on one tag.\n */\n immutableTag?: string;\n /**\n * MUTABLE aliases repointed at the image after every immutable push has\n * succeeded — `latest`, `test`, `next`.\n *\n * Kept as one list rather than a boolean per alias: an alias is a pointer, and\n * the set of pointers a channel maintains is channel policy, not a fixed\n * vocabulary this service should enumerate.\n */\n aliasTags?: string[];\n}\n\nexport interface FrameworkDockerPublishTargetResult {\n imageName: string;\n /** `<registry host>/<namespace>/<image>`, with no tag: what a digest reference is written against. */\n imageRepository: string;\n imageRef: string;\n /** The image index digest the push wrote (`containerimage.digest` in buildx's metadata file), once pushed. */\n digest?: string;\n /** What became of the image's signature, once pushed (#3063). */\n signature?: { outcome: FrameworkImageSignatureOutcome; reason?: string };\n aliasImageRefs: string[];\n buildContextPath: string;\n dockerfilePath: string;\n commands: string[];\n}\n\nexport interface FrameworkDockerPublishResult {\n frameworkVersion: string;\n namespace: string;\n targets: FrameworkDockerPublishTargetResult[];\n}\n\ninterface FrameworkDockerBuildContract {\n contextPath: string;\n dockerfilePath: string;\n}\n\ninterface FrameworkDockerBuildDefinition {\n role: WildoFrameworkDockerImageRole;\n variant: WildoFrameworkDockerImageVariant;\n resolveContextPath: (layout: FrameworkLayoutPaths) => string;\n resolveDockerfilePath: (layout: FrameworkLayoutPaths) => string;\n}\n\nconst FRAMEWORK_DOCKER_IMAGE_BUILD_DEFINITIONS: Record<string, FrameworkDockerBuildDefinition> = {\n 'wildo-platform': {\n role: WildoFrameworkDockerImageRole.PLATFORM_SERVICE,\n variant: WildoFrameworkDockerImageVariant.DEFAULT,\n resolveContextPath: (layout) => layout.repositoryRoot,\n resolveDockerfilePath: (layout) => layout.platformBaseDockerfilePath,\n },\n 'wildo-backend-base': {\n role: WildoFrameworkDockerImageRole.APPLICATION_BACKEND,\n variant: WildoFrameworkDockerImageVariant.DEFAULT,\n resolveContextPath: (layout) => layout.repositoryRoot,\n resolveDockerfilePath: (layout) => layout.backendBaseDockerfilePath,\n },\n 'wildo-backend-base-java': {\n role: WildoFrameworkDockerImageRole.APPLICATION_BACKEND,\n variant: WildoFrameworkDockerImageVariant.JAVA,\n resolveContextPath: (layout) => layout.repositoryRoot,\n resolveDockerfilePath: (layout) => layout.backendJavaDockerfilePath,\n },\n};\n\n/**\n * Publishes the framework-owned Docker image contract declared in framework\n * config. Each publishable image must resolve to a truthful framework-owned\n * Dockerfile so the release lane stays explicit about what the framework ships.\n */\n/**\n * The platforms every published framework image is built for, as ONE multi-platform\n * manifest list under the immutable tag.\n *\n * Decided 2026-09-03 (Paul): the Apple-Silicon-versus-x86 split is handled by the\n * registry, never by an operator. A host pulls its native image from the same\n * `docker.io/wildoai/<image>:<version>` reference, so compose files and k8s manifests carry\n * no architecture knowledge. The previous lane built `linux/amd64` only, which put every\n * Apple Silicon developer under emulation and could never produce a native arm64 image.\n *\n * Native modules (argon2, sharp, canvas, esbuild) are installed INSIDE each platform's\n * builder stage, so the binaries match by construction — see `Dockerfile.platform-base`.\n * Building the non-native half runs under QEMU on a laptop; if that becomes too slow the\n * same command moves to a CI matrix with native runners, and this list does not change.\n */\nexport const FRAMEWORK_DOCKER_IMAGE_PLATFORMS = ['linux/amd64', 'linux/arm64'] as const;\n\n/**\n * How long one image build may run, and how many times it is tried (#3063, #3963).\n *\n * The arm64 half is built under QEMU, and QEMU can crash the emulated Node process (`qemu: uncaught target\n * signal 4 (Illegal instruction)`) with nothing in the build noticing: the 1.1.13 release (framework-release\n * run 43566115901, 2026-11-14) crashed 103 s into the arm64 `pnpm install`, printed nothing for two hours and\n * was cancelled by GitHub's three-hour job limit, with the version tagged and nothing published. The crash is\n * intermittent (same base image digest, same QEMU), and FREQUENT: the 1.1.14 release (run 43853716196,\n * 2026-11-16) crashed on both of its two attempts, so 3 of the 4 arm64 attempts then recorded crashed.\n *\n * So an attempt ends the moment QEMU reports the crash (`QEMU_CRASH_PATTERN`) and is tried again, which costs\n * about two minutes rather than the whole bound. The bound stays for a build that hangs WITHOUT that line, and\n * at most `FRAMEWORK_DOCKER_IMAGE_BUILD_TIMEOUTS` attempts may run it out: the worst case is the two silent\n * 50-minute attempts the lane already allowed, which fit inside the release job's limit with the rest of the\n * lane. A whole build (both platforms, attestations, push) took 8 min 14 s for 1.1.12.\n *\n * A retry cannot release half an image: `buildx build --push` writes the tag only after every platform has\n * built, and the tag is the release's own, which nothing names until the npm step that follows.\n */\nexport const FRAMEWORK_DOCKER_IMAGE_BUILD_TIMEOUT_MS = 50 * 60_000;\nexport const FRAMEWORK_DOCKER_IMAGE_BUILD_ATTEMPTS = 4;\nexport const FRAMEWORK_DOCKER_IMAGE_BUILD_TIMEOUTS = 2;\n\n/**\n * What QEMU prints when an emulated process dies of a signal nothing handled. A process that probes a CPU\n * feature by catching SIGILL (OpenSSL does) never produces it, because the signal is caught; this line means\n * an emulated process is DEAD, and in every recorded instance the build then hung without another word. It\n * appears in none of the successful release logs read (#3963), so ending the attempt on it cannot end a build\n * that would have finished.\n */\nexport const QEMU_CRASH_PATTERN = /qemu: uncaught target signal \\d+/;\n\n/**\n * How one image build attempt ended (#3963). Only `SUCCEEDED` ends the build; `TIMED_OUT` counts against\n * `FRAMEWORK_DOCKER_IMAGE_BUILD_TIMEOUTS`; `SPAWN_FAILED` (docker itself could not start) is not retried, since\n * a second start would fail the same way; the rest are tried again.\n */\nexport enum DockerBuildAttemptOutcome {\n /** buildx exited 0: every platform built and the index was pushed. */\n SUCCEEDED = 'succeeded',\n /** The attempt ran out of `FRAMEWORK_DOCKER_IMAGE_BUILD_TIMEOUT_MS` and was ended. */\n TIMED_OUT = 'timed-out',\n /** QEMU printed `QEMU_CRASH_PATTERN`, and the attempt was ended without waiting for the bound. */\n EMULATOR_CRASHED = 'emulator-crashed',\n /** The `docker` process could not be started at all. */\n SPAWN_FAILED = 'spawn-failed',\n /** buildx exited non-zero, or was ended by a signal this lane did not send. */\n FAILED = 'failed',\n}\n\nexport class FrameworkDockerPublishService {\n static async publishImages(\n options: FrameworkDockerPublishOptions = {},\n ): Promise<FrameworkDockerPublishResult> {\n const resolvedFrameworkRoot = options.frameworkRoot ?? FrameworkReleaseService.getFrameworkRoot();\n await FrameworkReleaseService.assertCliCompatibility(resolvedFrameworkRoot);\n const dryRun = options.dryRun === true;\n const aliasTags = (options.aliasTags ?? []).map((tag) => tag.trim()).filter((tag) => tag.length > 0);\n const frameworkConfig = await FrameworkDockerPublishService.loadFrameworkConfigOrThrow(\n resolvedFrameworkRoot,\n );\n const immutableTag = options.immutableTag?.trim() || frameworkConfig.frameworkVersion;\n // Read before anything is built, so an unknown value refuses a dry run too rather than surfacing after the push.\n const signing = frameworkImageSigningOf();\n const allTargets = frameworkConfig.publish.docker.images;\n const requestedTargets = new Set(options.targets ?? []);\n const selectedTargets = allTargets.filter(\n (image) => requestedTargets.size === 0 || requestedTargets.has(image.imageName),\n );\n\n FrameworkDockerPublishService.assertLockedDockerRegistryIdentity(\n frameworkConfig.publish.docker.registryHost,\n frameworkConfig.publish.docker.namespace,\n );\n\n if (requestedTargets.size > 0) {\n const missingTargets = [...requestedTargets].filter(\n (target) => !selectedTargets.some((image) => image.imageName === target),\n );\n if (missingTargets.length > 0) {\n throw new Error(`Unknown Docker publish target(s): ${missingTargets.join(', ')}.`);\n }\n }\n\n const result: FrameworkDockerPublishResult = {\n frameworkVersion: frameworkConfig.frameworkVersion,\n namespace: frameworkConfig.publish.docker.namespace,\n targets: selectedTargets.map((image) => {\n const buildContract = FrameworkDockerPublishService.resolveBuildContract(\n resolvedFrameworkRoot,\n image,\n );\n /**\n * Fully qualified, including the registry host. A bare\n * `<namespace>/<image>` reference resolves to Docker Hub by default, so\n * omitting the host would push these images somewhere other than the\n * registry the config declares — silently, and only discoverably by a\n * consumer failing to pull.\n */\n const imageRepository = `${frameworkConfig.publish.docker.registryHost}/${frameworkConfig.publish.docker.namespace}/${image.imageName}`;\n const imageRef = `${imageRepository}:${immutableTag}`;\n const aliasImageRefs = aliasTags.map((tag) => `${imageRepository}:${tag}`);\n\n return {\n imageName: image.imageName,\n imageRepository,\n imageRef,\n aliasImageRefs,\n buildContextPath: FrameworkDockerPublishService.asFrameworkRelativePath(\n resolvedFrameworkRoot,\n buildContract.contextPath,\n ),\n dockerfilePath: FrameworkDockerPublishService.asFrameworkRelativePath(\n resolvedFrameworkRoot,\n buildContract.dockerfilePath,\n ),\n commands: FrameworkDockerPublishService.buildCommandPreview(\n buildContract.contextPath,\n buildContract.dockerfilePath,\n imageRepository,\n imageRef,\n aliasImageRefs,\n { version: immutableTag, sourceUrl: frameworkConfig.publish.npm.repositoryUrl },\n signing,\n ),\n };\n }),\n };\n\n if (dryRun || result.targets.length === 0) {\n return result;\n }\n\n FrameworkDockerPublishService.assertDockerReady();\n FrameworkDockerPublishService.loginWithFrameworkSecrets(resolvedFrameworkRoot, frameworkConfig.publish.docker);\n\n for (const target of result.targets) {\n const configuredTarget = selectedTargets.find((image) => image.imageName === target.imageName);\n if (!configuredTarget) {\n throw new Error(`Missing Docker target definition for \"${target.imageName}\".`);\n }\n const buildContract = FrameworkDockerPublishService.resolveBuildContract(\n resolvedFrameworkRoot,\n configuredTarget,\n );\n\n /*\n * ONE buildx invocation builds every platform in `FRAMEWORK_DOCKER_IMAGE_PLATFORMS` and\n * pushes them as a single manifest list under the immutable tag. A multi-platform result\n * cannot be `--load`ed into the local daemon (it is not one image), which is why this is\n * `--push` rather than the old build-then-push pair. No CLI lane builds into the local daemon\n * since #2988 removed `wildo local up --rebuild`, whose image no runtime ran; the registry host's\n * `--fromCheckout` builds there, on the host's own platform.\n *\n * The push carries the SLSA provenance and SBOM attestations (`FRAMEWORK_IMAGE_ATTESTATION_ARGS`)\n * in the same index, and the OCI labels name the release, the repository, the revision and the\n * build instant (`provenanceLabelArgs`).\n */\n // buildx writes the pushed index's digest here (`containerimage.digest`): what the signature is made over.\n const metadataDir = mkdtempSync(join(tmpdir(), 'wildo-image-metadata-'));\n const metadataFile = join(metadataDir, 'metadata.json');\n try {\n await FrameworkDockerPublishService.runDockerBuild('buildx build --push', [\n 'buildx',\n 'build',\n '--platform',\n FRAMEWORK_DOCKER_IMAGE_PLATFORMS.join(','),\n '-f',\n buildContract.dockerfilePath,\n '-t',\n target.imageRef,\n ...FrameworkDockerPublishService.provenanceLabelArgs(\n resolvedFrameworkRoot,\n dockerContextSourcePathspecs(resolvedFrameworkRoot, buildContract.contextPath, buildContract.dockerfilePath),\n { version: immutableTag, sourceUrl: frameworkConfig.publish.npm.repositoryUrl },\n ),\n ...FRAMEWORK_IMAGE_ATTESTATION_ARGS,\n '--metadata-file',\n metadataFile,\n '--push',\n buildContract.contextPath,\n ]);\n target.digest = FrameworkDockerPublishService.pushedDigestOf(metadataFile);\n } finally {\n rmSync(metadataDir, { recursive: true, force: true });\n }\n }\n\n /*\n * Aliases are repointed only after EVERY immutable push has succeeded.\n *\n * The previous shape moved each image's alias inside the per-image loop, so\n * a failure on image N left images 1..N-1 already advertising the new\n * release through `latest` while the release as a whole had not happened —\n * a partial release that looks complete to anyone pulling the alias. With\n * one image in the publish set that was unobservable; it returns the moment\n * a second image is re-added, which is exactly when nobody would be looking\n * for it.\n */\n for (const target of result.targets) {\n for (const aliasRef of target.aliasImageRefs) {\n // `imagetools create` repoints the alias at the whole MANIFEST LIST in the registry, its\n // attestation manifests included; a local `docker tag` + `push` would only ever carry the one\n // platform the daemon holds, and no attestation.\n FrameworkDockerPublishService.runDockerCommand('imagetools create alias', [\n 'buildx',\n 'imagetools',\n 'create',\n '-t',\n aliasRef,\n target.imageRef,\n ]);\n }\n }\n\n // Signed by digest once every image is pushed; see FrameworkImageSigning.COSIGN_KEYLESS for what that covers.\n for (const target of result.targets) {\n target.signature = FrameworkDockerPublishService.signImage(target, signing);\n }\n\n return result;\n }\n\n /** The image index digest buildx recorded in its metadata file, or undefined when it recorded none. */\n static pushedDigestOf(metadataFile: string): string | undefined {\n try {\n const metadata = JSON.parse(readFileSync(metadataFile, 'utf8')) as Record<string, unknown>;\n const digest = metadata['containerimage.digest'];\n return typeof digest === 'string' && /^sha256:[0-9a-f]{64}$/.test(digest) ? digest : undefined;\n } catch {\n return undefined;\n }\n }\n\n /**\n * Sign one pushed image as the environment asks (#3063). Never throws: the image is already public, so a signature\n * that cannot be made is reported (FAILED, with the command to run by hand) rather than stopping the release after it\n * published, and a consumer's `cosign verify` sees it missing rather than being told anything false.\n *\n * cosign reads the registry credentials `docker login` wrote (`loginWithFrameworkSecrets`), and in GitHub Actions takes\n * the job's OIDC token on its own (`id-token: write`). SIGNED means the signature then VERIFIED against this job's\n * workflow identity (`cosign verify`), so the outcome is the registry's answer rather than the signing command's exit.\n */\n static signImage(\n target: Pick<FrameworkDockerPublishTargetResult, 'imageRepository' | 'digest'>,\n signing: FrameworkImageSigning | undefined,\n spawn: typeof spawnSync = spawnSync,\n env: NodeJS.ProcessEnv = process.env,\n ): NonNullable<FrameworkDockerPublishTargetResult['signature']> {\n if (signing === undefined) return { outcome: FrameworkImageSignatureOutcome.NOT_REQUESTED };\n if (!target.digest) {\n return { outcome: FrameworkImageSignatureOutcome.FAILED, reason: `buildx recorded no digest for ${target.imageRepository}; sign it by hand: cosign sign --yes ${target.imageRepository}@<digest>` };\n }\n const reference = `${target.imageRepository}@${target.digest}`;\n const identity = githubWorkflowSigningIdentityOf(env);\n if (!identity) {\n return { outcome: FrameworkImageSignatureOutcome.FAILED, reason: `keyless signing needs a GitHub Actions workload identity (GITHUB_WORKFLOW_REF is unset); sign it by hand: cosign sign --yes ${reference}` };\n }\n const failed = (step: string, run: ReturnType<typeof spawnSync>) =>\n `${step}: ${run.error ? run.error.message : `cosign exited ${run.status ?? 'without a status'}`}`;\n const signed = spawn('cosign', ['sign', '--yes', reference], { encoding: 'utf8', stdio: 'inherit' });\n if (signed.status !== 0) {\n return { outcome: FrameworkImageSignatureOutcome.FAILED, reason: `${failed('cosign sign', signed)}; sign it by hand: cosign sign --yes ${reference}` };\n }\n const verifyArgs = ['verify', '--certificate-identity', identity, '--certificate-oidc-issuer', GITHUB_ACTIONS_OIDC_ISSUER, reference];\n const verified = spawn('cosign', verifyArgs, { encoding: 'utf8', stdio: 'inherit' });\n if (verified.status !== 0) {\n return { outcome: FrameworkImageSignatureOutcome.FAILED, reason: `${failed('signed, but cosign verify', verified)}; check it with: cosign ${verifyArgs.join(' ')}` };\n }\n return { outcome: FrameworkImageSignatureOutcome.SIGNED };\n }\n\n /**\n * Log the Docker CLI in to the framework's registry with `docker.publishToken` from the framework secrets file.\n *\n * Every step that WRITES to the registry calls it itself: the image push, and moving the `latest` alias\n * (`wildo fwk publish all` step 8). A resumed release (`--skipDocker`) skips the push, so an alias move that relied\n * on the push's login ran unauthenticated: on a developer machine an earlier `docker login` hid that, and on a fresh\n * CI runner Docker Hub answered 401 (framework-release run 43278280537, 2026-11-12, #3063).\n *\n * @param frameworkRoot the framework checkout whose secrets file and release config are read\n */\n static async loginToRegistry(frameworkRoot: string): Promise<void> {\n const frameworkConfig = await FrameworkDockerPublishService.loadFrameworkConfigOrThrow(frameworkRoot);\n FrameworkDockerPublishService.loginWithFrameworkSecrets(frameworkRoot, frameworkConfig.publish.docker);\n }\n\n /** The login itself; `docker` gives the registry host, and the namespace used as the username when the secrets name none. */\n private static loginWithFrameworkSecrets(frameworkRoot: string, docker: { registryHost: string; namespace: string }): void {\n const secrets = FrameworkReleaseService.loadFrameworkDockerSecrets(frameworkRoot);\n const publishToken = secrets?.publishToken ?? null;\n if (!publishToken) {\n throw new Error(`Docker publish requires docker.publishToken in ${FrameworkReleaseService.resolveFrameworkSecretsPath(frameworkRoot)}.`);\n }\n FrameworkDockerPublishService.runDockerLogin(docker.registryHost, secrets?.publishUsername ?? docker.namespace, publishToken);\n }\n\n private static async loadFrameworkConfigOrThrow(frameworkRoot: string) {\n const frameworkConfig = await FrameworkReleaseService.loadFrameworkConfig(frameworkRoot);\n if (!frameworkConfig) {\n throw new Error(\n `Framework release config not found at ${FrameworkReleaseService.resolveFrameworkConfigPath(frameworkRoot)}`,\n );\n }\n return frameworkConfig;\n }\n\n private static resolveBuildContract(\n frameworkRoot: string,\n target: WildoFrameworkReleaseDockerImage,\n ): FrameworkDockerBuildContract {\n const buildDefinition = FRAMEWORK_DOCKER_IMAGE_BUILD_DEFINITIONS[target.imageName];\n if (!buildDefinition) {\n throw new Error(\n `Docker publish target \"${target.imageName}\" is not mapped to a framework Dockerfile yet.`,\n );\n }\n if (buildDefinition.role !== target.role || buildDefinition.variant !== target.variant) {\n throw new Error(\n `Docker publish target \"${target.imageName}\" must use ${buildDefinition.role}/${buildDefinition.variant}.`,\n );\n }\n\n const frameworkLayout = resolveFrameworkLayout(frameworkRoot);\n const contextPath = buildDefinition.resolveContextPath(frameworkLayout);\n const dockerfilePath = buildDefinition.resolveDockerfilePath(frameworkLayout);\n\n if (!existsSync(dockerfilePath)) {\n throw new Error(\n `Dockerfile for \"${target.imageName}\" not found at ${dockerfilePath}.`,\n );\n }\n\n return { contextPath, dockerfilePath };\n }\n\n /**\n * Both halves of the published image identity are locked, not just the\n * namespace. The registry host is the half that used to be implicit, and an\n * unlocked host is the more dangerous of the two: a wrong namespace fails\n * loudly on push permissions, while a wrong host can succeed and publish the\n * framework to a registry nobody is watching.\n */\n private static assertLockedDockerRegistryIdentity(registryHost: string, namespace: string): void {\n if (registryHost !== FRAMEWORK_RELEASE_DOCKER_REGISTRY_HOST) {\n throw new Error(\n `Docker publish currently supports only the locked registry host \"${FRAMEWORK_RELEASE_DOCKER_REGISTRY_HOST}\".`,\n );\n }\n if (namespace !== FRAMEWORK_RELEASE_DOCKER_NAMESPACE) {\n throw new Error(\n `Docker publish currently supports only the locked namespace \"${FRAMEWORK_RELEASE_DOCKER_NAMESPACE}\".`,\n );\n }\n }\n\n /**\n * The OCI labels stamped on every pushed image: the release it is (`identity.version`, the immutable\n * tag), the repository it comes from (`identity.sourceUrl`), the source revision and the build instant.\n *\n * Read back by `fwk publish all --skipDocker`, which resumes a release whose image is already pushed:\n * existence proves the tag is there, not that it was built from the source now being published, so the\n * resume prints what the image was built from and how many commits touched its inputs since. The\n * revision is HEAD, marked `-dirty` when the image's own inputs (`sourcePathspecs`) held uncommitted\n * edits or untracked files — the image then carries content no commit has. Edits elsewhere in the\n * shared tree do not mark it.\n *\n * The version is the immutable tag even when it is not a semver version (`test-<sha>` on a per-commit\n * channel): it is the one reference that always resolves to this image, so it is what the label names.\n */\n private static provenanceLabelArgs(\n frameworkRoot: string,\n sourcePathspecs: string[],\n identity: FrameworkImageIdentity,\n ): string[] {\n const labels = [\n '--label', `${FRAMEWORK_IMAGE_VERSION_LABEL}=${identity.version}`,\n '--label', `${FRAMEWORK_IMAGE_SOURCE_LABEL}=${identity.sourceUrl}`,\n '--label', `${FRAMEWORK_IMAGE_CREATED_LABEL}=${new Date().toISOString()}`,\n ];\n const head = spawnSync('git', ['rev-parse', 'HEAD'], { cwd: frameworkRoot, encoding: 'utf8' });\n if (head.status === 0 && head.stdout.trim()) {\n const status = spawnSync('git', ['status', '--porcelain', '--untracked-files=all', '--', ...sourcePathspecs], { cwd: frameworkRoot, encoding: 'utf8' });\n const dirty = status.status !== 0 || status.stdout.trim() !== '';\n labels.push('--label', `${FRAMEWORK_IMAGE_REVISION_LABEL}=${head.stdout.trim()}${dirty ? '-dirty' : ''}`);\n }\n return labels;\n }\n\n /**\n * The source pathspecs of a configured image, by name — what `fwk publish all --skipDocker` asks git\n * about. `null` for an image this lane has no build definition for.\n */\n static imageSourcePathspecs(frameworkRoot: string, imageName: string): string[] | null {\n const buildDefinition = FRAMEWORK_DOCKER_IMAGE_BUILD_DEFINITIONS[imageName];\n if (!buildDefinition) return null;\n const frameworkLayout = resolveFrameworkLayout(frameworkRoot);\n return dockerContextSourcePathspecs(\n frameworkRoot,\n buildDefinition.resolveContextPath(frameworkLayout),\n buildDefinition.resolveDockerfilePath(frameworkLayout),\n );\n }\n\n private static buildCommandPreview(\n contextPath: string,\n dockerfilePath: string,\n imageRepository: string,\n imageRef: string,\n aliasImageRefs: string[],\n identity: FrameworkImageIdentity,\n signing: FrameworkImageSigning | undefined,\n ): string[] {\n return [\n `docker buildx build --platform ${FRAMEWORK_DOCKER_IMAGE_PLATFORMS.join(',')} -f \"${dockerfilePath}\" -t \"${imageRef}\" --label ${FRAMEWORK_IMAGE_VERSION_LABEL}=${identity.version} --label ${FRAMEWORK_IMAGE_SOURCE_LABEL}=${identity.sourceUrl} --label ${FRAMEWORK_IMAGE_CREATED_LABEL}=<build instant> --label ${FRAMEWORK_IMAGE_REVISION_LABEL}=<HEAD>[-dirty] ${FRAMEWORK_IMAGE_ATTESTATION_ARGS.join(' ')} --metadata-file <tmp> --push \"${contextPath}\"`,\n ...aliasImageRefs.map((aliasRef) => `docker buildx imagetools create -t \"${aliasRef}\" \"${imageRef}\"`),\n ...(signing === FrameworkImageSigning.COSIGN_KEYLESS\n ? [`cosign sign --yes \"${imageRepository}@<pushed digest>\"`, `cosign verify --certificate-identity <this workflow> --certificate-oidc-issuer ${GITHUB_ACTIONS_OIDC_ISSUER} \"${imageRepository}@<pushed digest>\"`]\n : []),\n ];\n }\n\n private static asFrameworkRelativePath(frameworkRoot: string, absolutePath: string): string {\n return relative(frameworkRoot, absolutePath) || '.';\n }\n\n private static assertDockerReady(): void {\n const dockerState = DockerUtils.checkDockerRunning();\n if (!dockerState.available || !dockerState.running) {\n throw new Error(dockerState.error ?? 'Docker must be running to publish framework images.');\n }\n }\n\n /**\n * `docker login` with no host argument authenticates against Docker Hub, so\n * the registry host must be passed explicitly or the credential is sent to\n * the wrong registry and the later push fails as unauthenticated.\n */\n private static runDockerLogin(registryHost: string, username: string, publishToken: string): void {\n const loginResult = spawnSync(\n 'docker',\n ['login', registryHost, '--username', username, '--password-stdin'],\n {\n input: publishToken,\n encoding: 'utf8',\n stdio: ['pipe', 'inherit', 'inherit'],\n },\n );\n if (loginResult.status !== 0) {\n throw new Error(`Docker login failed for username \"${username}\" at ${registryHost}.`);\n }\n }\n\n /**\n * Run one image build, bounded by `FRAMEWORK_DOCKER_IMAGE_BUILD_TIMEOUT_MS` and tried up to\n * `FRAMEWORK_DOCKER_IMAGE_BUILD_ATTEMPTS` times (#3063, #3963).\n *\n * The output is streamed through, unchanged, and watched: the moment QEMU reports a crashed emulated process\n * (`QEMU_CRASH_PATTERN`) the attempt is ended and tried again, instead of waiting out the bound in silence. A\n * build that runs out of time is ended the same way; at most `FRAMEWORK_DOCKER_IMAGE_BUILD_TIMEOUTS` attempts\n * may, so the worst case stays two full bounds. Ending an attempt sends SIGTERM to the buildx client, and\n * BuildKit cancels the build when its session closes. Every failure says which attempt it was and why.\n */\n static async runDockerBuild(\n label: string,\n args: string[],\n spawnProcess: typeof spawn = spawn,\n log: (message: string) => void = (message) => console.error(message),\n timeoutMs: number = FRAMEWORK_DOCKER_IMAGE_BUILD_TIMEOUT_MS,\n ): Promise<void> {\n const minutes = Math.round(FRAMEWORK_DOCKER_IMAGE_BUILD_TIMEOUT_MS / 60_000);\n let timeouts = 0;\n for (let attempt = 1; attempt <= FRAMEWORK_DOCKER_IMAGE_BUILD_ATTEMPTS; attempt += 1) {\n const outcome = await FrameworkDockerPublishService.runOneDockerBuild(args, spawnProcess, timeoutMs);\n if (outcome.kind === DockerBuildAttemptOutcome.SUCCEEDED) return;\n if (outcome.kind === DockerBuildAttemptOutcome.TIMED_OUT) timeouts += 1;\n const reason =\n outcome.kind === DockerBuildAttemptOutcome.TIMED_OUT\n ? `it ran out of its ${minutes} minutes (an emulated platform can hang without a word)`\n : outcome.kind === DockerBuildAttemptOutcome.EMULATOR_CRASHED\n ? `QEMU crashed an emulated process (\"${outcome.line}\"), after which the build never finishes`\n : outcome.kind === DockerBuildAttemptOutcome.SPAWN_FAILED\n ? `docker could not be started (${outcome.message})`\n : outcome.signal\n ? `it was ended by ${outcome.signal}`\n : `it exited ${outcome.status ?? 'without a status'}`;\n const last =\n attempt === FRAMEWORK_DOCKER_IMAGE_BUILD_ATTEMPTS ||\n timeouts >= FRAMEWORK_DOCKER_IMAGE_BUILD_TIMEOUTS ||\n outcome.kind === DockerBuildAttemptOutcome.SPAWN_FAILED;\n log(`Docker ${label}, attempt ${attempt} of ${FRAMEWORK_DOCKER_IMAGE_BUILD_ATTEMPTS}: ${reason}.${last ? '' : ' Trying again.'}`);\n if (last) throw new Error(`Docker ${label} failed after ${attempt} attempt${attempt === 1 ? '' : 's'}: ${reason}.`);\n }\n }\n\n /**\n * One build attempt: docker's output goes to this process's own stdout/stderr as it arrives (a release log\n * reads exactly as before), and each line is checked against `QEMU_CRASH_PATTERN`. Lines are reassembled\n * across chunks so a crash line split by the pipe is still seen.\n */\n private static runOneDockerBuild(\n args: string[],\n spawnProcess: typeof spawn,\n timeoutMs: number,\n ): Promise<\n | { kind: DockerBuildAttemptOutcome.SUCCEEDED }\n | { kind: DockerBuildAttemptOutcome.TIMED_OUT }\n | { kind: DockerBuildAttemptOutcome.EMULATOR_CRASHED; line: string }\n | { kind: DockerBuildAttemptOutcome.SPAWN_FAILED; message: string }\n | { kind: DockerBuildAttemptOutcome.FAILED; status: number | null; signal: NodeJS.Signals | null }\n > {\n return new Promise((resolve) => {\n const child = spawnProcess('docker', args, { stdio: ['ignore', 'pipe', 'pipe'] });\n let ended: { kind: DockerBuildAttemptOutcome.TIMED_OUT } | { kind: DockerBuildAttemptOutcome.EMULATOR_CRASHED; line: string } | undefined;\n const end = (reason: NonNullable<typeof ended>) => {\n if (ended) return;\n ended = reason;\n child.kill('SIGTERM');\n };\n const timer = setTimeout(() => end({ kind: DockerBuildAttemptOutcome.TIMED_OUT }), timeoutMs);\n const watch = (stream: NodeJS.ReadableStream | null, sink: NodeJS.WritableStream) => {\n let pending = '';\n stream?.on('data', (chunk: Buffer | string) => {\n const text = chunk.toString();\n sink.write(text);\n const lines = (pending + text).split('\\n');\n pending = lines.pop() ?? '';\n for (const line of lines) {\n const crash = QEMU_CRASH_PATTERN.exec(line);\n if (crash) end({ kind: DockerBuildAttemptOutcome.EMULATOR_CRASHED, line: line.slice(crash.index).trim() });\n }\n });\n };\n watch(child.stdout, process.stdout);\n watch(child.stderr, process.stderr);\n child.on('error', (error) => {\n clearTimeout(timer);\n resolve({ kind: DockerBuildAttemptOutcome.SPAWN_FAILED, message: error.message });\n });\n child.on('close', (status, signal) => {\n clearTimeout(timer);\n if (ended) resolve(ended);\n else if (status === 0) resolve({ kind: DockerBuildAttemptOutcome.SUCCEEDED });\n else resolve({ kind: DockerBuildAttemptOutcome.FAILED, status, signal });\n });\n });\n }\n\n private static runDockerCommand(label: string, args: string[]): void {\n const result = spawnSync('docker', args, {\n encoding: 'utf8',\n stdio: 'inherit',\n });\n if (result.status !== 0) {\n throw new Error(`Docker ${label} failed.`);\n }\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"csp-sync.service.d.ts","sourceRoot":"","sources":["../../../../src/services/security/csp-sync.service.ts"],"names":[],"mappings":"AASA,OAAO,EACL,eAAe,EAkBf,KAAK,iBAAiB,EAEtB,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACrB,MAAM,+BAA+B,CAAC;AAWvC,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B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,CAAC,EAAE,OAAO,CAAC;CAC9B;AAyeD;;;;;;;;;GASG;AACH,wBAAgB,kCAAkC,CAChD,UAAU,EAAE,IAAI,CAAC,eAAe,EAAE,UAAU,CAAC,EAC7C,WAAW,EAAE,IAAI,CAAC,mBAAmB,EAAE,cAAc,GAAG,cAAc,GAAG,cAAc,CAAC,GACvF,MAAM,GAAG,SAAS,CAWpB;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,YAAY,EAAE,eAAe,CAAC;IACvC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAC;CACpC;AAED,qBAAa,cAAc;IACzB;;;;;;;;;;;OAWG;WACU,sBAAsB,CACjC,KAAK,EAAE,mBAAmB,GACzB,OAAO,CAAC,wBAAwB,EAAE,CAAC;WA2EzB,IAAI,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,oBAAoB,CAAC;CAoD7E"}
@@ -1,6 +1,6 @@
1
1
  import { existsSync, mkdirSync, readFileSync, readdirSync, statSync, writeFileSync, } from 'node:fs';
2
2
  import { dirname, join, relative, resolve } from 'node:path';
3
- import { AppFrontendType, ConfigArtifactsZone, ConfigModuleResolution, EnvCspOverrideSchema, NGINX_CSP_BEGIN_MARKER, emitCspArtifacts, loadConfig, loadMaterializedFrontendProviders, resolveInfraEnvConfigPath, resolveCspPolicy, resolveFrontendServicesArtifactPath, rewriteNginxCspMarkerPairs, rewriteNginxCspMarkerPairsString, WildoCspConfigSchema, WildoLocationType, buildServicePublicUrl, resolveLocalhostApplicationOrigins, selectPrimaryBackendService, } from '@wildo-ai/platform-config-lib';
3
+ import { AppFrontendType, ConfigArtifactsZone, ConfigModuleResolution, EnvCspOverrideSchema, NGINX_CSP_BEGIN_MARKER, emitCspArtifacts, loadConfig, loadMaterializedBackendProviderFrameOrigins, loadMaterializedFrontendProviders, resolveInfraEnvConfigPath, resolveCspPolicy, resolveFrontendServicesArtifactPath, rewriteNginxCspMarkerPairs, rewriteNginxCspMarkerPairsString, WildoCspConfigSchema, WildoLocationType, buildServicePublicUrl, resolveLocalhostApplicationOrigins, selectPrimaryBackendService, } from '@wildo-ai/platform-config-lib';
4
4
  import { loadInfraEnvConfig } from '@wildo-ai/platform-config-lib';
5
5
  // The footprint type is owned by the package that puts it on the wire, and is
6
6
  // read here through the same public door every browser-bound consumer uses.
@@ -282,6 +282,22 @@ function collectProviderCspFootprints(args) {
282
282
  .map((provider) => resolveProviderCspFootprint(provider, args.serviceKey))
283
283
  .filter((footprint) => footprint !== undefined);
284
284
  }
285
+ /**
286
+ * The vendor pages the BACKEND's providers show in the application's own frontend (#4002): today a signing page framed
287
+ * by `EmbeddedSigningFrame`. Recorded per provider in the backend artifact from the module's own declaration, which is
288
+ * also what the engine checks a signing page against, so the policy admits exactly what the engine will frame.
289
+ *
290
+ * Only for the SAAS_APP frontends, the surface that renders the frame; a website or documentation site frames no
291
+ * signing page and gains no origin. One footprint carrying `frameOrigins` alone, so it adds to `frame-src` and nothing
292
+ * else.
293
+ */
294
+ function collectBackendProviderFrameFootprints(args) {
295
+ if (args.frontendType !== AppFrontendType.SAAS_APP)
296
+ return [];
297
+ const frameOrigins = [...new Set(Object.values(loadMaterializedBackendProviderFrameOrigins(args.saasRoot)).flat())]
298
+ .sort((left, right) => left.localeCompare(right));
299
+ return frameOrigins.length === 0 ? [] : [normalizeProviderFrontendCspFootprint({ frameOrigins })];
300
+ }
285
301
  /**
286
302
  * Fills a provider's DERIVED origins in from its own public configuration.
287
303
  *
@@ -434,7 +450,10 @@ export class CspSyncService {
434
450
  // production contributes origins only to production's policy, and CSP
435
451
  // is enforcing there while it is report-only in development, so this is
436
452
  // the one layer whose absence shows up nowhere else.
437
- providerCspFootprints: collectProviderCspFootprints({ saasRoot, serviceKey }),
453
+ providerCspFootprints: [
454
+ ...collectProviderCspFootprints({ saasRoot, serviceKey }),
455
+ ...collectBackendProviderFrameFootprints({ saasRoot, frontendType }),
456
+ ],
438
457
  // Pass the env id so the resolver can auto-apply Vite dev-mode
439
458
  // loosening for `'local'` + `SAAS_APP`. Without this the
440
459
  // framework would not know whether it's resolving for local dev
@@ -1 +1 @@
1
- {"version":3,"file":"csp-sync.service.js","sourceRoot":"","sources":["../../../../src/services/security/csp-sync.service.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,SAAS,EACT,YAAY,EACZ,WAAW,EACX,QAAQ,EACR,aAAa,GACd,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,sBAAsB,EACtB,oBAAoB,EACpB,sBAAsB,EACtB,gBAAgB,EAChB,UAAU,EACV,iCAAiC,EACjC,yBAAyB,EACzB,gBAAgB,EAChB,mCAAmC,EACnC,0BAA0B,EAC1B,gCAAgC,EAChC,oBAAoB,EACpB,iBAAiB,EACjB,qBAAqB,EACrB,kCAAkC,EAClC,2BAA2B,GAK5B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,8EAA8E;AAC9E,4EAA4E;AAC5E,OAAO,EACL,qCAAqC,EACrC,oCAAoC,GAGrC,MAAM,sCAAsC,CAAC;AAuE9C,MAAM,uBAAuB,GAAG,IAAI,GAAG,CAAkB;IACvD,eAAe,CAAC,QAAQ;IACxB,eAAe,CAAC,QAAQ;IACxB,eAAe,CAAC,cAAc;CAC/B,CAAC,CAAC;AAEH,SAAS,0BAA0B,CAAC,KAAc;IAChD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAChD,MAAM,IAAI,KAAK,CAAC,6DAA6D,CAAC,CAAC;IACjF,CAAC;IAED,OAAO,KAA8B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AChE,CAAC;YACH,CAAC;YAED,QAAQ,CAAC,IAAI,CAAC;gBACZ,UAAU;gBACV,YAAY;gBACZ,qBAAqB,EAAE,QAAQ,CAAC,QAAQ,EAAE,qBAAqB,CAAC;gBAChE,0BAA0B;gBAC1B,mBAAmB;gBACnB,YAAY,EAAE,KAAK,IAAI,CAAC,0BAA0B,IAAI,mBAAmB,CAAC,MAAM,GAAG,CAAC,CAAC;aACtF,CAAC,CAAC;QACL,CAAC;QAED,OAAO;YACL,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,QAAQ;SACT,CAAC;IACJ,CAAC;CACF","sourcesContent":["import {\n existsSync,\n mkdirSync,\n readFileSync,\n readdirSync,\n statSync,\n writeFileSync,\n} from 'node:fs';\nimport { dirname, join, relative, resolve } from 'node:path';\nimport {\n AppFrontendType,\n ConfigArtifactsZone,\n ConfigModuleResolution,\n EnvCspOverrideSchema,\n NGINX_CSP_BEGIN_MARKER,\n emitCspArtifacts,\n loadConfig,\n loadMaterializedFrontendProviders,\n resolveInfraEnvConfigPath,\n resolveCspPolicy,\n resolveFrontendServicesArtifactPath,\n rewriteNginxCspMarkerPairs,\n rewriteNginxCspMarkerPairsString,\n WildoCspConfigSchema,\n WildoLocationType,\n buildServicePublicUrl,\n resolveLocalhostApplicationOrigins,\n selectPrimaryBackendService,\n type ResolvedCspPolicy,\n type WildoCspConfig,\n type WildoInfraEnvConfig,\n type WildoSaasConfig,\n} from '@wildo-ai/platform-config-lib';\nimport { loadInfraEnvConfig } from '@wildo-ai/platform-config-lib';\n// The footprint type is owned by the package that puts it on the wire, and is\n// read here through the same public door every browser-bound consumer uses.\nimport {\n normalizeProviderFrontendCspFootprint,\n PROVIDER_FRONTEND_CSP_ORIGIN_BUCKETS,\n type ProviderFrontendCspFootprint,\n type ProviderFrontendCspOriginBucket,\n} from '@wildo-ai/saas-models/public-runtime';\n\nexport interface GeneratedCspArtifacts {\n readonly envName: string;\n readonly serviceKey: string;\n readonly connectSrc: string[];\n readonly nginxHeaderName: string;\n readonly nginxPolicyValue: string;\n readonly nginxAddHeaderLine: string;\n /**\n * Every response header the policy needs, by name, policy first: the CSP header, then `Reporting-Endpoints` when the\n * policy's `report-to` names a collector (#2867). What a dev server sets, so a page served there reports exactly as\n * one served by nginx.\n */\n readonly responseHeaders: Readonly<Record<string, string>>;\n /** The nginx `add_header` lines for {@link responseHeaders}, in order: the body of every marker region. */\n readonly nginxAddHeaderLines: readonly string[];\n readonly metaTag: {\n readonly tagName: 'meta';\n readonly attributes: {\n readonly 'http-equiv': string;\n readonly content: string;\n };\n } | null;\n}\n\nexport interface CspSyncServiceResult {\n readonly envName: string;\n readonly services: CspSyncServiceEntryResult[];\n}\n\nexport interface CspSyncServiceEntryResult {\n readonly serviceKey: string;\n readonly frontendType: AppFrontendType;\n readonly generatedArtifactPath: string;\n /**\n * The policy resolved from this service's inputs differs from the committed artifact.\n *\n * Separate from `wroteChanges` on purpose. This is a fact about the REPOSITORY — the generated\n * file no longer describes its own inputs — and it is true whether or not this run was allowed to\n * repair it. Collapsing the two into one \"wrote\" boolean is what made a check mode impossible to\n * express: under `checkOnly` nothing is written and the interesting answer is still yes.\n */\n readonly generatedArtifactOutOfDate: boolean;\n /** Nginx marker pairs whose header line differs from the resolved policy, written or not. */\n readonly outOfDateNginxFiles: readonly string[];\n /** Whether this run actually touched the filesystem. Always false under `checkOnly`. */\n readonly wroteChanges: boolean;\n}\n\ninterface ServiceCspAuthoringConfig {\n readonly csp?: WildoCspConfig;\n}\n\ninterface CspSyncServiceInput {\n readonly saasRoot: string;\n readonly envName: string;\n readonly serviceKey?: string;\n readonly env?: NodeJS.ProcessEnv;\n /**\n * Resolve and compare, writing nothing.\n *\n * The CSP artifacts are TRACKED and generated, and until #513 nothing re-derived them: Wonder\n * Todos' website artifact was four months behind its own authored inputs and its `app` artifact\n * three weeks, each missing a directive whose author had written down what breaks without it.\n * Local CSP is report-only, so the drift produced no symptom and would have been discovered by\n * whoever flipped enforcement.\n */\n readonly checkOnly?: boolean;\n}\n\nconst FRONTEND_TYPES_WITH_CSP = new Set<AppFrontendType>([\n AppFrontendType.SAAS_APP,\n AppFrontendType.TECH_DOC,\n AppFrontendType.STATIC_WEBSITE,\n]);\n\nfunction parseGeneratedCspArtifacts(input: unknown): GeneratedCspArtifacts {\n if (typeof input !== 'object' || input === null) {\n throw new Error('[wildo-csp-sync] generated CSP artifacts must be an object.');\n }\n\n return input as GeneratedCspArtifacts;\n}\n\n/**\n * Compare the resolved artifact against what is on disk, and write it unless checking.\n *\n * Returns whether the two DIFFER, which is the answer both modes want — the sync path reports it as\n * \"updated\", the check path as \"out of date\". The comparison is on the exact serialized bytes, so a\n * reordering that changes nothing semantically still reports, which is correct for a file whose\n * whole purpose is to be the byte-for-byte output of a resolution.\n */\nfunction reconcileGeneratedCspArtifacts(\n input: GeneratedCspArtifacts,\n filePath: string,\n options: { readonly write: boolean },\n): boolean {\n const nextSource = `${JSON.stringify(input, null, 2)}\\n`;\n let currentSource: string | null = null;\n\n try {\n currentSource = readFileSync(filePath, 'utf-8');\n } catch {\n currentSource = null;\n }\n\n if (currentSource === nextSource) {\n return false;\n }\n\n if (options.write) {\n mkdirSync(dirname(filePath), { recursive: true });\n writeFileSync(filePath, nextSource);\n }\n return true;\n}\n\n/**\n * The same comparison for an nginx marker pair, without writing.\n *\n * Uses the PURE string rewriter the writing variant is itself built on, rather than re-implementing\n * the marker parsing — a second parser would answer differently the first time the marker format\n * moved, and a check that disagrees with the thing it checks is worse than no check.\n */\nfunction nginxCspMarkerPairsAreOutOfDate(filePath: string, addHeaderLines: readonly string[]): boolean {\n const original = readFileSync(filePath, 'utf-8');\n const { rewritten } = rewriteNginxCspMarkerPairsString(original, addHeaderLines, filePath);\n return rewritten !== original;\n}\n\n/** The shared authored-infra path rule (`resolveInfraEnvConfigPath`, platform-config-lib). */\nfunction resolveAuthoredInfraConfigPath(saasRoot: string, envName: string): string {\n return resolveInfraEnvConfigPath(saasRoot, envName);\n}\n\n/**\n * Every configuration this service reads is evaluated against the CLI's own built framework packages\n * ({@link ConfigModuleResolution.LOADER_INSTANCES}, #3440).\n *\n * The sync only asks what the files DECLARE (the services, their `csp` blocks, the environment's origins), and the CLI\n * composes the policy with the `platform-config-lib` build it runs. Left to the loader's inference, a framework checkout\n * aliases `@wildo-ai/platform-config-lib` to its `config-authoring.entry.ts` source, so the first read transpiled about\n * 120 framework source modules: 2.2 s on a fast host and over 5 s on the CI runner, where this service's first test\n * timed out (#3621). Same root cause and remedy as #3610 and #3615, and the mode `wildo website audit` already reads\n * `wildo.saas.config.ts` with. The files read here import framework packages and, at most, an application's role enums;\n * none defines a zod schema of its own, so the decorated-zod caveat of that mode does not arise.\n */\nconst CSP_SYNC_CONFIG_MODULE_RESOLUTION = ConfigModuleResolution.LOADER_INSTANCES;\n\nasync function loadSaasScopedConfig<T>(saasRoot: string, filePath: string): Promise<T> {\n return loadConfig<T>(filePath, {\n artifactLocation: {\n zone: ConfigArtifactsZone.SAAS,\n ownerRoot: saasRoot,\n },\n moduleResolution: CSP_SYNC_CONFIG_MODULE_RESOLUTION,\n });\n}\n\nasync function loadSaasConfig(saasRoot: string): Promise<WildoSaasConfig> {\n return loadSaasScopedConfig<WildoSaasConfig>(\n saasRoot,\n resolve(saasRoot, 'wildo.saas.config.ts'),\n );\n}\n\nasync function loadInfraConfig(saasRoot: string, envName: string): Promise<WildoInfraEnvConfig> {\n // Through the shared loader, like every other reader of the descriptor: `csp` is application-owned, but a\n // HOSTED descriptor is not an environment until it is resolved, and this function returns the environment.\n const loaded = await loadInfraEnvConfig(saasRoot, envName, { moduleResolution: CSP_SYNC_CONFIG_MODULE_RESOLUTION });\n if (loaded === null) {\n throw new Error(`Config file not found: ${resolveAuthoredInfraConfigPath(saasRoot, envName)}`);\n }\n return loaded.config;\n}\n\nfunction resolveFrontendServiceEntries(\n saasConfig: WildoSaasConfig,\n requestedServiceKey: string | undefined,\n): Array<readonly [string, WildoSaasConfig['services'][string]]> {\n const entries = Object.entries(saasConfig.services).filter(([, service]) =>\n service.frontendType !== undefined &&\n FRONTEND_TYPES_WITH_CSP.has(service.frontendType),\n );\n\n if (!requestedServiceKey) {\n return entries;\n }\n\n const match = entries.filter(([serviceKey]) => serviceKey === requestedServiceKey);\n if (match.length !== 1) {\n throw new Error(\n `[wildo-csp-sync] expected one CSP-capable frontend service named \"${requestedServiceKey}\", found ${match.length}.`,\n );\n }\n\n return match;\n}\n\nfunction assertInfraCspKeysExistAsServices(\n config: WildoInfraEnvConfig,\n saasConfig: Pick<WildoSaasConfig, 'services'>,\n cspCapableServiceKeys: ReadonlySet<string>,\n envName: string,\n): void {\n if (!config.csp) {\n return;\n }\n\n const serviceKeys = new Set(Object.keys(saasConfig.services));\n const unknownKeys = Object.keys(config.csp).filter((key) => !serviceKeys.has(key));\n if (unknownKeys.length > 0) {\n throw new Error(\n `[wildo-csp-sync] infrastructure/${envName} authored csp override keys that do not exist in wildo.saas.config.ts services: ${unknownKeys.join(', ')}.`,\n );\n }\n\n const nonFrontendKeys = Object.keys(config.csp).filter((key) => !cspCapableServiceKeys.has(key));\n if (nonFrontendKeys.length > 0) {\n throw new Error(\n `[wildo-csp-sync] infrastructure/${envName} authored csp override keys for services that are not CSP-capable frontends: ${nonFrontendKeys.join(', ')}.`,\n );\n }\n}\n\nfunction resolvePerServiceConfigPath(serviceRoot: string, frontendType: AppFrontendType): string | null {\n switch (frontendType) {\n case AppFrontendType.TECH_DOC:\n return resolve(serviceRoot, 'wildo.tech-doc.config.ts');\n case AppFrontendType.STATIC_WEBSITE:\n return resolve(serviceRoot, 'wildo.website.config.ts');\n case AppFrontendType.SAAS_APP:\n return null;\n }\n}\n\nasync function resolveAppCsp(args: {\n readonly saasRoot: string;\n readonly serviceKey: string;\n readonly serviceRoot: string;\n readonly frontendType: AppFrontendType;\n readonly service: WildoSaasConfig['services'][string];\n}): Promise<WildoCspConfig> {\n if (args.frontendType === AppFrontendType.SAAS_APP) {\n /*\n * An unauthored app-static layer DEFAULTS to the pilot posture; it is not a refusal (#417).\n *\n * The refusal fired on the ONLY path a fresh application takes. Neither the skeleton template\n * nor Wonder CRM authors a `services.<key>.csp` block — measured 2026-09-08, zero occurrences\n * of the string in either — so `wildo dev start` failed on Wonder CRM and on every application\n * `wildo init` had just produced.\n *\n * ENABLED AND REPORT-ONLY, not the schema's own `{}` default, and the reason is a SECOND\n * refusal that #417's measurement did not name. `resolveServicePolicies` below throws for any\n * CSP-capable frontend whose policy resolves to `null` — \"CSP-capable frontend services require\n * csp.enabled = true\" — while `WildoCspConfigSchema.enabled` defaults to `false`. So parsing\n * the empty object here merely moves the wall one frame down, which is what the pin for this\n * change caught. The two are not in conflict once you read what each governs: the schema's\n * default governs AUTHORING in general, and that guard governs a surface the framework has\n * already decided must carry a policy.\n *\n * So the default is the posture the schema's own JSDoc prescribes for a first-time author —\n * `reportOnly: true`, \"to triage console-surfaced violations without breaking real traffic\" —\n * and it is byte-for-byte what Wonder Todos authors and what the skeleton's shipped\n * `csp.generated.json` already CLAIMS (`Content-Security-Policy-Report-Only`). The scaffold's\n * intended posture was never \"no CSP\"; the config block to express it was simply missing.\n *\n * Everything else stays at the schema's defaults, so the merge strategy, the directive\n * overrides and the report URI have exactly one source and this is not a second copy of them.\n *\n * The cost of removing the refusal, accepted deliberately in #417: an application that DELETES\n * its `csp` block is now defaulted rather than told. It is defaulted to a policy that reports\n * and does not enforce, so the failure mode of getting this wrong is a console warning rather\n * than a broken application.\n */\n /*\n * The parse wraps the authored block too, and that half is IDEMPOTENT HARDENING rather than a\n * second fix — stated because a reader should not have to re-derive it. `wildo.saas.config.ts`\n * is loaded by a bare cast, but it is authored through `defineSaasConfig`, which already runs\n * `WildoSaasConfigSchema.parse` — and `services.<key>.csp` is `WildoCspConfigSchema.optional()`\n * there, so a partial block is already defaulted by the time it arrives. Bypassing that helper\n * is not a supported shape and would fail on other defaults first, which is why no pin reddens\n * when this parse is removed (measured, #442). What it buys is that the invariant below holds\n * unconditionally instead of by way of somebody else's helper.\n */\n return WildoCspConfigSchema.parse(args.service.csp ?? { enabled: true, reportOnly: true });\n }\n\n const configPath = resolvePerServiceConfigPath(args.serviceRoot, args.frontendType);\n if (configPath === null) {\n throw new Error(`[wildo-csp-sync] Unsupported frontend type: ${args.frontendType}`);\n }\n\n const config = await loadSaasScopedConfig<ServiceCspAuthoringConfig>(\n args.saasRoot,\n configPath,\n );\n if (config.csp === undefined) {\n throw new Error(\n `[wildo-csp-sync] ${configPath} must author a csp block so service \"${args.serviceKey}\" has an app-static layer.`,\n );\n }\n\n /*\n * ─── PARSED, not returned verbatim (#442) ────────────────────────────────────────────────────\n *\n * This branch handed the authored block straight to `resolveCspPolicy`, so a hand-written PARTIAL\n * block — `{ enabled: true, reportOnly: true }`, no `directives`, no `mergeStrategy` — arrived\n * without the schema's defaults and the sync died on `TypeError: Cannot convert undefined or null\n * to object`. A stack trace naming neither the author's file nor the missing field.\n *\n * `WildoCspConfigSchema` is a `z.strictObject`, so parsing here buys a second thing: a typo like\n * `enable: true` becomes a parse error naming the key instead of silently resolving to\n * `enabled: false` — which the schema's own JSDoc calls \"CSP off, the worst possible default\".\n *\n * The SAAS_APP branch above parses for the same reason. Both are needed and neither is redundant:\n * `wildo.saas.config.ts` is parsed by `defineSaasConfig` only when the author USES that helper,\n * and this file is loaded by a bare cast with no validation at all. So the invariant is stated\n * where it can be relied on — every block `resolveAppCsp` returns has been through the schema,\n * however it arrived.\n */\n return WildoCspConfigSchema.parse(config.csp);\n}\n\nfunction assertOriginAllowedInConnectSrc(args: {\n readonly envVarName: string;\n readonly rawUrl: string | undefined;\n readonly connectSrc: readonly string[];\n readonly envName: string;\n readonly serviceKey: string;\n}): void {\n if (!args.rawUrl) {\n return;\n }\n\n let origin: string;\n try {\n origin = new URL(args.rawUrl).origin;\n } catch {\n throw new Error(\n `[wildo-csp-sync] ${args.envVarName} must be a valid absolute URL, got \"${args.rawUrl}\".`,\n );\n }\n\n if (!args.connectSrc.includes(origin)) {\n throw new Error(\n `[wildo-csp-sync] ${args.envVarName} origin \"${origin}\" is missing from the final connect-src allowlist for service \"${args.serviceKey}\" in ${args.envName}.`,\n );\n }\n}\n\nfunction assertExplicitHmrOriginAllowed(\n env: NodeJS.ProcessEnv,\n connectSrc: readonly string[],\n envName: string,\n serviceKey: string,\n): void {\n const explicitHmrHost = env.VITE_HMR_HOST?.trim();\n const explicitHmrClientPort = env.VITE_HMR_CLIENT_PORT?.trim();\n const explicitHmrProtocol = env.VITE_HMR_PROTOCOL?.trim();\n if (!explicitHmrHost && !explicitHmrClientPort && !explicitHmrProtocol) {\n return;\n }\n\n const protocol = explicitHmrProtocol || 'ws';\n const host = explicitHmrHost || 'localhost';\n const port = explicitHmrClientPort || env.VITE_PORT?.trim() || '4242';\n const hmrOrigin = `${protocol}://${host}:${port}`;\n if (!connectSrc.includes(hmrOrigin)) {\n throw new Error(\n `[wildo-csp-sync] explicit Vite HMR origin \"${hmrOrigin}\" is missing from the final connect-src allowlist for service \"${serviceKey}\" in ${envName}.`,\n );\n }\n}\n\nfunction assertRuntimeOriginsAllowed(args: {\n readonly frontendType: AppFrontendType;\n readonly env: NodeJS.ProcessEnv;\n readonly connectSrc: readonly string[];\n readonly envName: string;\n readonly serviceKey: string;\n}): void {\n if (args.frontendType === AppFrontendType.SAAS_APP) {\n assertOriginAllowedInConnectSrc({\n envVarName: 'VITE_API_BASE_URL',\n rawUrl: args.env.VITE_API_BASE_URL,\n connectSrc: args.connectSrc,\n envName: args.envName,\n serviceKey: args.serviceKey,\n });\n assertExplicitHmrOriginAllowed(args.env, args.connectSrc, args.envName, args.serviceKey);\n }\n\n if (args.frontendType === AppFrontendType.TECH_DOC) {\n assertOriginAllowedInConnectSrc({\n envVarName: 'WILDO_DOCS_API_BASE_URL',\n rawUrl: args.env.WILDO_DOCS_API_BASE_URL,\n connectSrc: args.connectSrc,\n envName: args.envName,\n serviceKey: args.serviceKey,\n });\n }\n}\n\n/**\n * The CSP footprints of the providers DECLARED FOR ONE SERVICE (#332).\n *\n * Read from the materialized `frontend-services.runtime-providers.generated.json`\n * that `wildo config sync` writes — which is the whole reason the footprint is\n * DATA. This CLI is a Node process and a frontend provider module is\n * browser-bound; it could not execute one to ask what origins it needs, and a\n * provider whose origins had to be transcribed into every application's config\n * by hand would be wrong in production the first time anyone forgot.\n *\n * Keyed by SERVICE, not by facet: a Zoom origin the marketing site declared\n * must not be admitted for the SaaS app, which is the isolation this per-service\n * read is for.\n *\n * A missing artifact is not an error. A clean checkout, or an application that\n * declares no frontend provider at all, legitimately has none — and refusing\n * here would make `wildo dev sync-csp` depend on a sync having already run.\n */\nfunction collectProviderCspFootprints(args: {\n readonly saasRoot: string;\n readonly serviceKey: string;\n}): ReadonlyArray<ProviderFrontendCspFootprint> {\n const block = loadMaterializedFrontendProviders({\n artifactPath: resolveFrontendServicesArtifactPath(args.saasRoot),\n serviceKey: args.serviceKey,\n });\n\n if (block === undefined) {\n return [];\n }\n\n return Object.values(block.providers)\n .map((provider) => resolveProviderCspFootprint(provider, args.serviceKey))\n .filter((footprint): footprint is ProviderFrontendCspFootprint => footprint !== undefined);\n}\n\n/**\n * Fills a provider's DERIVED origins in from its own public configuration.\n *\n * Some endpoints are not knowable by the provider: an error-monitoring\n * provider sends to the host inside its DSN, an analytics provider to whatever\n * `apiHost` the application configured — a region, a reverse proxy on the\n * application's own domain, or a self-hosted deployment. The provider therefore\n * declares WHERE the origin is, and this is the one place that has both halves:\n * the served entry carries `publicConfig` and the footprint beside it.\n *\n * Without this the application would author the same host twice — once as the\n * provider's config, once in its own CSP — and the copy that drifts fails in\n * production only.\n *\n * Absent key: contributes nothing. That is the correct reading of \"this\n * application has not configured that provider\", and refusing would make an\n * unconfigured optional provider break the sync.\n *\n * Present but not a URL: FAILS, naming the provider and the key. It is the one\n * case where the application said something and the framework cannot honour it,\n * and silently dropping it produces exactly the blocked-in-production-only\n * failure the whole layer exists to remove.\n */\nfunction resolveProviderCspFootprint(\n provider: { readonly csp?: ProviderFrontendCspFootprint; readonly publicConfig?: Readonly<Record<string, unknown>>; readonly metadata: { readonly ref: string } },\n serviceKey: string,\n): ProviderFrontendCspFootprint | undefined {\n const footprint = provider.csp;\n if (footprint === undefined) return undefined;\n if (footprint.derivedOrigins.length === 0) return footprint;\n\n const resolved = normalizeProviderFrontendCspFootprint({\n ...footprint,\n // Resolved here, so nothing downstream has to know the bucket existed.\n derivedOrigins: [],\n });\n // Every bucket, from the enum (#1702). This used to be a hand-written list of six, so a provider that\n // derived an origin into a bucket added later (worker, media) would have crashed here, and one that\n // merely declared such a bucket beside a derived origin would have had it silently erased.\n const buckets = Object.fromEntries(\n PROVIDER_FRONTEND_CSP_ORIGIN_BUCKETS.map((bucket) => [bucket, [...resolved[bucket]]]),\n ) as Record<ProviderFrontendCspOriginBucket, string[]>;\n\n for (const derived of footprint.derivedOrigins) {\n const configured = provider.publicConfig?.[derived.publicConfigKey];\n if (configured === undefined || configured === null || configured === '') continue;\n\n if (typeof configured !== 'string') {\n throw new Error(\n `[wildo-csp-sync] provider \"${provider.metadata.ref}\" on service \"${serviceKey}\" declares a CSP origin `\n + `derived from publicConfig.${derived.publicConfigKey}, but that value is not a string.`,\n );\n }\n\n let origin: string;\n try {\n origin = new URL(configured).origin;\n } catch {\n throw new Error(\n `[wildo-csp-sync] provider \"${provider.metadata.ref}\" on service \"${serviceKey}\" declares a CSP origin `\n + `derived from publicConfig.${derived.publicConfigKey}, but \"${configured}\" is not an absolute URL, so `\n + 'no origin can be read from it. The provider would then be blocked by the very policy it contributes '\n + 'to — and only where CSP enforces, so the failure would first appear in production.',\n );\n }\n\n const bucket = buckets[derived.bucket];\n if (!bucket.includes(origin)) bucket.push(origin);\n }\n\n return normalizeProviderFrontendCspFootprint(buckets);\n}\n\nfunction collectNginxConfigFilesWithCspMarkers(serviceRoot: string): string[] {\n const nginxConfigRoot = resolve(serviceRoot, 'nginx-config');\n if (!existsSync(nginxConfigRoot)) {\n return [];\n }\n\n const collected: string[] = [];\n const visit = (directory: string): void => {\n for (const entry of readdirSync(directory)) {\n const path = join(directory, entry);\n const stat = statSync(path);\n if (stat.isDirectory()) {\n visit(path);\n continue;\n }\n if (stat.isFile() && readFileSync(path, 'utf-8').includes(NGINX_CSP_BEGIN_MARKER)) {\n collected.push(path);\n }\n }\n };\n\n visit(nginxConfigRoot);\n return collected.sort();\n}\n\n/**\n * The origin of the environment's main backend API, where the platform CSP violation collector is served (#2867).\n *\n * The same derivation every other browser-facing origin of an environment takes, so the policy names the backend the\n * environment actually runs: a REMOTE environment's main backend at its public URL (`buildServicePublicUrl`, which the\n * ingress, `runtime.endPoints` and CORS key on), any other at `http://localhost:<defaultPort>`\n * (`resolveLocalhostApplicationOrigins`, the origin `wildo local dev` starts it on). The main backend is\n * `selectPrimaryBackendService`'s, the one rule every such derivation shares. `undefined` when the application declares\n * no backend with a port: the policy then names no collector rather than an invented one.\n */\nexport function resolveCspViolationCollectorOrigin(\n saasConfig: Pick<WildoSaasConfig, 'services'>,\n infraConfig: Pick<WildoInfraEnvConfig, 'locationType' | 'publicDomain' | 'serviceHosts'>,\n): string | undefined {\n if (infraConfig.locationType === WildoLocationType.REMOTE) {\n const backendKeys = Object.entries(saasConfig.services)\n .filter(([, service]) => service.frontendType === undefined)\n .map(([key]) => ({ key }));\n const primaryBackend = selectPrimaryBackendService(backendKeys);\n return primaryBackend === undefined\n ? undefined\n : buildServicePublicUrl({ serviceKey: primaryBackend.key, serviceHosts: infraConfig.serviceHosts, publicDomain: infraConfig.publicDomain });\n }\n return resolveLocalhostApplicationOrigins(saasConfig.services).api;\n}\n\n/**\n * Per-service resolved CSP policy — the side-effect-free output of\n * {@link CspSyncService.resolveServicePolicies}. Both the nginx sync (write\n * side) and `wildo frontend publish` (CDN edge re-home) consume this, so the\n * layered resolution (baseline ⊕ app-static ⊕ env-override ⊕ the declared\n * providers' footprints, plus the Vite dev-loosening / companion-origin\n * auto-derivations) lives in ONE place and can never drift between the two\n * consumers.\n */\nexport interface ResolvedServiceCspPolicy {\n readonly serviceKey: string;\n readonly frontendType: AppFrontendType;\n readonly serviceRoot: string;\n readonly policy: ResolvedCspPolicy;\n}\n\nexport class CspSyncService {\n /**\n * Resolve each CSP-capable frontend's policy WITHOUT writing anything.\n *\n * Loads the saas + infra configs, validates the infra `csp` keys, resolves\n * the app-static layer (SAAS_APP inline / `wildo.website.config.ts` /\n * `wildo.tech-doc.config.ts`) merged with the per-env override, and asserts\n * the runtime origins are in `connect-src`. Returns one entry per\n * CSP-capable frontend (filtered to `input.serviceKey` when given).\n *\n * This is the shared resolution seam: {@link sync} adds the nginx-write side;\n * the CDN publish path adds the `_headers` / edge-policy side.\n */\n static async resolveServicePolicies(\n input: CspSyncServiceInput,\n ): Promise<ResolvedServiceCspPolicy[]> {\n const saasRoot = resolve(input.saasRoot);\n const env = input.env ?? process.env;\n const saasConfig = await loadSaasConfig(saasRoot);\n const serviceEntries = resolveFrontendServiceEntries(saasConfig, input.serviceKey);\n const cspCapableServiceKeys = resolveFrontendServiceEntries(saasConfig, undefined).map(([serviceKey]) => serviceKey);\n const infraConfig = await loadInfraConfig(saasRoot, input.envName);\n const violationCollectorOrigin = resolveCspViolationCollectorOrigin(saasConfig, infraConfig);\n\n assertInfraCspKeysExistAsServices(\n infraConfig,\n saasConfig,\n new Set(cspCapableServiceKeys),\n input.envName,\n );\n\n const resolved: ResolvedServiceCspPolicy[] = [];\n for (const [serviceKey, service] of serviceEntries) {\n const frontendType = service.frontendType;\n if (frontendType === undefined) {\n continue;\n }\n\n const serviceRoot = resolve(saasRoot, service.path);\n const appCsp = await resolveAppCsp({\n saasRoot,\n serviceKey,\n serviceRoot,\n frontendType,\n service,\n });\n const policy = resolveCspPolicy({\n frontendType,\n appCsp,\n envOverride: EnvCspOverrideSchema.optional().parse(infraConfig.csp?.[serviceKey]),\n // The fourth layer (#332): what the providers this service declared\n // actually need to reach. Resolved per service AND per environment\n // because both axes change the answer — a provider enabled only in\n // production contributes origins only to production's policy, and CSP\n // is enforcing there while it is report-only in development, so this is\n // the one layer whose absence shows up nowhere else.\n providerCspFootprints: collectProviderCspFootprints({ saasRoot, serviceKey }),\n // Pass the env id so the resolver can auto-apply Vite dev-mode\n // loosening for `'local'` + `SAAS_APP`. Without this the\n // framework would not know whether it's resolving for local dev\n // or prod, and apps would still have to opt-in per-env.\n environmentId: input.envName,\n // Where the platform violation collector is (#2867): this environment's main backend. Every CSP-capable surface\n // names it, unless the application authored a collector of its own.\n violationCollectorOrigin,\n });\n if (policy === null) {\n throw new Error(\n `[wildo-csp-sync] service \"${serviceKey}\" resolved to a disabled CSP. CSP-capable frontend services require csp.enabled = true.`,\n );\n }\n\n const connectSrc = [...(policy.directives['connect-src'] ?? [])];\n assertRuntimeOriginsAllowed({\n frontendType,\n env,\n connectSrc,\n envName: input.envName,\n serviceKey,\n });\n\n resolved.push({ serviceKey, frontendType, serviceRoot, policy });\n }\n\n return resolved;\n }\n\n static async sync(input: CspSyncServiceInput): Promise<CspSyncServiceResult> {\n const saasRoot = resolve(input.saasRoot);\n const resolvedServices = await CspSyncService.resolveServicePolicies(input);\n\n const services: CspSyncServiceEntryResult[] = [];\n for (const { serviceKey, frontendType, serviceRoot, policy } of resolvedServices) {\n const connectSrc = [...(policy.directives['connect-src'] ?? [])];\n const artifacts = emitCspArtifacts(policy);\n const generatedArtifacts = parseGeneratedCspArtifacts({\n envName: input.envName,\n serviceKey,\n connectSrc,\n nginxHeaderName: artifacts.nginxHeaderName,\n nginxPolicyValue: artifacts.nginxPolicyValue,\n nginxAddHeaderLine: artifacts.nginxAddHeaderLine,\n responseHeaders: Object.fromEntries(artifacts.responseHeaders.map((header) => [header.name, header.value])),\n nginxAddHeaderLines: artifacts.nginxAddHeaderLines,\n metaTag: artifacts.metaTag,\n });\n const generatedArtifactPath = resolve(serviceRoot, 'src', 'generated', 'csp.generated.json');\n const write = input.checkOnly !== true;\n const generatedArtifactOutOfDate = reconcileGeneratedCspArtifacts(\n generatedArtifacts,\n generatedArtifactPath,\n { write },\n );\n const outOfDateNginxFiles: string[] = [];\n\n for (const nginxConfigFile of collectNginxConfigFilesWithCspMarkers(serviceRoot)) {\n const outOfDate = write\n ? rewriteNginxCspMarkerPairs(nginxConfigFile, generatedArtifacts.nginxAddHeaderLines).fileWritten\n : nginxCspMarkerPairsAreOutOfDate(nginxConfigFile, generatedArtifacts.nginxAddHeaderLines);\n if (outOfDate) {\n outOfDateNginxFiles.push(relative(saasRoot, nginxConfigFile));\n }\n }\n\n services.push({\n serviceKey,\n frontendType,\n generatedArtifactPath: relative(saasRoot, generatedArtifactPath),\n generatedArtifactOutOfDate,\n outOfDateNginxFiles,\n wroteChanges: write && (generatedArtifactOutOfDate || outOfDateNginxFiles.length > 0),\n });\n }\n\n return {\n envName: input.envName,\n services,\n };\n }\n}\n"]}
1
+ {"version":3,"file":"csp-sync.service.js","sourceRoot":"","sources":["../../../../src/services/security/csp-sync.service.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,SAAS,EACT,YAAY,EACZ,WAAW,EACX,QAAQ,EACR,aAAa,GACd,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,sBAAsB,EACtB,oBAAoB,EACpB,sBAAsB,EACtB,gBAAgB,EAChB,UAAU,EACV,2CAA2C,EAC3C,iCAAiC,EACjC,yBAAyB,EACzB,gBAAgB,EAChB,mCAAmC,EACnC,0BAA0B,EAC1B,gCAAgC,EAChC,oBAAoB,EACpB,iBAAiB,EACjB,qBAAqB,EACrB,kCAAkC,EAClC,2BAA2B,GAK5B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,8EAA8E;AAC9E,4EAA4E;AAC5E,OAAO,EACL,qCAAqC,EACrC,oCAAoC,GAGrC,MAAM,sCAAsC,CAAC;AAuE9C,MAAM,uBAAuB,GAAG,IAAI,GAAG,CAAkB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K,CAAC,OAAO;YACtB,QAAQ;SACT,CAAC;IACJ,CAAC;CACF","sourcesContent":["import {\n existsSync,\n mkdirSync,\n readFileSync,\n readdirSync,\n statSync,\n writeFileSync,\n} from 'node:fs';\nimport { dirname, join, relative, resolve } from 'node:path';\nimport {\n AppFrontendType,\n ConfigArtifactsZone,\n ConfigModuleResolution,\n EnvCspOverrideSchema,\n NGINX_CSP_BEGIN_MARKER,\n emitCspArtifacts,\n loadConfig,\n loadMaterializedBackendProviderFrameOrigins,\n loadMaterializedFrontendProviders,\n resolveInfraEnvConfigPath,\n resolveCspPolicy,\n resolveFrontendServicesArtifactPath,\n rewriteNginxCspMarkerPairs,\n rewriteNginxCspMarkerPairsString,\n WildoCspConfigSchema,\n WildoLocationType,\n buildServicePublicUrl,\n resolveLocalhostApplicationOrigins,\n selectPrimaryBackendService,\n type ResolvedCspPolicy,\n type WildoCspConfig,\n type WildoInfraEnvConfig,\n type WildoSaasConfig,\n} from '@wildo-ai/platform-config-lib';\nimport { loadInfraEnvConfig } from '@wildo-ai/platform-config-lib';\n// The footprint type is owned by the package that puts it on the wire, and is\n// read here through the same public door every browser-bound consumer uses.\nimport {\n normalizeProviderFrontendCspFootprint,\n PROVIDER_FRONTEND_CSP_ORIGIN_BUCKETS,\n type ProviderFrontendCspFootprint,\n type ProviderFrontendCspOriginBucket,\n} from '@wildo-ai/saas-models/public-runtime';\n\nexport interface GeneratedCspArtifacts {\n readonly envName: string;\n readonly serviceKey: string;\n readonly connectSrc: string[];\n readonly nginxHeaderName: string;\n readonly nginxPolicyValue: string;\n readonly nginxAddHeaderLine: string;\n /**\n * Every response header the policy needs, by name, policy first: the CSP header, then `Reporting-Endpoints` when the\n * policy's `report-to` names a collector (#2867). What a dev server sets, so a page served there reports exactly as\n * one served by nginx.\n */\n readonly responseHeaders: Readonly<Record<string, string>>;\n /** The nginx `add_header` lines for {@link responseHeaders}, in order: the body of every marker region. */\n readonly nginxAddHeaderLines: readonly string[];\n readonly metaTag: {\n readonly tagName: 'meta';\n readonly attributes: {\n readonly 'http-equiv': string;\n readonly content: string;\n };\n } | null;\n}\n\nexport interface CspSyncServiceResult {\n readonly envName: string;\n readonly services: CspSyncServiceEntryResult[];\n}\n\nexport interface CspSyncServiceEntryResult {\n readonly serviceKey: string;\n readonly frontendType: AppFrontendType;\n readonly generatedArtifactPath: string;\n /**\n * The policy resolved from this service's inputs differs from the committed artifact.\n *\n * Separate from `wroteChanges` on purpose. This is a fact about the REPOSITORY — the generated\n * file no longer describes its own inputs — and it is true whether or not this run was allowed to\n * repair it. Collapsing the two into one \"wrote\" boolean is what made a check mode impossible to\n * express: under `checkOnly` nothing is written and the interesting answer is still yes.\n */\n readonly generatedArtifactOutOfDate: boolean;\n /** Nginx marker pairs whose header line differs from the resolved policy, written or not. */\n readonly outOfDateNginxFiles: readonly string[];\n /** Whether this run actually touched the filesystem. Always false under `checkOnly`. */\n readonly wroteChanges: boolean;\n}\n\ninterface ServiceCspAuthoringConfig {\n readonly csp?: WildoCspConfig;\n}\n\ninterface CspSyncServiceInput {\n readonly saasRoot: string;\n readonly envName: string;\n readonly serviceKey?: string;\n readonly env?: NodeJS.ProcessEnv;\n /**\n * Resolve and compare, writing nothing.\n *\n * The CSP artifacts are TRACKED and generated, and until #513 nothing re-derived them: Wonder\n * Todos' website artifact was four months behind its own authored inputs and its `app` artifact\n * three weeks, each missing a directive whose author had written down what breaks without it.\n * Local CSP is report-only, so the drift produced no symptom and would have been discovered by\n * whoever flipped enforcement.\n */\n readonly checkOnly?: boolean;\n}\n\nconst FRONTEND_TYPES_WITH_CSP = new Set<AppFrontendType>([\n AppFrontendType.SAAS_APP,\n AppFrontendType.TECH_DOC,\n AppFrontendType.STATIC_WEBSITE,\n]);\n\nfunction parseGeneratedCspArtifacts(input: unknown): GeneratedCspArtifacts {\n if (typeof input !== 'object' || input === null) {\n throw new Error('[wildo-csp-sync] generated CSP artifacts must be an object.');\n }\n\n return input as GeneratedCspArtifacts;\n}\n\n/**\n * Compare the resolved artifact against what is on disk, and write it unless checking.\n *\n * Returns whether the two DIFFER, which is the answer both modes want — the sync path reports it as\n * \"updated\", the check path as \"out of date\". The comparison is on the exact serialized bytes, so a\n * reordering that changes nothing semantically still reports, which is correct for a file whose\n * whole purpose is to be the byte-for-byte output of a resolution.\n */\nfunction reconcileGeneratedCspArtifacts(\n input: GeneratedCspArtifacts,\n filePath: string,\n options: { readonly write: boolean },\n): boolean {\n const nextSource = `${JSON.stringify(input, null, 2)}\\n`;\n let currentSource: string | null = null;\n\n try {\n currentSource = readFileSync(filePath, 'utf-8');\n } catch {\n currentSource = null;\n }\n\n if (currentSource === nextSource) {\n return false;\n }\n\n if (options.write) {\n mkdirSync(dirname(filePath), { recursive: true });\n writeFileSync(filePath, nextSource);\n }\n return true;\n}\n\n/**\n * The same comparison for an nginx marker pair, without writing.\n *\n * Uses the PURE string rewriter the writing variant is itself built on, rather than re-implementing\n * the marker parsing — a second parser would answer differently the first time the marker format\n * moved, and a check that disagrees with the thing it checks is worse than no check.\n */\nfunction nginxCspMarkerPairsAreOutOfDate(filePath: string, addHeaderLines: readonly string[]): boolean {\n const original = readFileSync(filePath, 'utf-8');\n const { rewritten } = rewriteNginxCspMarkerPairsString(original, addHeaderLines, filePath);\n return rewritten !== original;\n}\n\n/** The shared authored-infra path rule (`resolveInfraEnvConfigPath`, platform-config-lib). */\nfunction resolveAuthoredInfraConfigPath(saasRoot: string, envName: string): string {\n return resolveInfraEnvConfigPath(saasRoot, envName);\n}\n\n/**\n * Every configuration this service reads is evaluated against the CLI's own built framework packages\n * ({@link ConfigModuleResolution.LOADER_INSTANCES}, #3440).\n *\n * The sync only asks what the files DECLARE (the services, their `csp` blocks, the environment's origins), and the CLI\n * composes the policy with the `platform-config-lib` build it runs. Left to the loader's inference, a framework checkout\n * aliases `@wildo-ai/platform-config-lib` to its `config-authoring.entry.ts` source, so the first read transpiled about\n * 120 framework source modules: 2.2 s on a fast host and over 5 s on the CI runner, where this service's first test\n * timed out (#3621). Same root cause and remedy as #3610 and #3615, and the mode `wildo website audit` already reads\n * `wildo.saas.config.ts` with. The files read here import framework packages and, at most, an application's role enums;\n * none defines a zod schema of its own, so the decorated-zod caveat of that mode does not arise.\n */\nconst CSP_SYNC_CONFIG_MODULE_RESOLUTION = ConfigModuleResolution.LOADER_INSTANCES;\n\nasync function loadSaasScopedConfig<T>(saasRoot: string, filePath: string): Promise<T> {\n return loadConfig<T>(filePath, {\n artifactLocation: {\n zone: ConfigArtifactsZone.SAAS,\n ownerRoot: saasRoot,\n },\n moduleResolution: CSP_SYNC_CONFIG_MODULE_RESOLUTION,\n });\n}\n\nasync function loadSaasConfig(saasRoot: string): Promise<WildoSaasConfig> {\n return loadSaasScopedConfig<WildoSaasConfig>(\n saasRoot,\n resolve(saasRoot, 'wildo.saas.config.ts'),\n );\n}\n\nasync function loadInfraConfig(saasRoot: string, envName: string): Promise<WildoInfraEnvConfig> {\n // Through the shared loader, like every other reader of the descriptor: `csp` is application-owned, but a\n // HOSTED descriptor is not an environment until it is resolved, and this function returns the environment.\n const loaded = await loadInfraEnvConfig(saasRoot, envName, { moduleResolution: CSP_SYNC_CONFIG_MODULE_RESOLUTION });\n if (loaded === null) {\n throw new Error(`Config file not found: ${resolveAuthoredInfraConfigPath(saasRoot, envName)}`);\n }\n return loaded.config;\n}\n\nfunction resolveFrontendServiceEntries(\n saasConfig: WildoSaasConfig,\n requestedServiceKey: string | undefined,\n): Array<readonly [string, WildoSaasConfig['services'][string]]> {\n const entries = Object.entries(saasConfig.services).filter(([, service]) =>\n service.frontendType !== undefined &&\n FRONTEND_TYPES_WITH_CSP.has(service.frontendType),\n );\n\n if (!requestedServiceKey) {\n return entries;\n }\n\n const match = entries.filter(([serviceKey]) => serviceKey === requestedServiceKey);\n if (match.length !== 1) {\n throw new Error(\n `[wildo-csp-sync] expected one CSP-capable frontend service named \"${requestedServiceKey}\", found ${match.length}.`,\n );\n }\n\n return match;\n}\n\nfunction assertInfraCspKeysExistAsServices(\n config: WildoInfraEnvConfig,\n saasConfig: Pick<WildoSaasConfig, 'services'>,\n cspCapableServiceKeys: ReadonlySet<string>,\n envName: string,\n): void {\n if (!config.csp) {\n return;\n }\n\n const serviceKeys = new Set(Object.keys(saasConfig.services));\n const unknownKeys = Object.keys(config.csp).filter((key) => !serviceKeys.has(key));\n if (unknownKeys.length > 0) {\n throw new Error(\n `[wildo-csp-sync] infrastructure/${envName} authored csp override keys that do not exist in wildo.saas.config.ts services: ${unknownKeys.join(', ')}.`,\n );\n }\n\n const nonFrontendKeys = Object.keys(config.csp).filter((key) => !cspCapableServiceKeys.has(key));\n if (nonFrontendKeys.length > 0) {\n throw new Error(\n `[wildo-csp-sync] infrastructure/${envName} authored csp override keys for services that are not CSP-capable frontends: ${nonFrontendKeys.join(', ')}.`,\n );\n }\n}\n\nfunction resolvePerServiceConfigPath(serviceRoot: string, frontendType: AppFrontendType): string | null {\n switch (frontendType) {\n case AppFrontendType.TECH_DOC:\n return resolve(serviceRoot, 'wildo.tech-doc.config.ts');\n case AppFrontendType.STATIC_WEBSITE:\n return resolve(serviceRoot, 'wildo.website.config.ts');\n case AppFrontendType.SAAS_APP:\n return null;\n }\n}\n\nasync function resolveAppCsp(args: {\n readonly saasRoot: string;\n readonly serviceKey: string;\n readonly serviceRoot: string;\n readonly frontendType: AppFrontendType;\n readonly service: WildoSaasConfig['services'][string];\n}): Promise<WildoCspConfig> {\n if (args.frontendType === AppFrontendType.SAAS_APP) {\n /*\n * An unauthored app-static layer DEFAULTS to the pilot posture; it is not a refusal (#417).\n *\n * The refusal fired on the ONLY path a fresh application takes. Neither the skeleton template\n * nor Wonder CRM authors a `services.<key>.csp` block — measured 2026-09-08, zero occurrences\n * of the string in either — so `wildo dev start` failed on Wonder CRM and on every application\n * `wildo init` had just produced.\n *\n * ENABLED AND REPORT-ONLY, not the schema's own `{}` default, and the reason is a SECOND\n * refusal that #417's measurement did not name. `resolveServicePolicies` below throws for any\n * CSP-capable frontend whose policy resolves to `null` — \"CSP-capable frontend services require\n * csp.enabled = true\" — while `WildoCspConfigSchema.enabled` defaults to `false`. So parsing\n * the empty object here merely moves the wall one frame down, which is what the pin for this\n * change caught. The two are not in conflict once you read what each governs: the schema's\n * default governs AUTHORING in general, and that guard governs a surface the framework has\n * already decided must carry a policy.\n *\n * So the default is the posture the schema's own JSDoc prescribes for a first-time author —\n * `reportOnly: true`, \"to triage console-surfaced violations without breaking real traffic\" —\n * and it is byte-for-byte what Wonder Todos authors and what the skeleton's shipped\n * `csp.generated.json` already CLAIMS (`Content-Security-Policy-Report-Only`). The scaffold's\n * intended posture was never \"no CSP\"; the config block to express it was simply missing.\n *\n * Everything else stays at the schema's defaults, so the merge strategy, the directive\n * overrides and the report URI have exactly one source and this is not a second copy of them.\n *\n * The cost of removing the refusal, accepted deliberately in #417: an application that DELETES\n * its `csp` block is now defaulted rather than told. It is defaulted to a policy that reports\n * and does not enforce, so the failure mode of getting this wrong is a console warning rather\n * than a broken application.\n */\n /*\n * The parse wraps the authored block too, and that half is IDEMPOTENT HARDENING rather than a\n * second fix — stated because a reader should not have to re-derive it. `wildo.saas.config.ts`\n * is loaded by a bare cast, but it is authored through `defineSaasConfig`, which already runs\n * `WildoSaasConfigSchema.parse` — and `services.<key>.csp` is `WildoCspConfigSchema.optional()`\n * there, so a partial block is already defaulted by the time it arrives. Bypassing that helper\n * is not a supported shape and would fail on other defaults first, which is why no pin reddens\n * when this parse is removed (measured, #442). What it buys is that the invariant below holds\n * unconditionally instead of by way of somebody else's helper.\n */\n return WildoCspConfigSchema.parse(args.service.csp ?? { enabled: true, reportOnly: true });\n }\n\n const configPath = resolvePerServiceConfigPath(args.serviceRoot, args.frontendType);\n if (configPath === null) {\n throw new Error(`[wildo-csp-sync] Unsupported frontend type: ${args.frontendType}`);\n }\n\n const config = await loadSaasScopedConfig<ServiceCspAuthoringConfig>(\n args.saasRoot,\n configPath,\n );\n if (config.csp === undefined) {\n throw new Error(\n `[wildo-csp-sync] ${configPath} must author a csp block so service \"${args.serviceKey}\" has an app-static layer.`,\n );\n }\n\n /*\n * ─── PARSED, not returned verbatim (#442) ────────────────────────────────────────────────────\n *\n * This branch handed the authored block straight to `resolveCspPolicy`, so a hand-written PARTIAL\n * block — `{ enabled: true, reportOnly: true }`, no `directives`, no `mergeStrategy` — arrived\n * without the schema's defaults and the sync died on `TypeError: Cannot convert undefined or null\n * to object`. A stack trace naming neither the author's file nor the missing field.\n *\n * `WildoCspConfigSchema` is a `z.strictObject`, so parsing here buys a second thing: a typo like\n * `enable: true` becomes a parse error naming the key instead of silently resolving to\n * `enabled: false` — which the schema's own JSDoc calls \"CSP off, the worst possible default\".\n *\n * The SAAS_APP branch above parses for the same reason. Both are needed and neither is redundant:\n * `wildo.saas.config.ts` is parsed by `defineSaasConfig` only when the author USES that helper,\n * and this file is loaded by a bare cast with no validation at all. So the invariant is stated\n * where it can be relied on — every block `resolveAppCsp` returns has been through the schema,\n * however it arrived.\n */\n return WildoCspConfigSchema.parse(config.csp);\n}\n\nfunction assertOriginAllowedInConnectSrc(args: {\n readonly envVarName: string;\n readonly rawUrl: string | undefined;\n readonly connectSrc: readonly string[];\n readonly envName: string;\n readonly serviceKey: string;\n}): void {\n if (!args.rawUrl) {\n return;\n }\n\n let origin: string;\n try {\n origin = new URL(args.rawUrl).origin;\n } catch {\n throw new Error(\n `[wildo-csp-sync] ${args.envVarName} must be a valid absolute URL, got \"${args.rawUrl}\".`,\n );\n }\n\n if (!args.connectSrc.includes(origin)) {\n throw new Error(\n `[wildo-csp-sync] ${args.envVarName} origin \"${origin}\" is missing from the final connect-src allowlist for service \"${args.serviceKey}\" in ${args.envName}.`,\n );\n }\n}\n\nfunction assertExplicitHmrOriginAllowed(\n env: NodeJS.ProcessEnv,\n connectSrc: readonly string[],\n envName: string,\n serviceKey: string,\n): void {\n const explicitHmrHost = env.VITE_HMR_HOST?.trim();\n const explicitHmrClientPort = env.VITE_HMR_CLIENT_PORT?.trim();\n const explicitHmrProtocol = env.VITE_HMR_PROTOCOL?.trim();\n if (!explicitHmrHost && !explicitHmrClientPort && !explicitHmrProtocol) {\n return;\n }\n\n const protocol = explicitHmrProtocol || 'ws';\n const host = explicitHmrHost || 'localhost';\n const port = explicitHmrClientPort || env.VITE_PORT?.trim() || '4242';\n const hmrOrigin = `${protocol}://${host}:${port}`;\n if (!connectSrc.includes(hmrOrigin)) {\n throw new Error(\n `[wildo-csp-sync] explicit Vite HMR origin \"${hmrOrigin}\" is missing from the final connect-src allowlist for service \"${serviceKey}\" in ${envName}.`,\n );\n }\n}\n\nfunction assertRuntimeOriginsAllowed(args: {\n readonly frontendType: AppFrontendType;\n readonly env: NodeJS.ProcessEnv;\n readonly connectSrc: readonly string[];\n readonly envName: string;\n readonly serviceKey: string;\n}): void {\n if (args.frontendType === AppFrontendType.SAAS_APP) {\n assertOriginAllowedInConnectSrc({\n envVarName: 'VITE_API_BASE_URL',\n rawUrl: args.env.VITE_API_BASE_URL,\n connectSrc: args.connectSrc,\n envName: args.envName,\n serviceKey: args.serviceKey,\n });\n assertExplicitHmrOriginAllowed(args.env, args.connectSrc, args.envName, args.serviceKey);\n }\n\n if (args.frontendType === AppFrontendType.TECH_DOC) {\n assertOriginAllowedInConnectSrc({\n envVarName: 'WILDO_DOCS_API_BASE_URL',\n rawUrl: args.env.WILDO_DOCS_API_BASE_URL,\n connectSrc: args.connectSrc,\n envName: args.envName,\n serviceKey: args.serviceKey,\n });\n }\n}\n\n/**\n * The CSP footprints of the providers DECLARED FOR ONE SERVICE (#332).\n *\n * Read from the materialized `frontend-services.runtime-providers.generated.json`\n * that `wildo config sync` writes — which is the whole reason the footprint is\n * DATA. This CLI is a Node process and a frontend provider module is\n * browser-bound; it could not execute one to ask what origins it needs, and a\n * provider whose origins had to be transcribed into every application's config\n * by hand would be wrong in production the first time anyone forgot.\n *\n * Keyed by SERVICE, not by facet: a Zoom origin the marketing site declared\n * must not be admitted for the SaaS app, which is the isolation this per-service\n * read is for.\n *\n * A missing artifact is not an error. A clean checkout, or an application that\n * declares no frontend provider at all, legitimately has none — and refusing\n * here would make `wildo dev sync-csp` depend on a sync having already run.\n */\nfunction collectProviderCspFootprints(args: {\n readonly saasRoot: string;\n readonly serviceKey: string;\n}): ReadonlyArray<ProviderFrontendCspFootprint> {\n const block = loadMaterializedFrontendProviders({\n artifactPath: resolveFrontendServicesArtifactPath(args.saasRoot),\n serviceKey: args.serviceKey,\n });\n\n if (block === undefined) {\n return [];\n }\n\n return Object.values(block.providers)\n .map((provider) => resolveProviderCspFootprint(provider, args.serviceKey))\n .filter((footprint): footprint is ProviderFrontendCspFootprint => footprint !== undefined);\n}\n\n/**\n * The vendor pages the BACKEND's providers show in the application's own frontend (#4002): today a signing page framed\n * by `EmbeddedSigningFrame`. Recorded per provider in the backend artifact from the module's own declaration, which is\n * also what the engine checks a signing page against, so the policy admits exactly what the engine will frame.\n *\n * Only for the SAAS_APP frontends, the surface that renders the frame; a website or documentation site frames no\n * signing page and gains no origin. One footprint carrying `frameOrigins` alone, so it adds to `frame-src` and nothing\n * else.\n */\nfunction collectBackendProviderFrameFootprints(args: {\n readonly saasRoot: string;\n readonly frontendType: AppFrontendType;\n}): ReadonlyArray<ProviderFrontendCspFootprint> {\n if (args.frontendType !== AppFrontendType.SAAS_APP) return [];\n const frameOrigins = [...new Set(Object.values(loadMaterializedBackendProviderFrameOrigins(args.saasRoot)).flat())]\n .sort((left, right) => left.localeCompare(right));\n return frameOrigins.length === 0 ? [] : [normalizeProviderFrontendCspFootprint({ frameOrigins })];\n}\n\n/**\n * Fills a provider's DERIVED origins in from its own public configuration.\n *\n * Some endpoints are not knowable by the provider: an error-monitoring\n * provider sends to the host inside its DSN, an analytics provider to whatever\n * `apiHost` the application configured — a region, a reverse proxy on the\n * application's own domain, or a self-hosted deployment. The provider therefore\n * declares WHERE the origin is, and this is the one place that has both halves:\n * the served entry carries `publicConfig` and the footprint beside it.\n *\n * Without this the application would author the same host twice — once as the\n * provider's config, once in its own CSP — and the copy that drifts fails in\n * production only.\n *\n * Absent key: contributes nothing. That is the correct reading of \"this\n * application has not configured that provider\", and refusing would make an\n * unconfigured optional provider break the sync.\n *\n * Present but not a URL: FAILS, naming the provider and the key. It is the one\n * case where the application said something and the framework cannot honour it,\n * and silently dropping it produces exactly the blocked-in-production-only\n * failure the whole layer exists to remove.\n */\nfunction resolveProviderCspFootprint(\n provider: { readonly csp?: ProviderFrontendCspFootprint; readonly publicConfig?: Readonly<Record<string, unknown>>; readonly metadata: { readonly ref: string } },\n serviceKey: string,\n): ProviderFrontendCspFootprint | undefined {\n const footprint = provider.csp;\n if (footprint === undefined) return undefined;\n if (footprint.derivedOrigins.length === 0) return footprint;\n\n const resolved = normalizeProviderFrontendCspFootprint({\n ...footprint,\n // Resolved here, so nothing downstream has to know the bucket existed.\n derivedOrigins: [],\n });\n // Every bucket, from the enum (#1702). This used to be a hand-written list of six, so a provider that\n // derived an origin into a bucket added later (worker, media) would have crashed here, and one that\n // merely declared such a bucket beside a derived origin would have had it silently erased.\n const buckets = Object.fromEntries(\n PROVIDER_FRONTEND_CSP_ORIGIN_BUCKETS.map((bucket) => [bucket, [...resolved[bucket]]]),\n ) as Record<ProviderFrontendCspOriginBucket, string[]>;\n\n for (const derived of footprint.derivedOrigins) {\n const configured = provider.publicConfig?.[derived.publicConfigKey];\n if (configured === undefined || configured === null || configured === '') continue;\n\n if (typeof configured !== 'string') {\n throw new Error(\n `[wildo-csp-sync] provider \"${provider.metadata.ref}\" on service \"${serviceKey}\" declares a CSP origin `\n + `derived from publicConfig.${derived.publicConfigKey}, but that value is not a string.`,\n );\n }\n\n let origin: string;\n try {\n origin = new URL(configured).origin;\n } catch {\n throw new Error(\n `[wildo-csp-sync] provider \"${provider.metadata.ref}\" on service \"${serviceKey}\" declares a CSP origin `\n + `derived from publicConfig.${derived.publicConfigKey}, but \"${configured}\" is not an absolute URL, so `\n + 'no origin can be read from it. The provider would then be blocked by the very policy it contributes '\n + 'to — and only where CSP enforces, so the failure would first appear in production.',\n );\n }\n\n const bucket = buckets[derived.bucket];\n if (!bucket.includes(origin)) bucket.push(origin);\n }\n\n return normalizeProviderFrontendCspFootprint(buckets);\n}\n\nfunction collectNginxConfigFilesWithCspMarkers(serviceRoot: string): string[] {\n const nginxConfigRoot = resolve(serviceRoot, 'nginx-config');\n if (!existsSync(nginxConfigRoot)) {\n return [];\n }\n\n const collected: string[] = [];\n const visit = (directory: string): void => {\n for (const entry of readdirSync(directory)) {\n const path = join(directory, entry);\n const stat = statSync(path);\n if (stat.isDirectory()) {\n visit(path);\n continue;\n }\n if (stat.isFile() && readFileSync(path, 'utf-8').includes(NGINX_CSP_BEGIN_MARKER)) {\n collected.push(path);\n }\n }\n };\n\n visit(nginxConfigRoot);\n return collected.sort();\n}\n\n/**\n * The origin of the environment's main backend API, where the platform CSP violation collector is served (#2867).\n *\n * The same derivation every other browser-facing origin of an environment takes, so the policy names the backend the\n * environment actually runs: a REMOTE environment's main backend at its public URL (`buildServicePublicUrl`, which the\n * ingress, `runtime.endPoints` and CORS key on), any other at `http://localhost:<defaultPort>`\n * (`resolveLocalhostApplicationOrigins`, the origin `wildo local dev` starts it on). The main backend is\n * `selectPrimaryBackendService`'s, the one rule every such derivation shares. `undefined` when the application declares\n * no backend with a port: the policy then names no collector rather than an invented one.\n */\nexport function resolveCspViolationCollectorOrigin(\n saasConfig: Pick<WildoSaasConfig, 'services'>,\n infraConfig: Pick<WildoInfraEnvConfig, 'locationType' | 'publicDomain' | 'serviceHosts'>,\n): string | undefined {\n if (infraConfig.locationType === WildoLocationType.REMOTE) {\n const backendKeys = Object.entries(saasConfig.services)\n .filter(([, service]) => service.frontendType === undefined)\n .map(([key]) => ({ key }));\n const primaryBackend = selectPrimaryBackendService(backendKeys);\n return primaryBackend === undefined\n ? undefined\n : buildServicePublicUrl({ serviceKey: primaryBackend.key, serviceHosts: infraConfig.serviceHosts, publicDomain: infraConfig.publicDomain });\n }\n return resolveLocalhostApplicationOrigins(saasConfig.services).api;\n}\n\n/**\n * Per-service resolved CSP policy — the side-effect-free output of\n * {@link CspSyncService.resolveServicePolicies}. Both the nginx sync (write\n * side) and `wildo frontend publish` (CDN edge re-home) consume this, so the\n * layered resolution (baseline ⊕ app-static ⊕ env-override ⊕ the declared\n * providers' footprints, plus the Vite dev-loosening / companion-origin\n * auto-derivations) lives in ONE place and can never drift between the two\n * consumers.\n */\nexport interface ResolvedServiceCspPolicy {\n readonly serviceKey: string;\n readonly frontendType: AppFrontendType;\n readonly serviceRoot: string;\n readonly policy: ResolvedCspPolicy;\n}\n\nexport class CspSyncService {\n /**\n * Resolve each CSP-capable frontend's policy WITHOUT writing anything.\n *\n * Loads the saas + infra configs, validates the infra `csp` keys, resolves\n * the app-static layer (SAAS_APP inline / `wildo.website.config.ts` /\n * `wildo.tech-doc.config.ts`) merged with the per-env override, and asserts\n * the runtime origins are in `connect-src`. Returns one entry per\n * CSP-capable frontend (filtered to `input.serviceKey` when given).\n *\n * This is the shared resolution seam: {@link sync} adds the nginx-write side;\n * the CDN publish path adds the `_headers` / edge-policy side.\n */\n static async resolveServicePolicies(\n input: CspSyncServiceInput,\n ): Promise<ResolvedServiceCspPolicy[]> {\n const saasRoot = resolve(input.saasRoot);\n const env = input.env ?? process.env;\n const saasConfig = await loadSaasConfig(saasRoot);\n const serviceEntries = resolveFrontendServiceEntries(saasConfig, input.serviceKey);\n const cspCapableServiceKeys = resolveFrontendServiceEntries(saasConfig, undefined).map(([serviceKey]) => serviceKey);\n const infraConfig = await loadInfraConfig(saasRoot, input.envName);\n const violationCollectorOrigin = resolveCspViolationCollectorOrigin(saasConfig, infraConfig);\n\n assertInfraCspKeysExistAsServices(\n infraConfig,\n saasConfig,\n new Set(cspCapableServiceKeys),\n input.envName,\n );\n\n const resolved: ResolvedServiceCspPolicy[] = [];\n for (const [serviceKey, service] of serviceEntries) {\n const frontendType = service.frontendType;\n if (frontendType === undefined) {\n continue;\n }\n\n const serviceRoot = resolve(saasRoot, service.path);\n const appCsp = await resolveAppCsp({\n saasRoot,\n serviceKey,\n serviceRoot,\n frontendType,\n service,\n });\n const policy = resolveCspPolicy({\n frontendType,\n appCsp,\n envOverride: EnvCspOverrideSchema.optional().parse(infraConfig.csp?.[serviceKey]),\n // The fourth layer (#332): what the providers this service declared\n // actually need to reach. Resolved per service AND per environment\n // because both axes change the answer — a provider enabled only in\n // production contributes origins only to production's policy, and CSP\n // is enforcing there while it is report-only in development, so this is\n // the one layer whose absence shows up nowhere else.\n providerCspFootprints: [\n ...collectProviderCspFootprints({ saasRoot, serviceKey }),\n ...collectBackendProviderFrameFootprints({ saasRoot, frontendType }),\n ],\n // Pass the env id so the resolver can auto-apply Vite dev-mode\n // loosening for `'local'` + `SAAS_APP`. Without this the\n // framework would not know whether it's resolving for local dev\n // or prod, and apps would still have to opt-in per-env.\n environmentId: input.envName,\n // Where the platform violation collector is (#2867): this environment's main backend. Every CSP-capable surface\n // names it, unless the application authored a collector of its own.\n violationCollectorOrigin,\n });\n if (policy === null) {\n throw new Error(\n `[wildo-csp-sync] service \"${serviceKey}\" resolved to a disabled CSP. CSP-capable frontend services require csp.enabled = true.`,\n );\n }\n\n const connectSrc = [...(policy.directives['connect-src'] ?? [])];\n assertRuntimeOriginsAllowed({\n frontendType,\n env,\n connectSrc,\n envName: input.envName,\n serviceKey,\n });\n\n resolved.push({ serviceKey, frontendType, serviceRoot, policy });\n }\n\n return resolved;\n }\n\n static async sync(input: CspSyncServiceInput): Promise<CspSyncServiceResult> {\n const saasRoot = resolve(input.saasRoot);\n const resolvedServices = await CspSyncService.resolveServicePolicies(input);\n\n const services: CspSyncServiceEntryResult[] = [];\n for (const { serviceKey, frontendType, serviceRoot, policy } of resolvedServices) {\n const connectSrc = [...(policy.directives['connect-src'] ?? [])];\n const artifacts = emitCspArtifacts(policy);\n const generatedArtifacts = parseGeneratedCspArtifacts({\n envName: input.envName,\n serviceKey,\n connectSrc,\n nginxHeaderName: artifacts.nginxHeaderName,\n nginxPolicyValue: artifacts.nginxPolicyValue,\n nginxAddHeaderLine: artifacts.nginxAddHeaderLine,\n responseHeaders: Object.fromEntries(artifacts.responseHeaders.map((header) => [header.name, header.value])),\n nginxAddHeaderLines: artifacts.nginxAddHeaderLines,\n metaTag: artifacts.metaTag,\n });\n const generatedArtifactPath = resolve(serviceRoot, 'src', 'generated', 'csp.generated.json');\n const write = input.checkOnly !== true;\n const generatedArtifactOutOfDate = reconcileGeneratedCspArtifacts(\n generatedArtifacts,\n generatedArtifactPath,\n { write },\n );\n const outOfDateNginxFiles: string[] = [];\n\n for (const nginxConfigFile of collectNginxConfigFilesWithCspMarkers(serviceRoot)) {\n const outOfDate = write\n ? rewriteNginxCspMarkerPairs(nginxConfigFile, generatedArtifacts.nginxAddHeaderLines).fileWritten\n : nginxCspMarkerPairsAreOutOfDate(nginxConfigFile, generatedArtifacts.nginxAddHeaderLines);\n if (outOfDate) {\n outOfDateNginxFiles.push(relative(saasRoot, nginxConfigFile));\n }\n }\n\n services.push({\n serviceKey,\n frontendType,\n generatedArtifactPath: relative(saasRoot, generatedArtifactPath),\n generatedArtifactOutOfDate,\n outOfDateNginxFiles,\n wroteChanges: write && (generatedArtifactOutOfDate || outOfDateNginxFiles.length > 0),\n });\n }\n\n return {\n envName: input.envName,\n services,\n };\n }\n}\n"]}