From 51c31e6bf6bcd74f75dea21fef70b525e9afe2f0 Mon Sep 17 00:00:00 2001 From: patrick Date: Wed, 12 Aug 2026 01:37:19 -0400 Subject: [PATCH] docs: document the foliate-js reader Adds a reader section covering the vendored tree, the $foliate alias and the traps around it, and refreshes the stale stack line, oklch claim and rough edges. Records why CSP is not enabled in TODO.md. --- AGENTS.md | 16 +++++---- TODO.md | 23 ++++++++++++ frontend/AGENTS.md | 90 +++++++++++++++++++++++++++++++++++++--------- 3 files changed, 106 insertions(+), 23 deletions(-) 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 `