tiny-essentials
Version:
Collection of small, essential scripts designed to be used across various projects. These simple utilities are crafted for speed, ease of use, and versatility.
23 lines • 1.06 kB
text/typescript
/**
* @function csrfTokenAnalyze
*
* Checks if the CSRF token in the request body matches the expected token from the session.
* If invalid, returns a 401 response and optionally executes a custom callback.
*
* @param {import('express').Request} req - The Express request object. Should contain:
* - `req.csrfToken.now`: The expected CSRF token.
* - `req.body.csrfToken`: The token provided by the client.
* @param {import('express').Response} res - The Express response object.
* @param {Function} [callback] - Optional custom callback to execute when CSRF validation fails.
*
* @returns {boolean} Returns `true` if the token is invalid and a response was sent, otherwise `false`.
* @deprecated
*
* @example
* app.post('/submit', (req, res) => {
* if (csrfTokenAnalyze(req, res)) return;
* // Continue with request logic if CSRF is valid
* });
*/
export default function csrfTokenAnalyze(req: import("express").Request, res: import("express").Response, callback?: Function): boolean;
//# sourceMappingURL=csrfTokenAnalyze.d.mts.map