$ show fastify/fastify-cookie
@fastify/cookie is a Fastify plugin that adds cookie handling capabilities to Fastify applications. It provides automatic parsing of incoming cookies via Fastify hooks and methods to set, clear, and sign cookies on responses. The plugin integrates with Fastify's lifecycle through decorators and hooks, supporting various hook points for cookie parsing (onRequest, preParsing, etc.). It includes robust security features like cookie signing with HMAC, key rotation support, and protection against timing attacks. The implementation follows Fastify plugin best practices and provides both high-level convenience methods and low-level utilities for direct use.
The LLM identified 1 files worth highlighting for reuse:
This file implements a self-contained cookie signing utility with HMAC-based signatures, key rotation support, and proper cryptographic practices. It includes functions for signing and verifying cookie values, with special handling for cookie-specific base64 encoding (removing padding). The implementation uses timing-safe comparison to prevent timing attacks and supports key renewal detection. This component could be extracted and used in any Node.js project requiring secure cookie handling or similar data signing/verification needs.