@fastify/csrf-protection
Advanced tools
Comparing version 6.0.0 to 6.1.0
@@ -20,3 +20,3 @@ 'use strict' | ||
async function csrfPlugin (fastify, opts) { | ||
async function fastifyCsrfProtection (fastify, opts) { | ||
const { | ||
@@ -135,5 +135,7 @@ cookieKey, | ||
module.exports = fp(csrfPlugin, { | ||
module.exports = fp(fastifyCsrfProtection, { | ||
fastify: '4.x', | ||
name: '@fastify/csrf-protection' | ||
}) | ||
module.exports.default = fastifyCsrfProtection | ||
module.exports.fastifyCsrfProtection = fastifyCsrfProtection |
{ | ||
"name": "@fastify/csrf-protection", | ||
"version": "6.0.0", | ||
"version": "6.1.0", | ||
"description": "A plugin for adding CSRF protection to Fastify.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -201,7 +201,16 @@ # @fastify/csrf-protection | ||
```js | ||
fastify.register(require('@fastify/csrf-protection'), { getToken: function (req) { req.headers['csrf'] } }) | ||
fastify.register(require('@fastify/csrf-protection'), | ||
{ getToken: function (req) { return req.headers['csrf-token'] } } | ||
) | ||
``` | ||
or | ||
```js | ||
fastify.register(require('@fastify/csrf-protection'), | ||
{ getToken: (req) => req.headers['csrf-token'] } | ||
) | ||
``` | ||
## License | ||
[MIT](./LICENSE) |
@@ -18,3 +18,3 @@ /// <reference types="node" /> | ||
generateCsrf( | ||
options?: CookieSerializeOptions | ||
options?: fastifyCsrfProtection.CookieSerializeOptions | ||
): FastifyReply; | ||
@@ -24,18 +24,30 @@ } | ||
export type CookieSerializeOptions = FastifyCookieSerializeOptions | ||
type FastifyCsrfProtection = FastifyPluginAsync<fastifyCsrfProtection.FastifyCsrfOptions>; | ||
export type GetTokenFn = (req: FastifyRequest) => string | void; | ||
declare namespace fastifyCsrfProtection { | ||
export type CookieSerializeOptions = FastifyCookieSerializeOptions | ||
export interface FastifyCsrfOptions { | ||
csrfOpts?: CSRFOptions; | ||
cookieKey?: string; | ||
cookieOpts?: CookieSerializeOptions; | ||
sessionKey?: string; | ||
getUserInfo?: (req: FastifyRequest) => string; | ||
getToken?: GetTokenFn; | ||
sessionPlugin?: '@fastify/cookie' | '@fastify/session' | '@fastify/secure-session'; | ||
export type GetTokenFn = (req: FastifyRequest) => string | void; | ||
export interface FastifyCsrfProtectionOptions { | ||
csrfOpts?: CSRFOptions; | ||
cookieKey?: string; | ||
cookieOpts?: CookieSerializeOptions; | ||
sessionKey?: string; | ||
getUserInfo?: (req: FastifyRequest) => string; | ||
getToken?: GetTokenFn; | ||
sessionPlugin?: '@fastify/cookie' | '@fastify/session' | '@fastify/secure-session'; | ||
} | ||
/** | ||
* @deprecated Use FastifyCsrfProtectionOptions instead | ||
*/ | ||
export type FastifyCsrfOptions = FastifyCsrfProtectionOptions; | ||
export const fastifyCsrfProtection: FastifyCsrfProtection | ||
export { fastifyCsrfProtection as default } | ||
} | ||
declare const fastifyCsrf: FastifyPluginAsync<FastifyCsrfOptions>; | ||
export default fastifyCsrf; | ||
declare function fastifyCsrfProtection(...params: Parameters<FastifyCsrfProtection>): ReturnType<FastifyCsrfProtection> | ||
export = fastifyCsrfProtection |
import Fastify from 'fastify' | ||
import FastifyCookie from '@fastify/cookie' | ||
import FastifyCsrfProtection from '..' | ||
import { expectError } from 'tsd' | ||
import FastifyCsrfProtection, { FastifyCsrfOptions } from '..' | ||
import { expectError, expectDeprecated } from 'tsd' | ||
import FastifySession from '@fastify/session' | ||
@@ -41,1 +41,2 @@ | ||
expectDeprecated({} as FastifyCsrfOptions) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
31892
637
216
0