{"name":"csrf-tokens","description":"primary logic behind csrf tokens","version":"1.0.2","author":{"name":"Jonathan Ong","email":"me@jongleberry.com","url":"http://jongleberry.com"},"license":"MIT","repository":{"type":"git","url":"git://github.com/expressjs/csrf-tokens"},"dependencies":{"rndm":"1","uid2":"~0.0.2","scmp":"~0.0.3"},"devDependencies":{"mocha":"1"},"scripts":{"test":"mocha --reporter spec"},"bugs":{"url":"https://github.com/expressjs/csrf-tokens/issues"},"homepage":"https://github.com/expressjs/csrf-tokens","_id":"csrf-tokens@1.0.2","_shasum":"03b1206a7876baaf5d0e347a2bc566cdfa2ca30b","_from":".","_npmVersion":"1.4.9","_npmUser":{"name":"jongleberry","email":"jonathanrichardong@gmail.com"},"maintainers":[{"name":"jongleberry","email":"jonathanrichardong@gmail.com"}],"dist":{"shasum":"03b1206a7876baaf5d0e347a2bc566cdfa2ca30b","tarball":"http://registry-npm.ywwl.com/csrf-tokens/download/csrf-tokens-1.0.2.tgz","integrity":"sha512-RxG+LRkqfaH4VFVel6QY+o6B3AvdBa6hU4YU73aiH4nDoY/vZSk8sKmPkXZDoXHtgFtkfCagxXFLYhb3rGb2gw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDnLz8XFxOSlM/+dD1zciBuIOfPR6mrEnv4PbMMi1vcDAIhANT6oLA+ZmQCPJvtqexahvHfOu4We2ymDGI8TqekpPyE"}],"size":2468,"noattachment":false,"key":"/csrf-tokens/-/csrf-tokens-1.0.2.tgz"},"directories":{},"readme":"\n# CSRF Tokens\n\nLogic behind CSRF token creation and verification.\nRead [Understanding-CSRF](http://www.jongleberry.com/understanding-csrf.html) for more information on CSRF.\nUse this module to create custom CSRF middleware and what not.\n\n## API\n\n```js\nvar tokens = require('csrf-tokens')(options)\n\nvar secret = tokens.secretSync()\nvar token = tokens.create(secret)\nvar valid = tokens.verify(secret, token)\n```\n\nOptions:\n\n- `secretLength: 24` - the byte length of the secret key\n- `saltLength: 8` - the string length of the salt\n- `tokensize: (secret, salt) => token` - a custom token creation function\n\n### tokens.secret([cb])\n\nAsynchronously create a new `secret` of length `secretLength`.\nIf `cb` is not defined, a promise is returned.\nYou don't have to use this.\n\n```js\ntokens.secret().then(function (secret) {\n\n})\n\ntokens.secret(function (err, secret) {\n\n})\n```\n\n### var secret = tokens.secretSync()\n\nSynchronous version of `tokens.secret()`\n\n### var token = tokens.token(secret)\n\nCreate a CSRF token based on a `secret`.\nThis is the token you pass to clients.\n\n### var valid = tokens.verify(secret, token)\n\nCheck whether a CSRF token is valid based on a `secret`.\nIf it's not valid, you should probably throw a `403` error.\n","publish_time":1402264961123,"_cnpm_publish_time":1402264961123,"dist-tags":{"latest":"2.0.0"}}