Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@fastify/csrf-protection

Package Overview
Dependencies
Maintainers
19
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fastify/csrf-protection - npm Package Compare versions

Comparing version 6.0.0 to 6.1.0

6

index.js

@@ -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)
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc