fix: add expiration to download tokens (30-day TTL)
From the PR description
Summary
- Adds an
exp(Unix timestamp) field to every HMAC-signed download token verifyDownloadrejects tokens whoseexpis in the past- Default TTL is 30 days - generous enough for links stored in chat history, bounded enough to limit exposure if the signing secret is ever rotated
- Old tokens without an
expfield are still accepted (backward compat)
Closes #68
Changes
backend/src/lib/downloadTokens.ts-signDownloadgains optionalttlSecondsparam (default 30 days);verifyDownloadchecksexpwhen presentbackend/src/lib/__tests__/downloadTokens.test.ts- 5 unit tests covering round-trip, tampering, exp field presence, rejection of expired tokens, and acceptance of valid tokensbackend/vitest.config.ts+backend/package.json- vitest added
Test plan
- Unit tests: round-trip, tamper, exp field present, expired → null, valid → ok
- Build and typecheck pass Closes #91
Our analysis
Add expiry to HMAC-signed download tokens — read the full analysis →
Think the analysis missed something the PR description covers?
Capture this PR into my fork
Download a Markdown prompt that tells Claude how to port every
commit in this PR into your working tree. Run it via
claude -p < capture-pull-77.md from
inside the repo you want the changes in.