chore: upgrade Node.js runtime to v24 across codebase #419

Merged
jason.woltje merged 438 commits from fix/auth-frontend-remediation into main 2026-02-17 01:04:47 +00:00
Showing only changes of commit 31ce9e920c - Show all commits

View File

@@ -113,34 +113,24 @@ describe("ApiKeyGuard", () => {
const validApiKey = "test-api-key-12345"; const validApiKey = "test-api-key-12345";
vi.mocked(mockConfigService.get).mockReturnValue(validApiKey); vi.mocked(mockConfigService.get).mockReturnValue(validApiKey);
const startTime = Date.now(); // Verify that same-length keys are compared properly (exercises timingSafeEqual path)
const context1 = createMockExecutionContext({ // and different-length keys are rejected before comparison
"x-api-key": "wrong-key-short", const sameLength = createMockExecutionContext({
"x-api-key": "test-api-key-12344", // Same length, one char different
});
const differentLength = createMockExecutionContext({
"x-api-key": "short", // Different length
}); });
try { // Both should throw, proving the comparison logic handles both cases
guard.canActivate(context1); expect(() => guard.canActivate(sameLength)).toThrow("Invalid API key");
} catch { expect(() => guard.canActivate(differentLength)).toThrow("Invalid API key");
// Expected to fail
}
const shortKeyTime = Date.now() - startTime;
const startTime2 = Date.now(); // Correct key should pass
const context2 = createMockExecutionContext({ const correct = createMockExecutionContext({
"x-api-key": "test-api-key-12344", // Very close to correct key "x-api-key": validApiKey,
}); });
expect(guard.canActivate(correct)).toBe(true);
try {
guard.canActivate(context2);
} catch {
// Expected to fail
}
const longKeyTime = Date.now() - startTime2;
// Times should be similar (within 10ms) to prevent timing attacks
// Note: This is a simplified test; real timing attack prevention
// is handled by crypto.timingSafeEqual
expect(Math.abs(shortKeyTime - longKeyTime)).toBeLessThan(10);
}); });
}); });
}); });