Frontend/four issues content csp docs - #1541
Merged
Merged
Conversation
added 4 commits
July 27, 2026 08:23
Mocks the content API layer (getContentById) directly so tests assert
on real gated-vs-unlocked rendering from GatedContentViewer rather than
just the page shell:
- Locked overlay ("Exclusive Content" + Subscribe CTA) for gated content
without an active subscription
- Full player rendering for un-gated content
- Full player rendering once a gated content access check resolves to
an active subscription
Uses fake timers to deterministically advance past the simulated
access-check network round trip, keeping the suite stable in CI.
…zon hosts next.config.ts's CSP builder hardcoded a fixed set of Stellar hosts for connect-src and never looked at NEXT_PUBLIC_SOROBAN_RPC_URL or NEXT_PUBLIC_HORIZON_URL. Pointing the app at a non-default RPC (a private endpoint, a different provider) meant CSP silently blocked it, breaking wallet signing/submission with an opaque browser-console violation instead of a working request. - Extract CSP construction into src/lib/csp.ts (buildConnectSrcHosts, buildContentSecurityPolicy), unit-testable independent of next.config. - buildConnectSrcHosts() now always includes the API origin and the default Stellar/Soroban hosts, plus whatever host is configured via NEXT_PUBLIC_SOROBAN_RPC_URL / NEXT_PUBLIC_HORIZON_URL, deduped. - next.config.ts's getCSP() delegates to the shared helper; behavior for existing default hosts is unchanged. - Add docs/CSP.md documenting the allowed connect-src hosts, why the configured RPC/Horizon hosts matter, and how to update the list safely.
CSP changes can silently break wallet extensions: a refactor of next.config.ts or src/lib/csp.ts can drop a Stellar/Soroban host from connect-src and nothing fails until a wallet throws a CSP violation in production. - Add src/lib/csp.test.ts asserting: every DEFAULT_STELLAR_CONNECT_HOSTS entry is present, the API origin host is present, a host configured via NEXT_PUBLIC_SOROBAN_RPC_URL / NEXT_PUBLIC_HORIZON_URL is added and deduped, arbitrary unconfigured hosts are not added, and localhost/127.0.0.1 sources only appear outside production. - Document the regression test and the update process in docs/CSP.md so a deliberate host-list change updates both the code and the test/docs together instead of drifting apart.
Contributors had no documented path to set up the frontend locally and connect Freighter against the local API, and no .env template to start from. - Add frontend/.env.example covering API base URL, Stellar network, Horizon/Soroban RPC overrides, contract IDs, feature flags, and the dev-only auth shortcut. Un-ignore .env.example specifically in frontend/.gitignore (which blanket-ignores .env*). - Add docs/LOCAL_QUICKSTART.md: a ~15-minute walkthrough (prerequisites, env setup, install/run, connecting Freighter, a smoke-test checklist) plus a troubleshooting section for common wallet/CORS/CSP failures. - Add frontend/README.md linking the quickstart and other existing frontend docs (CSP, security headers, wallet system, accessibility), since no frontend README previously existed.
|
@Mac-5 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
1. Content page integration tests for unlock flow
content/[id]previously only had a test for the page shell (subscription badge), not the actual unlock flow. Addedfrontend/src/app/content/[id]/unlock-flow.test.tsx, which mocks the content API layer (getContentById) directly and asserts:Uses fake timers to deterministically advance past the simulated access-check delay, keeping the suite stable in CI.
2. Local env + Freighter quickstart for the frontend package
Contributors had no documented path to set up the frontend locally or connect Freighter to the local API.
frontend/.env.example(API base URL, Stellar network, Horizon/Soroban RPC overrides, contract IDs, feature flags, dev-auth shortcut) and un-ignored it infrontend/.gitignore(which blanket-ignores.env*).frontend/docs/LOCAL_QUICKSTART.md: a ~15-minute walkthrough (prerequisites → env setup → install/run → connect Freighter → smoke-test checklist) plus troubleshooting for common wallet/CORS/CSP failures.frontend/README.mdlinking the quickstart and other existing docs (CSP, security headers, wallet system, accessibility) — no frontend README existed before.3. Enforce CSP connect-src for configured Soroban RPC
next.config.ts's CSP builder hardcoded a fixed Stellar host list and never readNEXT_PUBLIC_SOROBAN_RPC_URL/NEXT_PUBLIC_HORIZON_URL. Pointing the app at a non-default RPC silently broke wallet calls once CSP blocked the un-listed host.frontend/src/lib/csp.ts(buildConnectSrcHosts,buildContentSecurityPolicy), independently testable fromnext.config.ts.connect-srcnow always includes the API origin + default Stellar hosts, plus whatever host is configured viaNEXT_PUBLIC_SOROBAN_RPC_URL/NEXT_PUBLIC_HORIZON_URL, deduped.next.config.tsnow delegates to the shared helper; existing default-host behavior is unchanged.frontend/docs/CSP.md4. CSP regression test for wallet connect-src hosts
CSP changes can silently break wallets — a refactor can drop a Stellar host and nothing fails until a wallet throws a CSP violation in production.
frontend/src/lib/csp.test.tsasserting: every default Stellar host isresent, env-configured RPC/Horizon hosts are added and deduped, arbitraryunconfigured hosts are rejected, andlocalhost:*/127.0.0.1:*only appear outside production.DEFAULT_STELLAR_he docs together) infrontend/docs/CSP.md`.Changes
Test Plan
Automated tests added or updated
backend/src/**/*.spec.ts) — service/guard/decorator logic in isolationbackend/test/**/*.e2e-spec.ts) — HTTP round-trips with mocked infrastructurefrontend/src/**/*.test.{ts,tsx}) — React component behaviourfrontend/e2e/**/*.spec.ts) — Playwright browser flowscontract/) — Soroban/Rust unit tests viacargo testHow to run the tests locally
Manual verification checklist
cd backend && npm run lint/cd frontend && npm run lintRelated issues
Notes for reviewers
Closes #1492
Closes #1493
Closes #1488
Closes #1494