fix(web-app): map ws:// relay URL to http:// for CSP connect-src#703
Open
Priyanshubhartistm wants to merge 1 commit into
Open
fix(web-app): map ws:// relay URL to http:// for CSP connect-src#703Priyanshubhartistm wants to merge 1 commit into
Priyanshubhartistm wants to merge 1 commit into
Conversation
Signed-off-by: Priyanshubhartistm <bhartipriyanshustm@gmail.com>
🦋 Changeset detectedLatest commit: c309631 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Collaborator
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.
Description
createWebAppinsrc/factories/web-app-factory.tsbuilds theContent-Security-Policyconnect-srcdirective by deriving an HTTP(S) origin from the relay's WebSocket URL. Thewss:case correctly maps tohttps:, but theelsebranch assigned the string':'instead of'http:'. Because':'is not a valid scheme, the WHATWG URL API silentlyignores the assignment, so
webRelayUrlkeeps itsws:protocol andconnect-srcends up with aws://…entry instead of the intendedhttp://…origin.This one-character fix maps
ws:→http::Related Issue
Closes #700
Motivation and Context
For relays served over plain
ws://(local/dev, Tor, or reverse-proxied setups), the CSPconnect-srcfor the invoices/terms pages was wrong — it advertised aws://origin where anhttp://origin was intended. This produces an incorrect security header for those deployments. Thewss:→https:path was already correct and is unaffected.How Has This Been Tested?
pnpm lint— Biome lint passes (328 files, no errors)pnpm check:deps— Knip passespnpm run build:check,pnpm run build,pnpm run verify:cli:build— all passpnpm run test:unit(1392 passing),pnpm run test:cli(73 passing),pnpm run cover:unit(1393 passing) — all greenpnpm exec changeset status --since origin/main— changeset presentEnvironment: Linux, Node/pnpm per
.nvmrc, Docker v2.1.0.Screenshots (if appropriate):
N/A — no visual change.
Types of changes
Checklist: