# Tasks
Work in this order. Finish each task's check before starting the next one.
1. **Set up (R1).**
- One npm package: the Vite + React client in `src/client`, the Worker in `src/worker`, shared code in `src/shared`.
- Add `wrangler.jsonc` and the scripts from `design.md` ("Cloudflare config"), then run `npm run types`.
- `src/shared/settings.ts` reads `spekkr.inputs.json` at build time (the Worker imports it too). `vite.config.ts` puts `app_name` into the `
`.
- Add `GET /api/health`.
Check: `npm run dev` serves a page titled `app_name`, and `/api/health` answers `{ ok: true }`. `npx wrangler deploy --dry-run --outdir /tmp/dry` bundles. Do not log in to Cloudflare or deploy.
2. **Shared helpers.** Write `time.ts`, `allowlist.ts`, `range.ts`, `parts.ts`, `ids.ts` and `limits.ts` from `design.md`, plus `tests/shared.test.ts`.
Check: `npm test` passes every unit test named in `spec.md` "Tests" except "camera bubble" (step 5).
3. **Database and accounts (R2).**
- Add `migrations/0001_init.sql`.
- Passwords: PBKDF2-SHA-256 at 100000 iterations with a 16-byte salt, stored as `pbkdf2$100000$$`.
- Sessions: a 32-byte token in the `sid` cookie (`HttpOnly; Secure; SameSite=Lax; Path=/; Max-Age` 30 days), stored as its SHA-256 hex.
- Add the allowlist check on sign-up, on sign-in, and on every request that loads a session. Then the auth endpoints, `/api/me`, the sign-in page and the top bar.
Check: the three `1-accounts` tests. Also check by hand that removing an email from `ALLOWED_EMAILS` (restart `wrangler dev` with a different `--var`) signs that account out at its next request.
4. **Upload API (R5, R16).**
- Video create, parts, complete, abort, thumbnail, media (with `Range`) and thumbnail read.
- Add the `Origin` check and the three rate limits. Return 507 when the storage limit is reached.
- Add the stuck-upload cleanup in the library list.
Check: `6-api` "cross-site writes are refused and inputs are checked". Also upload a small WebM through `page.request` in three parts and read it back with `Range: bytes=0-99` (206, 100 bytes).
5. **Recorder (R3, R4).**
- `lib/recorder.ts` per `design.md` "Recording pipeline", `lib/upload.ts`, and the `/record` page: setup, the bubble, the countdown, the recording bar, upload progress, and the camera-only fallback.
- Add the "camera bubble" unit test.
Check: the four `2-record` tests. Then download a screen + camera recording and confirm that `ffprobe` (or a `