Files
explicata/tests/csp.test.ts
T
thalladaandClaude Fable 5.2 f8c6576ea1 Web pages: a link to any address opens as an article, as Wikipedia's do
A url link now opens in the app instead of the browser. The server fetches
the page (robots.txt honoured, public addresses only, size and time caps),
keeps a snapshot on disk until it is reloaded, and cuts it into a lead and
sections: by its headings, else by pseudo-headings, else in chunks, or by a
model when asked (s), within a daily budget. The pane has its own amber
ground, the author and date in its head when the page gives them, and the
source in its foot. W opens the original, R reads it again. See
docs/pages.md.

Pictures and videos are kept, in web pages and in Wikipedia articles:
pictures through the server (only addresses seen in a page that was read),
videos as a still that loads the player on a click.

A section that is only a link (a target, no text, no sections) opens as
its article at once, and L opens a target to the right of the node's own
pane, never under it.

Article text is sized to read like the reader's own.

Panes: a pane that already has all its column can give beside the others'
tabs no longer peeks over them on hover, and the curves of tabs under a
peeking pane are no longer drawn over it. The keypress timing test judges
each of its two passes on its own, so a stall from outside the app does
not fail it.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014yB6q4BHMwptTX3YFtkRab
2026-11-18 13:44:13 -05:00

18 lines
1.2 KiB
TypeScript

/** server/csp.ts: the page's Content-Security-Policy, exactly, so a loosening shows up as a failing test. */
import { describe, expect, it } from "vitest";
import { CSP } from "../server/csp";
describe("the page's Content-Security-Policy", () => {
it("lets video files load from https and frames only YouTube's privacy-enhanced player and Vimeo's; nothing else loads from elsewhere", () => {
expect(CSP).toBe(
"default-src 'self'; script-src 'self' 'wasm-unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' data: blob:; media-src https:; font-src 'self' data:; connect-src 'self'; frame-src https://www.youtube-nocookie.com https://player.vimeo.com; object-src 'none'; base-uri 'none'; form-action 'none'",
);
const d = Object.fromEntries(CSP.split("; ").map((x) => [x.split(" ")[0], x.split(" ").slice(1)]));
// Images only from the app itself: every picture in article text comes through a media route.
expect(d["img-src"]).toEqual(["'self'", "data:", "blob:"]);
expect(d["frame-src"]).toEqual(["https://www.youtube-nocookie.com", "https://player.vimeo.com"]);
expect(d["media-src"]).toEqual(["https:"]);
expect(d["script-src"]).not.toContain("'unsafe-inline'");
});
});