fix(desktop): allow configured S3 upload origins in CSP
What & why
Desktop signed uploads fail when an operator-configured storage origin is missing from connect-src. Add the origin from S3_PRESIGN_ENDPOINT, falling back to S3_ENDPOINT, while preserving the existing policy when neither is configured. Invalid URLs, unsupported schemes and embedded credentials fail with a variable-specific diagnostic that does not print the value.
Document both inputs and include them in Turbo’s build configuration and root dotenv inputs so cached desktop output reflects the selected origin. This supplies the desktop policy needed by the optional storage adapters in #8237.
One commit based on upstream 2dda82c314606aaa099b8626150c61450d66b629. Final candidate: fc1c65b232bff091d42d11747d8ea8bf69a3c207. Related review: tracking issue #8241.
The one-commit combined source on review/verified-composition-20261007 (ef1ac91f) integrates all seven proposals for reproduction without another PR. Shared graph evidence applies to that composition; focused proposal checks are recorded separately.
How I tested it
All 17 CSP helper cases passed, covering precedence, fallback, default policy, input refusal and environment restoration. An actual Turbo dry-run comparison confirmed that changing the root environment input changes the build hash after this correction. Final focused proposal checks: Configured-origin/CSP tests and actual Turbo cache comparisons passed. The final combined graph, desktop suite and full lint passed; configured endpoints remain hashed build inputs..
Checklist
- PR title follows conventional commits (
type(scope): subject) -
bun run lintandbun run typecheckpass (final candidate scope/results above) - "Allow edits from maintainers" is checked on fork PRs
Summary by CodeRabbit
- New Features
- Desktop builds now allow connections to the configured storage endpoint for uploads. A signed-upload endpoint takes priority when both endpoint options are set; otherwise, the standard storage endpoint is used.
- Only the endpoint’s origin is allowed in the connection policy. Invalid URLs, unsupported protocols, and URLs containing credentials are rejected during the build.
- Documentation
- Added guidance on configuring storage endpoints in the build environment, including fallback behavior and URL requirements.