refactor: drop redundant iat intersections and reuse JwtPayload in tests

JwtPayload already declares iat?: number, so the & { iat?: number } in
makeRequireAuth and slideSessionIfNeeded was a no-op. The unit test had a
local TestPayload duplicating the same shape — replaced with the canonical
import.
This commit is contained in:
2026-05-09 10:23:24 -07:00
parent a4355e1ef3
commit cbc22dcac4
3 changed files with 10 additions and 15 deletions

View File

@@ -33,7 +33,7 @@ export function issueSessionCookie(
export function makeRequireAuth(config: Config) {
return async function requireAuth(request: FastifyRequest, reply: FastifyReply): Promise<void> {
try {
const payload = await request.jwtVerify<JwtPayload & { iat?: number }>();
const payload = await request.jwtVerify<JwtPayload>();
slideSessionIfNeeded(request, reply, payload, request.server, config.cookieSecure);
} catch {
const isApi = request.url.startsWith('/api/');

View File

@@ -7,7 +7,7 @@ import { issueSessionCookie } from './auth.ts';
export function slideSessionIfNeeded(
request: FastifyRequest,
reply: FastifyReply,
payload: JwtPayload & { iat?: number },
payload: JwtPayload,
server: FastifyInstance,
cookieSecure: boolean,
): void {