Files
causius/lib/security.ts
CatoandClaude Opus 5.5 40a5c4b05d Matters, the fleet design system and a technical narrative (#10)
* Matters: encrypted, agentic legal workspace behind OrangeCat sign-in

A matter is sealed per matter (AES-256-GCM data key under CAUSIUS_MASTER_KEY).
The agent works it with tools (search, read, deadlines, tasks, drafts,
approvals); every personal detail is swapped for a placeholder before a model
sees it, and the person's account name is always one of them. The database in
the clear holds no name, message, deadline or document.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012EJFFkKhmaVnnH8E3mHnaZ

* Fleet design system, a technical narrative, one account across the fleet, domain checks

- @bitbaum/design-tokens replaces the bespoke paper-and-ink theme; Solon's
  grammar (kicker, headline-caps, btn-frame) for every page, pinned dark.
- New Platform, Security and Ecosystem pages; the home page rebuilt around what
  works today (lib/capabilities.ts is the one place a status is decided).
- Sign-in and sign-up routes hand straight to OrangeCat; the account menu and
  the ecosystem page link the rest of the fleet, read from the fleet map.
- The agent can check domain names with the registries over RDAP.
- The i18n parity test reads ICU properly (select branches, apostrophes).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012EJFFkKhmaVnnH8E3mHnaZ

* Provision matters on the host: database, OrangeCat client, runtime env

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012EJFFkKhmaVnnH8E3mHnaZ

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-11 12:23:14 -07:00

64 lines
2.7 KiB
TypeScript

/**
* The site's security headers, in one place.
*
* Causius holds the most private paperwork people have — migration, tax,
* court, debt — so the browser is told to trust as little as possible:
*
* - scripts only from this origin, and only those carrying this response's
* nonce (`strict-dynamic` lets those load their own chunks, nothing else);
* - network requests only to this origin: a case can be read only by the page
* that made it, and a script that slipped in still has nowhere to send it;
* - no framing (clickjacking), no plugins, no <base> rewriting, forms post
* only here;
* - HTTPS only, for two years, subdomains included;
* - no referrer leaves the site: a case URL never shows up in someone else's
* logs;
* - camera, microphone, location and payment APIs are off for every frame.
*
* The Loki feedback widget is the one third party, and it is allowed only when
* this deployment turns the widget on.
*/
const LOKI = "https://loki.orangecat.ch";
export function contentSecurityPolicy(
nonce: string,
{ dev = false, widget = false }: { dev?: boolean; widget?: boolean } = {},
): string {
const extra = widget ? ` ${LOKI}` : "";
return [
"default-src 'self'",
// `unsafe-eval` only in development, where React needs it for its stacks.
`script-src 'self' 'nonce-${nonce}' 'strict-dynamic'${dev ? " 'unsafe-eval'" : ""}`,
// Next and bip-kit set a few inline style attributes; styles cannot run
// code, and blocking them would only break layout.
"style-src 'self' 'unsafe-inline'",
// blob: and data: for the page photos previewed before they are sent.
"img-src 'self' blob: data:",
"font-src 'self'",
`connect-src 'self'${extra}${dev ? " ws:" : ""}`,
widget ? `frame-src ${LOKI}` : "frame-src 'none'",
"worker-src 'self' blob:",
"object-src 'none'",
"base-uri 'self'",
// Sign-in posts here and is redirected to OrangeCat's authorize page.
"form-action 'self' https://orangecat.ch",
"frame-ancestors 'none'",
"upgrade-insecure-requests",
].join("; ");
}
/** Headers for every response, pages and API alike. Read by next.config.ts. */
export const SECURITY_HEADERS: { key: string; value: string }[] = [
{ key: "Strict-Transport-Security", value: "max-age=63072000; includeSubDomains" },
{ key: "X-Content-Type-Options", value: "nosniff" },
{ key: "X-Frame-Options", value: "DENY" },
{ key: "Referrer-Policy", value: "no-referrer" },
{
key: "Permissions-Policy",
value:
"camera=(), microphone=(), geolocation=(), payment=(), usb=(), serial=(), bluetooth=(), interest-cohort=()",
},
{ key: "Cross-Origin-Opener-Policy", value: "same-origin" },
{ key: "Cross-Origin-Resource-Policy", value: "same-origin" },
];