mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-16 23:03:06 +00:00
src/auth/grant-age.ts owns GRANT_MAX_AGE_SECONDS and a pure check over the grant's `grantIssuedAt` prop; oauth.ts wires it into the provider's tokenExchangeCallback so both code exchanges and refreshes fail closed with invalid_grant once a grant is older than 90 days — or whenever the timestamp is missing or malformed. The upstream session cannot be refreshed, so a grant must eventually re-consent; this is also the runway for swapping the upstream credential later. Tests: 6 function-level cases (fresh, boundary ±1s, 90-day default, malformed/missing timestamps fail closed, explicit maximum) and 2 end-to-end cases through /token (aged-out grant and timestamp-less grant both → 400 invalid_grant). A test bug found on the way — passing undefined to a defaulted parameter applies the default — is fixed with an explicit null sentinel. pnpm check: typecheck, eslint, prettier, 105 tests passing. Claude-Session: https://claude.ai/code/session_01H3gfN2NCx3hBXSrZXYHUQ3