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

think-csrf

Package Overview
Dependencies
Maintainers
9
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

think-csrf - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

6

lib/csrf.js

@@ -19,8 +19,4 @@ const utils = require('./utils.js');

.checkCsrf(ctx, options)
.then(() => next())
.catch(() => {
ctx.status = options.errno;
ctx.message = options.errmsg;
});
.then(_ => next());
};
};

6

lib/utils.js

@@ -15,8 +15,8 @@ const helper = require('think-helper');

checkCsrf(ctx, {session_name, form_name, header_name}) {
checkCsrf(ctx, {session_name, form_name, header_name, errno, errmsg}) {
return ctx.session(session_name).then(value => {
if (!value) throw new Error('Verification failed');
if (!value) ctx.throw(errno, errmsg);
const token = ctx.query[form_name] || (ctx.request.body.post && ctx.request.body.post[form_name]) || ctx.get(header_name);
if (token !== value) throw new Error('Verification failed');
if (token !== value) ctx.throw(errno, errmsg);
});

@@ -23,0 +23,0 @@ },

{
"name": "think-csrf",
"version": "1.0.3",
"version": "1.0.4",
"description": "CSRF for ThinkJS 3.x",

@@ -5,0 +5,0 @@ "main": "index.js",

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