@csrf/csrf
generateCsrfToken, // Use this in your routes to provide a CSRF token.
Official Documentation ↗v1.0. Check the official docs for the latest API surface.Installation
npm install csrf-csrfpnpm add csrf-csrfyarn add csrf-csrfMethods
No methods match this filter.
Overview
generateCsrfToken, // Use this in your routes to provide a CSRF token. validateRequest, // Also a convenience if you plan on making your own middleware.
API reference status
This page lists only entry points that appear verbatim in the official README examples: generateCsrfToken, doubleCsrf. Parameter and return types are not given by the official README, so signatures are marked unverified.
Errors
The following points are quoted verbatim from the official documentation. 来源:https://cdn.jsdelivr.net/gh/Psifi-Solutions/csrf-csrf@latest/README.md · 取证方式:HTTP GET 官方 README/文档页(HTML 去标签) · 抓取时间:2026-11-07T13:49:02.907Z. Any error type, throw condition or recovery step not stated there is left unspecified; this page does not infer exception classes or return values.
- For additional information on figuring out the error see the “Dealing with ‘ForbiddenError: invalid csrf token’” section of the FAQ. (https://cdn.jsdelivr.net/gh/Psifi-Solutions/csrf-csrf@latest/README.md)
- If overwrite is true a new token will always be generated, even if the current one is invalid. (https://cdn.jsdelivr.net/gh/Psifi-Solutions/csrf-csrf@latest/README.md)
Security notes
Quoted verbatim from the official documentation; this is not a complete threat model. 来源:https://cdn.jsdelivr.net/gh/Psifi-Solutions/csrf-csrf@latest/README.md · 取证方式:HTTP GET 官方 README/文档页(HTML 去标签) · 抓取时间:2026-11-07T13:49:02.907Z.
- Double CSRF A utility package to help implement stateless CSRF (Cross-Site Request Forgery) protection using the signed Double Submit Cookie Pattern in express. (https://cdn.jsdelivr.net/gh/Psifi-Solutions/csrf-csrf@latest/README.md)
- Getting Started • Configuration • Utilities • FAQ • Support Background This module provides the necessary pieces required to implement CSRF protection using the signed Double Submit Cookie Pattern . (https://cdn.jsdelivr.net/gh/Psifi-Solutions/csrf-csrf@latest/README.md)
- This is a stateless CSRF protection pattern, if you are using sessions it is highly recommended that you use csrf-sync for the Synchroniser Token Pattern instead. (https://cdn.jsdelivr.net/gh/Psifi-Solutions/csrf-csrf@latest/README.md)
Verification notes
- Official source: https://github.com/Psifi-Solutions/csrf-csrf
- Evidence: https://cdn.jsdelivr.net/gh/Psifi-Solutions/csrf-csrf@latest/README.md
- Checked on 2026-11-04 by
scripts/phase11/build-api-profiles.mjs
FAQ
- What does csrf-csrf do?
- generateCsrfToken, // Use this in your routes to provide a CSRF token.
- How do I install csrf-csrf?
- Run `npm install csrf-csrf`.
- Where can I verify the API details?
- Official repository/documentation: https://github.com/Psifi-Solutions/csrf-csrf. Checked on 2026-11-04; signatures and return values not stated in the official README are marked unverified.
Report a problem with this API docOpens a pre-filled issue on GitHub.