Files
Komediruzecki 8dadb7a359 feat(worker): field encryption at rest, server-side, per-user keys
Seals transaction text (description, beneficiary, payor, notes),
recurring rules (description, notes), bills (name, notes) and receipt
files with AES-256-GCM under a per-user data key, itself wrapped by a
master key from Workers Secrets (DATA_KEK_<n>). The Worker decrypts to
compute, so every feature keeps working; this protects a leaked D1
export, backup artifact or bucket, not the data from the operator. It
is not end-to-end encryption, which is dropped.

Ships dark: with no DATA_KEK_<n> every route keeps its original SQL and
nothing is sealed. With a key, SQL work over sealed text (LIKE, text
ORDER BY, GROUP BY) moves to JS over opened rows and reproduces
SQLite's answers exactly. Edits use a two-statement batch so they land
in whichever form the row is in when the backfill races them; the
backfill (*/20 cron) is the only place a row changes form, by
compare-and-set.

Migration 0031 adds users.dek_wrapped, text_enc on the three tables,
receipts.enc and a partial index. Schema only.

CI runs the worker suite keyless and keyed (test:sealed).
Design and rollout: docs/plans/field-encryption.md.
2026-09-11 02:39:02 +02:00

120 lines
3.7 KiB
YAML

name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
# Three gates, one per thing that actually ships: the SolidJS frontend, the Cloudflare Worker,
# and lint. Those two runtimes are the whole product — browser-only mode is IndexedDB, cloud mode
# is the Worker. e2e.yml drives the built frontend against a locally-run Worker.
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Setup pnpm
uses: pnpm/action-setup@v6
with:
version: 10
- name: Setup Node.js
uses: actions/setup-node@v7
with:
node-version: '22'
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Typecheck
run: pnpm run typecheck
- name: Run frontend tests
run: pnpm run test
worker:
name: Worker Tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Setup pnpm
uses: pnpm/action-setup@v6
with:
version: 10
- name: Setup Node.js
uses: actions/setup-node@v7
with:
node-version: '22'
cache: 'pnpm'
# Same install as deploy-worker.yml: worker/.gitignore deliberately does not pin a
# lockfile ("deps installed fresh"), so --frozen-lockfile fails with ERR_PNPM_NO_LOCKFILE.
- name: Install worker deps (outside the pnpm workspace)
working-directory: worker
# Frozen, like e2e.yml and deploy-worker.yml. This was --no-frozen-lockfile from #397,
# before worker/pnpm-lock.yaml was committed (#460), and was never brought in line: a
# Dependabot worker PR — which arrives without a lockfile update, see dependabot.yml —
# passed here against whatever resolved that morning and failed E2E on the frozen
# install, which read as a flaky suite. Now every job installs the same pinned tree,
# and a stale lockfile fails here first, with its real error.
run: pnpm install --frozen-lockfile --ignore-workspace
- name: Typecheck
working-directory: worker
run: pnpm run typecheck
# Runs the real Worker in workerd via Miniflare, against a local D1 built from
# worker/migrations/ — so a broken migration fails here rather than at deploy time.
- name: Run worker tests
working-directory: worker
run: pnpm run test
# The same suite again with field encryption ON, under a throwaway key generated for this run
# (test:sealed). The keyless run above proves a deployment with no master key behaves exactly
# as before; this one proves no read path forgets to decrypt. docs/plans/field-encryption.md
- name: Run worker tests with field encryption on
working-directory: worker
run: pnpm run test:sealed
lint:
name: Lint Frontend
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Setup pnpm
uses: pnpm/action-setup@v6
with:
version: 10
- name: Setup Node.js
uses: actions/setup-node@v7
with:
node-version: '22'
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Run ESLint
run: pnpm run lint
# frontend/.prettierrc is the only prettier config under frontend/. A second one
# (.prettierrc.json) once sat beside it, silently losing to .prettierrc by precedence
# while declaring a plugin that never ran -- this gate makes any such drift fail loudly.
- name: Check formatting
run: pnpm run format:check