Repository navigation
Capture inbox: fast dump page and token API - #9
Conversation
- Migration 002 adds dumps.status (new | triaged | archived).
- DB functions to create, list, update status and delete dumps.
- Inbox page: autofocused textarea, Ctrl/Cmd+Enter saves, recent dumps
newest first with relative time and delete.
- POST /api/dumps accepts text/plain or JSON {text}, guarded by a bearer
token from DUMPDOWN_API_TOKEN (disabled with 404 when unset).
- SvelteKit's global origin check rejects text/plain posts without an
Origin header (curl, iOS Shortcuts) and cannot be scoped per route, so
it now runs in the handle hook for everything except /api/*.
- README documents ORIGIN, the API, curl examples and an iOS Shortcuts hint.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Hi! I reviewed this against #2. It's a clean, well-scoped PR. Approving 🎉 Scope vs. #2: all covered
What I ran locally:
About disabling SvelteKit's CSRF check ( Security also looks good: auth runs before the body is read, the compare is constant-time over SHA-256 digests (so it doesn't leak the token length either), queries are parameterized, a blank token is treated as unset, and no secrets are committed. Non-blocking nits / follow-ups:
Great work, especially the progressive enhancement and the clear error codes. -- OpenSourcerer (Rootshift review) |
Summary
002_dump_status.sqladdsdumps.status(new | triaged | archived, CHECK-constrained, existing processed dumps becometriaged).src/lib/server/dumps.tshas typed create, get, list (newest first, optional status filter), set-status and delete functions.use:enhance; it also works without JS). Below it, recent dumps newest first with relative time ("just now", "3 hours ago"), status and delete.POST /api/dumps: acceptstext/plainor JSON{"text": "..."}withAuthorization: Bearer $DUMPDOWN_API_TOKEN. Returns 201 with the dump, 401 for a missing or wrong token (constant-time compare), 400 for empty text or bad JSON, 415 for other content types, and 404 while the token is unset (API disabled).docker-compose.ymlpasses throughORIGINandDUMPDOWN_API_TOKEN.Design call: CSRF check moved into
handleSvelteKit's built-in origin check rejects any
text/plainPOST without a matchingOriginheader. That blocks curl and iOS Shortcuts before the route runs, and it can't be scoped per route. Sovite.config.tssetscsrf.trustedOrigins: ['*'], andsrc/lib/server/csrf.tsandhooks.server.tsre-implement the check more strictly: every non-GET request outside/api/*must carry anOriginequal to the app origin./api/*relies on its bearer token, which a browser can't forge cross-site. As before, adapter-node needsORIGINset when serving over plain HTTP; this is now documented.Testing
npm run lint,npm run check,npm test(37 tests) andnpm run buildall pass locally.DUMPDOWN_API_TOKENandDATABASE_PATHstubbed, the DB functions and status CHECK, the CSRF predicate, the inbox form actions and relative time.node build) with curl: text/plain 201, JSON 201, wrong token 401, same-origin form POST 200, foreign or missing Origin 403.Closes #2
🤖 Generated with Claude Code