diff --git a/AGENTS.md b/AGENTS.md index 43764cc..46473a6 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -9,13 +9,15 @@ a KOSync-compatible endpoint. ## Layout -| Path | What | -| --- | --- | -| `backend/` | Litestar REST API + PostgreSQL. See `backend/AGENTS.md`. | -| `frontend/` | SvelteKit SSR web app. See `frontend/AGENTS.md`. | -| `docker-compose.yml` | Production stack: `db` (postgres:17), `backend`, `frontend`. | -| `docs/screenshots/` | Images used by `README.md`. | -| `shell.nix` | Root dev shell; composes the two sub-shells. | +| Path | What | +| -------------------------- | ---------------------------------------------------------------------------------------- | +| `backend/` | Litestar REST API + PostgreSQL. See `backend/AGENTS.md`. | +| `frontend/` | SvelteKit SSR web app. See `frontend/AGENTS.md`. | +| `frontend/src/lib/vendor/` | Vendored `foliate-js` (the EPUB engine), copied by `frontend/scripts/vendor-foliate.sh`. | +| `frontend/static/pdfjs/` | Vendored pdf.js viewer, used by the PDF reader in an iframe. | +| `docker-compose.yml` | Production stack: `db` (postgres:17), `backend`, `frontend`. | +| `docs/screenshots/` | Images used by `README.md`. | +| `shell.nix` | Root dev shell; composes the two sub-shells. | ## Development environment diff --git a/TODO.md b/TODO.md index 8692444..7a94b31 100644 --- a/TODO.md +++ b/TODO.md @@ -51,6 +51,29 @@ Worth adding at the same time: ## Frontend +### No CSP, so scripted EPUBs run against the app origin + +EPUB files may contain JavaScript. foliate-js renders each section in an iframe from a +**same-origin** `blob:` URL and cannot sandbox it — `allow-scripts` is required, and +blob URLs inherit the embedder's origin — so script inside a book can reach `/api/*` +with the session cookie attached. foliate's own README says not to use it without a +Content Security Policy blocking scripts. + +The obvious policy is `kit.csp` in `svelte.config.js` with `script-src: ['self']`, and +deliberately no `default-src` (it would also cover `style-src`/`img-src`/`font-src` and +kill both the book's own blob: assets and the inline `