Files
orca/mobile/modules/orca-mobile-web-shell/ios/MobileWebShellCsp.swift
Kelvin Amoaba f375aba997 fix(mobile): make chat report buttons work in an isolated frame (#42954)
* fix(mobile): run chat report scripts in an isolated shell frame

* fix(mobile): theme chat visuals at handoff and pin the iOS frame to Android's

* test(mobile): probe the page origin by absolute URL from the visual
2026-11-16 06:12:04 +00:00

32 lines
1.8 KiB
Swift
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
enum MobileWebShellCsp {
/// Native document-response policy cannot be relaxed by a bundle/meta tag; keep both platforms in sync.
static let header = [
"default-src 'none'",
"script-src 'self'",
// React Native Web 0.21.2 injects styles without nonces; allow inline styling while keeping script-src 'self'.
"style-src 'self' 'unsafe-inline'",
// data: supports base64 file previews; https: supports agent/project icons and sealed srcdoc images.
// Markdown images remain links, the editor is plain source, and web review avatars are skipped (C7.10).
// Scheme matching constrains destination, not provenance/MIME/body: any image URL is allowed.
// Image/SVG fetches cannot execute script; script/connect/object policies remain strict. HTTPS images
// can reveal a document was opened, so Referrer-Policy hides session identity. Exclude mutable cleartext http:.
"img-src 'self' data: blob: https:",
// Terminal fonts use bundled same-origin assets or embedded data URLs.
"font-src 'self' data:",
// fetch/XHR can read only this generation’s manifest-mapped directory, including bootstrap’s manifest.json.
// The document-start blocker covers WebSocket and service-worker APIs that native cannot intercept.
"connect-src 'self'",
// Media previews play bytes downloaded through authenticated RPC, never a network URL.
"media-src blob:",
"object-src 'none'",
// Admits the chat visual frame; the shell document refuses framing and nothing else served is a page.
"frame-src 'self'",
"child-src 'none'",
"worker-src 'none'",
// Preserve srcdoc’s about: base/in-page links without admitting network bases.
"base-uri about:",
"form-action 'none'",
"frame-ancestors 'none'"
].joined(separator: "; ")
}