135 lines
15 KiB
JSON
135 lines
15 KiB
JSON
{
|
|
"_args": [
|
|
[
|
|
{
|
|
"raw": "jsonwebtoken@^7.2.1",
|
|
"scope": null,
|
|
"escapedName": "jsonwebtoken",
|
|
"name": "jsonwebtoken",
|
|
"rawSpec": "^7.2.1",
|
|
"spec": ">=7.2.1 <8.0.0",
|
|
"type": "range"
|
|
},
|
|
"/Volumes/2009-SSD/GT2/GT2-iOS/node_modules/xdl"
|
|
]
|
|
],
|
|
"_from": "jsonwebtoken@>=7.2.1 <8.0.0",
|
|
"_id": "jsonwebtoken@7.4.3",
|
|
"_inCache": true,
|
|
"_location": "/jsonwebtoken",
|
|
"_nodeVersion": "4.4.3",
|
|
"_npmOperationalInternal": {
|
|
"host": "s3://npm-registry-packages",
|
|
"tmp": "tmp/jsonwebtoken-7.4.3.tgz_1502981444880_0.00893402541987598"
|
|
},
|
|
"_npmUser": {
|
|
"name": "ziluvatar",
|
|
"email": "eduardo.diaz@auth0.com"
|
|
},
|
|
"_npmVersion": "2.15.1",
|
|
"_phantomChildren": {
|
|
"moment": "2.20.1"
|
|
},
|
|
"_requested": {
|
|
"raw": "jsonwebtoken@^7.2.1",
|
|
"scope": null,
|
|
"escapedName": "jsonwebtoken",
|
|
"name": "jsonwebtoken",
|
|
"rawSpec": "^7.2.1",
|
|
"spec": ">=7.2.1 <8.0.0",
|
|
"type": "range"
|
|
},
|
|
"_requiredBy": [
|
|
"/xdl"
|
|
],
|
|
"_resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-7.4.3.tgz",
|
|
"_shasum": "77f5021de058b605a1783fa1283e99812e645638",
|
|
"_shrinkwrap": null,
|
|
"_spec": "jsonwebtoken@^7.2.1",
|
|
"_where": "/Volumes/2009-SSD/GT2/GT2-iOS/node_modules/xdl",
|
|
"author": {
|
|
"name": "auth0"
|
|
},
|
|
"bugs": {
|
|
"url": "https://github.com/auth0/node-jsonwebtoken/issues"
|
|
},
|
|
"dependencies": {
|
|
"joi": "^6.10.1",
|
|
"jws": "^3.1.4",
|
|
"lodash.once": "^4.0.0",
|
|
"ms": "^2.0.0",
|
|
"xtend": "^4.0.1"
|
|
},
|
|
"description": "JSON Web Token implementation (symmetric and asymmetric)",
|
|
"devDependencies": {
|
|
"atob": "^1.1.2",
|
|
"chai": "^1.10.0",
|
|
"conventional-changelog": "~1.1.0",
|
|
"mocha": "^2.1.0",
|
|
"nsp": "^2.6.2",
|
|
"sinon": "^1.15.4"
|
|
},
|
|
"directories": {},
|
|
"dist": {
|
|
"shasum": "77f5021de058b605a1783fa1283e99812e645638",
|
|
"tarball": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-7.4.3.tgz"
|
|
},
|
|
"engines": {
|
|
"node": ">=0.12",
|
|
"npm": ">=1.4.28"
|
|
},
|
|
"gitHead": "e54e53c70ad3fa0d6b54f916ea4a2a2d5a8c47c2",
|
|
"homepage": "https://github.com/auth0/node-jsonwebtoken#readme",
|
|
"keywords": [
|
|
"jwt"
|
|
],
|
|
"license": "MIT",
|
|
"main": "index.js",
|
|
"maintainers": [
|
|
{
|
|
"name": "dschenkelman",
|
|
"email": "damian.schenkelman@gmail.com"
|
|
},
|
|
{
|
|
"name": "iaco",
|
|
"email": "sebastian.iacomuzzi@gmail.com"
|
|
},
|
|
{
|
|
"name": "jaredhanson",
|
|
"email": "jaredhanson@gmail.com"
|
|
},
|
|
{
|
|
"name": "jfromaniello",
|
|
"email": "jfromaniello@gmail.com"
|
|
},
|
|
{
|
|
"name": "pose",
|
|
"email": "albertopose@gmail.com"
|
|
},
|
|
{
|
|
"name": "rolodato",
|
|
"email": "rolodato@rolodato.com"
|
|
},
|
|
{
|
|
"name": "woloski",
|
|
"email": "matiasw@gmail.com"
|
|
},
|
|
{
|
|
"name": "ziluvatar",
|
|
"email": "eduardo.diaz@auth0.com"
|
|
}
|
|
],
|
|
"name": "jsonwebtoken",
|
|
"optionalDependencies": {},
|
|
"readme": "# jsonwebtoken\n\n[![Build Status](https://secure.travis-ci.org/auth0/node-jsonwebtoken.svg?branch=master)](http://travis-ci.org/auth0/node-jsonwebtoken)[![Dependency Status](https://david-dm.org/auth0/node-jsonwebtoken.svg)](https://david-dm.org/auth0/node-jsonwebtoken)\n\n\nAn implementation of [JSON Web Tokens](https://tools.ietf.org/html/rfc7519).\n\nThis was developed against `draft-ietf-oauth-json-web-token-08`. It makes use of [node-jws](https://github.com/brianloveswords/node-jws)\n\n# Install\n\n```bash\n$ npm install jsonwebtoken\n```\n\n# Usage\n\n### jwt.sign(payload, secretOrPrivateKey, [options, callback])\n\n(Asynchronous) If a callback is supplied, callback is called with the `err` or the JWT.\n\n(Synchronous) Returns the JsonWebToken as string\n\n`payload` could be an object literal, buffer or string. *Please note that* `exp` is only set if the payload is an object literal.\n\n`secretOrPrivateKey` is a string, buffer, or object containing either the secret for HMAC algorithms or the PEM\nencoded private key for RSA and ECDSA. In case of a private key with passphrase an object `{ key, passphrase }` can be used (based on [crypto documentation](https://nodejs.org/api/crypto.html#crypto_sign_sign_private_key_output_format)), in this case be sure you pass the `algorithm` option.\n\n`options`:\n\n* `algorithm` (default: `HS256`)\n* `expiresIn`: expressed in seconds or a string describing a time span [zeit/ms](https://github.com/zeit/ms). Eg: `60`, `\"2 days\"`, `\"10h\"`, `\"7d\"`\n* `notBefore`: expressed in seconds or a string describing a time span [zeit/ms](https://github.com/zeit/ms). Eg: `60`, `\"2 days\"`, `\"10h\"`, `\"7d\"`\n* `audience`\n* `issuer`\n* `jwtid`\n* `subject`\n* `noTimestamp`\n* `header`\n* `keyid`\n\nIf `payload` is not a buffer or a string, it will be coerced into a string using `JSON.stringify`.\n\nThere are no default values for `expiresIn`, `notBefore`, `audience`, `subject`, `issuer`. These claims can also be provided in the payload directly with `exp`, `nbf`, `aud`, `sub` and `iss` respectively, but you can't include in both places.\n\nRemember that `exp`, `nbf` and `iat` are **NumericDate**, see related [Token Expiration (exp claim)](#token-expiration-exp-claim)\n\n\nThe header can be customized via the `option.header` object.\n\nGenerated jwts will include an `iat` (issued at) claim by default unless `noTimestamp` is specified. If `iat` is inserted in the payload, it will be used instead of the real timestamp for calculating other things like `exp` given a timespan in `options.expiresIn`.\n\nExample\n\n```js\n// sign with default (HMAC SHA256)\nvar jwt = require('jsonwebtoken');\nvar token = jwt.sign({ foo: 'bar' }, 'shhhhh');\n//backdate a jwt 30 seconds\nvar older_token = jwt.sign({ foo: 'bar', iat: Math.floor(Date.now() / 1000) - 30 }, 'shhhhh');\n\n// sign with RSA SHA256\nvar cert = fs.readFileSync('private.key'); // get private key\nvar token = jwt.sign({ foo: 'bar' }, cert, { algorithm: 'RS256'});\n\n// sign asynchronously\njwt.sign({ foo: 'bar' }, cert, { algorithm: 'RS256' }, function(err, token) {\n console.log(token);\n});\n```\n\n#### Token Expiration (exp claim)\n\nThe standard for JWT defines an `exp` claim for expiration. The expiration is represented as a **NumericDate**:\n\n> A JSON numeric value representing the number of seconds from 1970-01-01T00:00:00Z UTC until the specified UTC date/time, ignoring leap seconds. This is equivalent to the IEEE Std 1003.1, 2013 Edition [POSIX.1] definition \"Seconds Since the Epoch\", in which each day is accounted for by exactly 86400 seconds, other than that non-integer values can be represented. See RFC 3339 [RFC3339] for details regarding date/times in general and UTC in particular.\n\nThis means that the `exp` field should contain the number of seconds since the epoch.\n\nSigning a token with 1 hour of expiration:\n\n```javascript\njwt.sign({\n exp: Math.floor(Date.now() / 1000) + (60 * 60),\n data: 'foobar'\n}, 'secret');\n```\n\nAnother way to generate a token like this with this library is:\n\n```javascript\njwt.sign({\n data: 'foobar'\n}, 'secret', { expiresIn: 60 * 60 });\n\n//or even better:\n\njwt.sign({\n data: 'foobar'\n}, 'secret', { expiresIn: '1h' });\n```\n\n### jwt.verify(token, secretOrPublicKey, [options, callback])\n\n(Asynchronous) If a callback is supplied, function acts asynchronously. Callback is passed the decoded payload if the signature and optional expiration, audience, or issuer are valid. If not, it will be passed the error.\n\n(Synchronous) If a callback is not supplied, function acts synchronously. Returns the payload decoded if the signature (and, optionally, expiration, audience, issuer) are valid. If not, it will throw the error.\n\n`token` is the JsonWebToken string\n\n`secretOrPublicKey` is a string or buffer containing either the secret for HMAC algorithms, or the PEM\nencoded public key for RSA and ECDSA.\n\nAs mentioned in [this comment](https://github.com/auth0/node-jsonwebtoken/issues/208#issuecomment-231861138), there are other libraries that expect base64 encoded secrets (random bytes encoded using base64), if that is your case you can pass `new Buffer(secret, 'base64')`, by doing this the secret will be decoded using base64 and the token verification will use the original random bytes.\n\n`options`\n\n* `algorithms`: List of strings with the names of the allowed algorithms. For instance, `[\"HS256\", \"HS384\"]`.\n* `audience`: if you want to check audience (`aud`), provide a value here\n* `issuer` (optional): string or array of strings of valid values for the `iss` field.\n* `ignoreExpiration`: if `true` do not validate the expiration of the token.\n* `ignoreNotBefore`...\n* `subject`: if you want to check subject (`sub`), provide a value here\n* `clockTolerance`: number of seconds to tolerate when checking the `nbf` and `exp` claims, to deal with small clock differences among different servers\n* `maxAge`: the maximum allowed age for tokens to still be valid. Currently it is expressed in milliseconds or a string describing a time span [zeit/ms](https://github.com/zeit/ms). Eg: `1000`, `\"2 days\"`, `\"10h\"`, `\"7d\"`. **We advise against using milliseconds precision, though, since JWTs can only contain seconds. The maximum precision might be reduced to seconds in the future.**\n* `clockTimestamp`: the time in seconds that should be used as the current time for all necessary comparisons (also against `maxAge`, so our advise is to avoid using `clockTimestamp` and a `maxAge` in milliseconds together)\n\n\n```js\n// verify a token symmetric - synchronous\nvar decoded = jwt.verify(token, 'shhhhh');\nconsole.log(decoded.foo) // bar\n\n// verify a token symmetric\njwt.verify(token, 'shhhhh', function(err, decoded) {\n console.log(decoded.foo) // bar\n});\n\n// invalid token - synchronous\ntry {\n var decoded = jwt.verify(token, 'wrong-secret');\n} catch(err) {\n // err\n}\n\n// invalid token\njwt.verify(token, 'wrong-secret', function(err, decoded) {\n // err\n // decoded undefined\n});\n\n// verify a token asymmetric\nvar cert = fs.readFileSync('public.pem'); // get public key\njwt.verify(token, cert, function(err, decoded) {\n console.log(decoded.foo) // bar\n});\n\n// verify audience\nvar cert = fs.readFileSync('public.pem'); // get public key\njwt.verify(token, cert, { audience: 'urn:foo' }, function(err, decoded) {\n // if audience mismatch, err == invalid audience\n});\n\n// verify issuer\nvar cert = fs.readFileSync('public.pem'); // get public key\njwt.verify(token, cert, { audience: 'urn:foo', issuer: 'urn:issuer' }, function(err, decoded) {\n // if issuer mismatch, err == invalid issuer\n});\n\n// verify jwt id\nvar cert = fs.readFileSync('public.pem'); // get public key\njwt.verify(token, cert, { audience: 'urn:foo', issuer: 'urn:issuer', jwtid: 'jwtid' }, function(err, decoded) {\n // if jwt id mismatch, err == invalid jwt id\n});\n\n// verify subject\nvar cert = fs.readFileSync('public.pem'); // get public key\njwt.verify(token, cert, { audience: 'urn:foo', issuer: 'urn:issuer', jwtid: 'jwtid', subject: 'subject' }, function(err, decoded) {\n // if subject mismatch, err == invalid subject\n});\n\n// alg mismatch\nvar cert = fs.readFileSync('public.pem'); // get public key\njwt.verify(token, cert, { algorithms: ['RS256'] }, function (err, payload) {\n // if token alg != RS256, err == invalid signature\n});\n\n```\n\n### jwt.decode(token [, options])\n\n(Synchronous) Returns the decoded payload without verifying if the signature is valid.\n\n__Warning:__ This will __not__ verify whether the signature is valid. You should __not__ use this for untrusted messages. You most likely want to use `jwt.verify` instead.\n\n`token` is the JsonWebToken string\n\n`options`:\n\n* `json`: force JSON.parse on the payload even if the header doesn't contain `\"typ\":\"JWT\"`.\n* `complete`: return an object with the decoded payload and header.\n\nExample\n\n```js\n// get the decoded payload ignoring signature, no secretOrPrivateKey needed\nvar decoded = jwt.decode(token);\n\n// get the decoded payload and header\nvar decoded = jwt.decode(token, {complete: true});\nconsole.log(decoded.header);\nconsole.log(decoded.payload)\n```\n\n## Errors & Codes\nPossible thrown errors during verification.\nError is the first argument of the verification callback.\n\n### TokenExpiredError\n\nThrown error if the token is expired.\n\nError object:\n\n* name: 'TokenExpiredError'\n* message: 'jwt expired'\n* expiredAt: [ExpDate]\n\n```js\njwt.verify(token, 'shhhhh', function(err, decoded) {\n if (err) {\n /*\n err = {\n name: 'TokenExpiredError',\n message: 'jwt expired',\n expiredAt: 1408621000\n }\n */\n }\n});\n```\n\n### JsonWebTokenError\nError object:\n\n* name: 'JsonWebTokenError'\n* message:\n * 'jwt malformed'\n * 'jwt signature is required'\n * 'invalid signature'\n * 'jwt audience invalid. expected: [OPTIONS AUDIENCE]'\n * 'jwt issuer invalid. expected: [OPTIONS ISSUER]'\n * 'jwt id invalid. expected: [OPTIONS JWT ID]'\n * 'jwt subject invalid. expected: [OPTIONS SUBJECT]'\n\n```js\njwt.verify(token, 'shhhhh', function(err, decoded) {\n if (err) {\n /*\n err = {\n name: 'JsonWebTokenError',\n message: 'jwt malformed'\n }\n */\n }\n});\n```\n\n## Algorithms supported\n\nArray of supported algorithms. The following algorithms are currently supported.\n\nalg Parameter Value | Digital Signature or MAC Algorithm\n----------------|----------------------------\nHS256 | HMAC using SHA-256 hash algorithm\nHS384 | HMAC using SHA-384 hash algorithm\nHS512 | HMAC using SHA-512 hash algorithm\nRS256 | RSASSA using SHA-256 hash algorithm\nRS384 | RSASSA using SHA-384 hash algorithm\nRS512 | RSASSA using SHA-512 hash algorithm\nES256 | ECDSA using P-256 curve and SHA-256 hash algorithm\nES384 | ECDSA using P-384 curve and SHA-384 hash algorithm\nES512 | ECDSA using P-521 curve and SHA-512 hash algorithm\nnone | No digital signature or MAC value included\n\n## Refreshing JWTs\n\nFirst of all, we recommend to think carefully if auto-refreshing a JWT will not introduce any vulnerability in your system.\n\nWe are not comfortable including this as part of the library, however, you can take a look to [this example](https://gist.github.com/ziluvatar/a3feb505c4c0ec37059054537b38fc48) to show how this could be accomplish.\nApart from that example there are [an issue](https://github.com/auth0/node-jsonwebtoken/issues/122) and [a pull request](https://github.com/auth0/node-jsonwebtoken/pull/172) to get more knowledge about this topic.\n\n# TODO\n\n* X.509 certificate chain is not checked\n\n## Issue Reporting\n\nIf you have found a bug or if you have a feature request, please report them at this repository issues section. Please do not report security vulnerabilities on the public GitHub issue tracker. The [Responsible Disclosure Program](https://auth0.com/whitehat) details the procedure for disclosing security issues.\n\n## Author\n\n[Auth0](https://auth0.com)\n\n## License\n\nThis project is licensed under the MIT license. See the [LICENSE](LICENSE) file for more info.\n",
|
|
"readmeFilename": "README.md",
|
|
"repository": {
|
|
"type": "git",
|
|
"url": "git+https://github.com/auth0/node-jsonwebtoken.git"
|
|
},
|
|
"scripts": {
|
|
"test": "mocha --require test/util/fakeDate && nsp check"
|
|
},
|
|
"version": "7.4.3"
|
|
}
|