{"name":"koa-csrf","description":"CSRF tokens for Koa","version":"5.0.1","author":{"name":"Jonathan Ong","email":"me@jongleberry.com","url":"http://jongleberry.com"},"contributors":[{"name":"Nick Baugh","email":"niftylettuce@gmail.com","url":"https://github.com/niftylettuce"},{"name":"Imed Jaberi","email":"imed_jebari@hotmail.fr","url":"https://www.3imed-jaberi.com/"}],"dependencies":{"csrf":"^3.1.0","is-string-and-not-blank":"^0.0.2","multimatch":"5"},"devDependencies":{"@commitlint/cli":"^17.0.3","@commitlint/config-conventional":"^17.0.3","ava":"^4.3.0","cross-env":"^7.0.3","eslint":"^8.19.0","eslint-config-xo-lass":"^2.0.1","fixpack":"^4.0.0","husky":"^8.0.1","koa":"^2.13.4","koa-bodyparser":"^4.3.0","koa-convert":"^2.0.0","koa-generic-session":"^2.3.0","lint-staged":"^13.0.3","nyc":"^15.1.0","remark-cli":"^11.0.0","remark-preset-github":"^4.0.4","supertest":"^6.2.4","xo":"^0.50.0"},"engines":{"node":">= 14"},"homepage":"https://github.com/koajs/csrf","keywords":["cross","csrf","forgery","koa","koa2","koa@2","koa@next","koanext","middleware","next","request","security","site"],"license":"MIT","main":"index.js","repository":{"type":"git","url":"git+https://github.com/koajs/csrf.git"},"scripts":{"lint":"xo --fix && remark . -qfo && fixpack","prepare":"husky install","pretest":"npm run lint","test":"cross-env NODE_ENV=test nyc ava"},"gitHead":"0b87e994dbd114bac93e775409ee8218c8864830","_id":"koa-csrf@5.0.1","_nodeVersion":"16.15.1","_npmVersion":"8.11.0","dist":{"integrity":"sha512-357feVSJ2QFm30P9ge4x96GGnYWGGyCpX8uBAJI4i8neGwYiv5aip4qqtbgOUF8v/9Zr29nhUaxsBsOgiZyQKQ==","shasum":"f3fb13e20a5aa1168ff1c35f101fcc379f452132","tarball":"http://registry-npm.ywwl.com/koa-csrf/download/koa-csrf-5.0.1.tgz","fileCount":4,"unpackedSize":7900,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDhcNVNC3DMNLwEDKKmvs0E3sXJMzj/CYaT8GKzLtpLTAIhAK5OA5YWLLMowPDqEuxE0xSNbVvpP2aEzRmY2I0Ksxrp"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiv9QqACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpsuQ//dXoOe+VHh3BHS9NuXSYbI5Fq4NIIUqr30/apFwqg/64X+C+r\r\nxaWPbIMmHtCyAgzqljJSajFmrm0Ola2HGMhIUrT3w2ShmwIGa5QqvdkLEq1r\r\nisLb/wyHKH8fZurZ/W33g3mUosw2sWBo3id+OQN49UC0Qq6oD83u0+ZH5UYB\r\nBC/qsZh6pusPmm5BkqjRJt+U7Lmzq3kM+UBbtxoEiex+FMBC9wbskVrSZrWJ\r\na1U5OuofZPhugX3/6Wyt+4VZe7hrkMU7k+F4H0nswGD02xaoqKbpgzhUcfE7\r\nuPdAjtPupXb1PCb7W6eMYwKmwrA5znDsE1okQGhhxFm5WqaCMJjOrPPqO4RZ\r\nWZmU6YA63/F1DoliHCgAQ/Spwu/CZ6NI2tkplckOTcnz5nyovacvfyp5ZTy6\r\nPzEvs9aLs6zZTkSp5npuG3iCBAoHBWo8ESsyXMQPiUWUcKsk78A6d8RQL2DE\r\npAZ2ZfHxMg0jfI9K6E8GKwmeOpzzczAMD068ERjXqdGkzopy6aGzuLJMNkJY\r\ndW+M4uORrtpU4rDHd8E2nZTzlfZUzk1U1dMtYbgmv51J7mKVBlKTbsFzueoh\r\nyTIlxdOBmIthig9F5g/V4JLU8IB+gQj9D9jBmYjfhan3fV3OxcK/TNArtNub\r\nndNTaFM/1qBz9wgSzDqB+0h+jz731f2uOX0=\r\n=ySNq\r\n-----END PGP SIGNATURE-----\r\n","size":3388,"noattachment":false,"key":"/koa-csrf/-/koa-csrf-5.0.1.tgz"},"_npmUser":{"name":"titanism","email":"npm@titanism.com"},"directories":{},"maintainers":[{"name":"coderhaoxin","email":"haoxinst@gmail.com"},{"name":"dead-horse","email":"dead_horse@qq.com"},{"name":"niftylettuce","email":"niftylettuce@gmail.com"},{"name":"aaron","email":"aaron.heckmann+github@gmail.com"},{"name":"juliangruber","email":"julian@juliangruber.com"},{"name":"eivifj","email":"eivind.fjeldstad@gmail.com"},{"name":"dead_horse","email":"dead_horse@qq.com"},{"name":"stephenmathieson","email":"me@stephenmathieson.com"},{"name":"tjholowaychuk","email":"tj@vision-media.ca"},{"name":"jongleberry","email":"jonathanrichardong@gmail.com"},{"name":"fengmk2","email":"fengmk2@gmail.com"},{"name":"popomore","email":"sakura9515@gmail.com"},{"name":"titanism","email":"npm@titanism.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/koa-csrf_5.0.1_1656738858277_0.5221467408291578"},"_hasShrinkwrap":false,"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":1656738858437,"_cnpm_publish_time":1656738858437,"dist-tags":{"latest":"5.0.1"}}