You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* @property {number} [tokenLength=16] - The length of the CSRF token in bytes.
13
+
* @property {Object} [storage] - The storage configuration for the CSRF token.
14
+
* @property {string} [storage.type='session'] - The type of storage to use for the CSRF token ('session' or 'cookie').
15
+
* @property {Object} [storage.options={}] - Options to pass to the cookie storage (e.g., `domain`, `path`, `secure`, `httpOnly`). Only applicable when `storage.type` is 'cookie'.
16
+
* @property {string} [param='_csrf'] - The name of the request body or query parameter to check for the CSRF token.
17
+
* @property {string} [value='csrfToken'] - The name of the local variable to set the CSRF token to for use in templates.
18
+
* @property {function} [errorResponse] - A function to call when the CSRF token is invalid. It should accept `(req, res, next)` and send an appropriate error response.
19
+
* @property {function} [protectCondition] - A function to determine if CSRF protection should be applied. It should accept `(req)` and return `true` to protect, `false` to skip.
20
+
* @property {function} [getTransmitToken] - A function to retrieve the CSRF token from the request. It should accept `(req)` and return the token string or `null`.
* - The name of the request body or query parameter to check for the CSRF token.
25
+
*/
26
+
param?: string;
27
+
/**
28
+
* - The name of the local variable to set the CSRF token to for use in templates.
29
+
*/
30
+
value?: string;
31
+
/**
32
+
* - A function to call when the CSRF token is invalid. It should accept `(req, res, next)` and send an appropriate error response.
33
+
*/
34
+
errorResponse?: Function;
35
+
/**
36
+
* - A function to determine if CSRF protection should be applied. It should accept `(req)` and return `true` to protect, `false` to skip.
37
+
*/
38
+
protectCondition?: Function;
39
+
/**
40
+
* - A function to retrieve the CSRF token from the request. It should accept `(req)` and return the token string or `null`.
41
+
*/
42
+
getTransmitToken?: Function;
43
+
};
44
+
typeCsrf={
45
+
/**
46
+
* - The name of the request body or query parameter to check for the CSRF token.
47
+
*/
48
+
param: string;
49
+
/**
50
+
* - The name of the local variable to set the CSRF token to for use in templates.
51
+
*/
52
+
value: string;
53
+
/**
54
+
* - The storage configuration for the CSRF token.
55
+
*/
56
+
storage: {
57
+
type: string;
58
+
options: any;
59
+
};
60
+
/**
61
+
* - The length of the CSRF token in bytes.
62
+
*/
63
+
tokenLength: number;
64
+
/**
65
+
* - A function to get the CSRF token from the request.
66
+
*/
67
+
getToken: Function;
68
+
/**
69
+
* - A function to clear the CSRF token from the request and/or response.
70
+
*/
71
+
clearToken: Function;
72
+
/**
73
+
* - A function to determine if CSRF protection should be applied.
74
+
*/
75
+
protectCondition: Function;
76
+
/**
77
+
* - A function to retrieve the CSRF token from the request.
78
+
*/
79
+
getTransmitToken: Function;
80
+
/**
81
+
* - A function to call when the CSRF token is invalid.
82
+
*/
83
+
errorResponse: Function;
84
+
};
85
+
/**
86
+
* @typedef {Object} CsrfConfig
87
+
* @property {number} [tokenLength=16] - The length of the CSRF token in bytes.
88
+
* @property {Object} [storage] - The storage configuration for the CSRF token.
89
+
* @property {string} [storage.type='session'] - The type of storage to use for the CSRF token ('session' or 'cookie').
90
+
* @property {Object} [storage.options={}] - Options to pass to the cookie storage (e.g., `domain`, `path`, `secure`, `httpOnly`). Only applicable when `storage.type` is 'cookie'.
91
+
* @property {string} [param='_csrf'] - The name of the request body or query parameter to check for the CSRF token.
92
+
* @property {string} [value='csrfToken'] - The name of the local variable to set the CSRF token to for use in templates.
93
+
* @property {function} [errorResponse] - A function to call when the CSRF token is invalid. It should accept `(req, res, next)` and send an appropriate error response.
94
+
* @property {function} [protectCondition] - A function to determine if CSRF protection should be applied. It should accept `(req)` and return `true` to protect, `false` to skip.
95
+
* @property {function} [getTransmitToken] - A function to retrieve the CSRF token from the request. It should accept `(req)` and return the token string or `null`.
0 commit comments