Files
artcraft/mcp/test
Tanish Manku 99fce07806 mcp: enforce the 90-day absolute grant lifetime on every token exchange
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
2026-08-24 20:34:03 -07:00
..