Skip to content

fix: add expiration to download tokens (30-day TTL)#77

Open
bmersereau wants to merge 5 commits into
willchen96:mainfrom
bmersereau:fix/68-expiring-download-tokens
Open

fix: add expiration to download tokens (30-day TTL)#77
bmersereau wants to merge 5 commits into
willchen96:mainfrom
bmersereau:fix/68-expiring-download-tokens

Conversation

@bmersereau
Copy link
Copy Markdown

@bmersereau bmersereau commented May 13, 2026

Summary

  • Adds an exp (Unix timestamp) field to every HMAC-signed download token
  • verifyDownload rejects tokens whose exp is 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 exp field are still accepted (backward compat)

Closes #68

Changes

  • backend/src/lib/downloadTokens.tssignDownload gains optional ttlSeconds param (default 30 days); verifyDownload checks exp when present
  • backend/src/lib/__tests__/downloadTokens.test.ts — 5 unit tests covering round-trip, tampering, exp field presence, rejection of expired tokens, and acceptance of valid tokens
  • backend/vitest.config.ts + backend/package.json — vitest added

Test plan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant