{"name":"koa-csrf","description":"CSRF tokens for koa","version":"3.0.2","author":{"name":"Jonathan Ong","email":"me@jongleberry.com","url":"http://jongleberry.com"},"contributors":[{"name":"Nick Baugh","email":"niftylettuce@gmail.com"}],"dependencies":{"csrf":"^3.0.3"},"devDependencies":{"babel-cli":"^6.14.0","babel-preset-crocodile":"^1.0.0","chai":"^3.5.0","codecov":"^1.0.1","dirty-chai":"^1.2.2","eslint-config-crocodile":"^1.0.0","istanbul":"^1.1.0-alpha.1","koa":"^2.0.0-alpha.3","koa-bodyparser":"^3.2.0","koa-convert":"^1.2.0","koa-generic-session":"^1.11.3","mocha":"^3.0.2","supertest":"^2.0.0"},"engines":{"node":">= 6.x"},"homepage":"https://github.com/koajs/csrf","keywords":["cross","csrf","forgery","koa","koa2","koa@2","koa@next","koanext","next","request","security","site"],"license":"MIT","main":"lib/index.js","repository":{"type":"git","url":"git+https://github.com/koajs/csrf.git"},"scripts":{"analyze-coverage":"babel-node node_modules/.bin/istanbul cover node_modules/.bin/_mocha","check-coverage":"babel-node node_modules/.bin/istanbul check-coverage","compile":"rm -rf lib/ && babel -d lib src","coverage":"rm -rf coverage/ && npm run analyze-coverage && npm run check-coverage && node_modules/.bin/codecov","lint":"eslint .","mocha":"NODE_ENV=test node_modules/.bin/_mocha","prepublish":"npm run test","test":"npm run lint && npm run compile && npm run coverage"},"gitHead":"80d835989d3c3798c8e771ac92d1c7d53ce05b5b","_id":"koa-csrf@3.0.2","_shasum":"a77b9a959da57fbff2d6aa7db041bf809786b5c6","_from":".","_npmVersion":"3.10.3","_nodeVersion":"6.3.1","_npmUser":{"name":"niftylettuce","email":"niftylettuce@gmail.com"},"maintainers":[{"name":"aheckmann","email":"aaron.heckmann+github@gmail.com"},{"name":"coderhaoxin","email":"coderhaoxin@outlook.com"},{"name":"dead-horse","email":"dead_horse@qq.com"},{"name":"dead_horse","email":"dead_horse@qq.com"},{"name":"eivifj","email":"eivind.fjeldstad@gmail.com"},{"name":"fengmk2","email":"fengmk2@gmail.com"},{"name":"jongleberry","email":"jonathanrichardong@gmail.com"},{"name":"juliangruber","email":"julian@juliangruber.com"},{"name":"niftylettuce","email":"niftylettuce@gmail.com"},{"name":"popomore","email":"sakura9515@gmail.com"},{"name":"stephenmathieson","email":"me@stephenmathieson.com"},{"name":"tjholowaychuk","email":"tj@vision-media.ca"}],"dist":{"shasum":"a77b9a959da57fbff2d6aa7db041bf809786b5c6","tarball":"http://registry-npm.ywwl.com/koa-csrf/download/koa-csrf-3.0.2.tgz","integrity":"sha512-PQSpkqzLH5KeCU0OE6+CU0Jym9ogPz6ZoXKEaZMyHASG4kfCxU3sc188DJ6Uk+XDFPd8biog/kaeKo5gg3jqBA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIAjqBQXpPIjLZgD5waJEIblOusvEhDB5AUofvcogrbnqAiB/ifGgT7WiL9PFYTvSfaZYaZ4UWdlb3Kgp2c494w+zrw=="}],"size":19229,"noattachment":false,"key":"/koa-csrf/-/koa-csrf-3.0.2.tgz"},"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/koa-csrf-3.0.2.tgz_1473674362327_0.43978540832176805"},"directories":{},"deprecated":"Please use SameSite lax or strict see <https://scotthelme.co.uk/csrf-is-dead/> and example usage of in @forwardemail codebase <https://github.com/forwardemail/forwardemail.net/blob/040c07f076642ddd3a1a09c63c4252609a4bc52e/config/cookies.js\\#L12-L16>","readme":"# koa-csrf\n\n[![build status](https://github.com/koajs/csrf/actions/workflows/ci.yml/badge.svg)](https://github.com/koajs/csrf/actions/workflows/ci.yml)\n[![build status](https://img.shields.io/travis/koajs/csrf.svg)](https://travis-ci.com/koajs/csrf)\n[![code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/sindresorhus/xo)\n[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)\n[![made with lass](https://img.shields.io/badge/made_with-lass-95CC28.svg)](https://lass.js.org)\n[![license](https://img.shields.io/github/license/koajs/csrf.svg)](LICENSE)\n\n> CSRF tokens for Koa\n\n> **NOTE:** As of v5.0.0+ `ctx.csrf`, `ctx_csrf`, and `ctx.response.csrf` are removed – instead use `ctx.state._csrf`.  Furthermore we have dropped `invalidTokenMessage` and `invalidTokenStatusCode` in favor of an `errorHandler` function option.\n\n\n## Table of Contents\n\n* [Install](#install)\n* [Usage](#usage)\n* [Options](#options)\n* [Contributors](#contributors)\n* [License](#license)\n\n\n## Install\n\n[npm][]:\n\n```sh\nnpm install koa-csrf\n```\n\n\n## Usage\n\n1. Add middleware in Koa app (see [options](#options) below):\n\n   ```js\n   const Koa = require('koa');\n   const bodyParser = require('koa-bodyparser');\n   const session = require('koa-generic-session');\n   const convert = require('koa-convert');\n   const CSRF = require('koa-csrf');\n\n   const app = new Koa();\n\n   // set the session keys\n   app.keys = [ 'a', 'b' ];\n\n   // add session support\n   app.use(convert(session()));\n\n   // add body parsing\n   app.use(bodyParser());\n\n   // add the CSRF middleware\n   app.use(new CSRF());\n\n   // your middleware here (e.g. parse a form submit)\n   app.use((ctx, next) => {\n     if (![ 'GET', 'POST' ].includes(ctx.method))\n       return next();\n     if (ctx.method === 'GET') {\n       ctx.body = ctx.state._csrf;\n       return;\n     }\n     ctx.body = 'OK';\n   });\n\n   app.listen();\n   ```\n\n2. Add the CSRF token in your template forms:\n\n   > Jade Template:\n\n   ```jade\n   form(action='/register', method='POST')\n     input(type='hidden', name='_csrf', value=_csrf)\n     input(type='email', name='email', placeholder='Email')\n     input(type='password', name='password', placeholder='Password')\n     button(type='submit') Register\n   ```\n\n   > EJS Template:\n\n   ```ejs\n   <form action=\"/register\" method=\"POST\">\n     <input type=\"hidden\" name=\"_csrf\" value=\"<%= _csrf %>\" />\n     <input type=\"email\" name=\"email\" placeholder=\"Email\" />\n     <input type=\"password\" name=\"password\" placeholder=\"Password\" />\n     <button type=\"submit\">Register</button>\n   </form>\n   ```\n\n\n## Options\n\n* `errorHandler` (Function) - defaults to a function that returns `ctx.throw(403, 'Invalid CSRF token')`\n* `excludedMethods` (Array) - defaults to `[ 'GET', 'HEAD', 'OPTIONS' ]`\n* `disableQuery` (Boolean) - defaults to `false`\n* `ignoredPathGlobs` (Array) - defaults to an empty Array, but you can pass an Array of glob paths to ignore\n\n\n## Contributors\n\n| Name            | Website                           |\n| --------------- | --------------------------------- |\n| **Nick Baugh**  | <https://github.com/niftylettuce> |\n| **Imed Jaberi** | <https://www.3imed-jaberi.com/>   |\n\n\n## License\n\n[MIT](LICENSE) © [Jonathan Ong](http://jongleberry.com)\n\n\n##\n\n[npm]: https://www.npmjs.com/\n","publish_time":1473674364211,"_cnpm_publish_time":1473674364211,"dist-tags":{"latest":"5.0.1"}}