mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-10 07:11:25 +03:00
fix(cli): let the web app start the QR scanner worker (#53278)
This commit is contained in:
committed by
GitHub
Unverified
parent
999097bdac
commit
63e33bc4dc
@@ -58,8 +58,10 @@ function isRouteNotFound(error: unknown) {
|
||||
return error instanceof HttpServerError.HttpServerError && error.reason._tag === "RouteNotFound"
|
||||
}
|
||||
|
||||
// qr-scanner decodes in a worker it creates from a blob: URL whenever the browser has no BarcodeDetector (Safari, desktop
|
||||
// Chrome on Windows and Linux). Without worker-src that worker falls under script-src 'self' and never starts.
|
||||
function csp(hash = "") {
|
||||
return `default-src 'self'; script-src 'self' 'wasm-unsafe-eval'${hash ? ` 'sha256-${hash}'` : ""}; style-src 'self' 'unsafe-inline'; img-src 'self' data: https: blob:; font-src 'self' data:; media-src 'self' data:; connect-src * data: blob:`
|
||||
return `default-src 'self'; script-src 'self' 'wasm-unsafe-eval'${hash ? ` 'sha256-${hash}'` : ""}; style-src 'self' 'unsafe-inline'; img-src 'self' data: https: blob:; font-src 'self' data:; media-src 'self' data:; connect-src * data: blob:; worker-src 'self' blob:`
|
||||
}
|
||||
|
||||
function cspForHtml(body: string) {
|
||||
|
||||
@@ -171,6 +171,7 @@ describe("web UI", () => {
|
||||
expect(yield* Effect.promise(() => fallback.text())).toContain("embedded")
|
||||
expect(fallback.headers.get("content-security-policy")).toContain("default-src 'self'")
|
||||
expect(fallback.headers.get("content-security-policy")).toContain("connect-src * data: blob:")
|
||||
expect(fallback.headers.get("content-security-policy")).toContain("worker-src 'self' blob:")
|
||||
|
||||
const dotted = yield* Effect.promise(() => fetch(`${origin}/workspace/example.js`))
|
||||
expect(dotted.status).toBe(200)
|
||||
|
||||
Reference in New Issue
Block a user