mirror of
https://github.com/stablyai/orca.git
synced 2026-11-16 19:07:41 +00:00
* 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
26 lines
974 B
Swift
26 lines
974 B
Swift
/// CSP belongs only on the document response; it is inert on subresources.
|
|
enum MobileWebShellResponseHeaders {
|
|
static func forPath(
|
|
_ path: String,
|
|
contentType: String,
|
|
byteCount: Int
|
|
) -> [String: String] {
|
|
var headers = [
|
|
"Content-Type": contentType,
|
|
"Content-Length": String(byteCount),
|
|
"Cache-Control": "no-store",
|
|
"X-Content-Type-Options": "nosniff"
|
|
]
|
|
if path == "/" {
|
|
headers["Content-Security-Policy"] = MobileWebShellCsp.header
|
|
// HTTPS images can expose session identity: Android uses a hashed host, iOS the verbatim id.
|
|
// WebKit srcdoc images leaked the embedder origin despite iframe referrerPolicy; set the document header.
|
|
headers["Referrer-Policy"] = "no-referrer"
|
|
} else if path == MobileWebShellChatVisualFrame.path {
|
|
headers["Content-Security-Policy"] = MobileWebShellChatVisualFrame.csp
|
|
headers["Referrer-Policy"] = "no-referrer"
|
|
}
|
|
return headers
|
|
}
|
|
}
|