{"name":"jwt-decode","version":"2.1.0","keywords":["jwt","browser"],"author":{"url":"http://joseoncode.com","name":"Jose F. Romaniello","email":"jfromaniello@gmail.com"},"license":"MIT","_id":"jwt-decode@2.1.0","maintainers":[{"name":"jfromaniello","email":"jfromaniello@gmail.com"}],"homepage":"https://github.com/auth0/jwt-decode#readme","bugs":{"url":"https://github.com/auth0/jwt-decode/issues"},"dist":{"shasum":"d3079cef1689d82d56bbb7aedcfea28b12f0e36a","tarball":"http://registry-npm.ywwl.com/jwt-decode/download/jwt-decode-2.1.0.tgz","integrity":"sha512-7gtm67jqIZ65KUAtY1GKrRRk8v4Kq+YnM9FnVbeKE/iLKpF08PG09egYioN6YuUqQYtErJm+IYGpKq+rvu6i/g==","signatures":[{"sig":"MEYCIQCn5T49MsX2hq/pBjMaf1op9e/VPmj0QhvjsAEKoZpTvwIhAM+V0ufFIfYSmiizHKjmOjwW7e7NgWR1lLvbtCT3NcPK","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"size":9515,"noattachment":false,"key":"/jwt-decode/-/jwt-decode-2.1.0.tgz"},"main":"lib/index.js","_from":".","_shasum":"d3079cef1689d82d56bbb7aedcfea28b12f0e36a","gitHead":"25cc9adfe951d7eead4751da26a9815e1f09d8de","scripts":{"test":"grunt test"},"_npmUser":{"name":"jfromaniello","email":"jfromaniello@gmail.com"},"repository":{"url":"git://github.com/auth0/jwt-decode.git","type":"git"},"_npmVersion":"2.15.1","description":"Decode JWT tokens, mostly useful for browser applications.","directories":{},"_nodeVersion":"4.4.3","dependencies":{},"devDependencies":{"grunt":"~0.4.0","mocha":"~1.13.0","rimraf":"~2.2.2","testem":"~0.5.8","grunt-s3":"~0.2.0-alpha.3","expect.js":"~0.2.0","grunt-cli":"~0.1.9","uglify-js":"~2.4.0","grunt-exec":"~0.4.2","grunt-browserify":"~5.0.0","grunt-contrib-copy":"~0.4.1","grunt-contrib-clean":"~0.5.0","grunt-contrib-watch":"~0.2.0","grunt-contrib-uglify":"~0.2.4","grunt-contrib-connect":"~0.5.0"},"_npmOperationalInternal":{"tmp":"tmp/jwt-decode-2.1.0.tgz_1468874257280_0.09860750148072839","host":"packages-12-west.internal.npmjs.com"},"readme":"![Browser library that helps decoding JWT tokens which are Base64Url encoded](https://cdn.auth0.com/website/sdks/banners/jwt-decode-banner.png)\n\n**IMPORTANT:** This library doesn't validate the token, any well-formed JWT can be decoded. You should validate the token in your server-side logic by using something like [express-jwt](https://github.com/auth0/express-jwt), [koa-jwt](https://github.com/stiang/koa-jwt), [Microsoft.AspNetCore.Authentication.JwtBearer](https://www.nuget.org/packages/Microsoft.AspNetCore.Authentication.JwtBearer), etc.\n\n![Release](https://img.shields.io/npm/v/jwt-decode)\n![Downloads](https://img.shields.io/npm/dw/jwt-decode)\n[![License](https://img.shields.io/:license-MIT-blue.svg?style=flat)](https://opensource.org/licenses/MIT)\n[![CircleCI](https://img.shields.io/circleci/build/github/auth0/jwt-decode)](https://circleci.com/gh/auth0/jwt-decode)\n\n:books: [Documentation](#documentation) - :rocket: [Getting Started](#getting-started) - :speech_balloon: [Feedback](#feedback)\n\n## Documentation\n\n- [Docs site](https://www.auth0.com/docs) - explore our docs site and learn more about Auth0.\n\n## Getting started\n\n### Installation\n\nInstall with NPM or Yarn.\n\nRun `npm install jwt-decode` or `yarn add jwt-decode` to install the library.\n\n### Usage\n\n```js\nimport { jwtDecode } from \"jwt-decode\";\n\nconst token = \"eyJ0eXAiO.../// jwt token\";\nconst decoded = jwtDecode(token);\n\nconsole.log(decoded);\n\n/* prints:\n * { \n *   foo: \"bar\",\n *   exp: 1393286893,\n *   iat: 1393268893  \n * }\n */\n\n// decode header by passing in options (useful for when you need `kid` to verify a JWT):\nconst decodedHeader = jwtDecode(token, { header: true });\nconsole.log(decodedHeader);\n\n/* prints:\n * { \n *   typ: \"JWT\",\n *   alg: \"HS256\" \n * }\n */\n```\n\n**Note:** A falsy or malformed token will throw an `InvalidTokenError` error; see below for more information on specific errors.\n\n## Errors\n\nThis library works with valid JSON web tokens. The basic format of these token is\n```\n[part1].[part2].[part3]\n```\nAll parts are supposed to be valid base64 (url) encoded json.\nDepending on the `{ header: <option> }` option it will decode part 1 (only if header: true is specified) or part 2 (default)\n\nNot adhering to the format will result in a `InvalidTokenError` with one of the following messages:\n\n- `Invalid token specified: must be a string` => the token passed was not a string, this library only works on strings. \n- `Invalid token specified: missing part #` => this probably means you are missing a dot (`.`) in the token \n- `Invalid token specified: invalid base64 for part #` => the part could not be base64 decoded (the message should contain the error the base64 decoder gave)\n- `Invalid token specified: invalid json for part #` => the part was correctly base64 decoded, however, the decoded value was not valid JSON (the message should contain the error the JSON parser gave)\n\n#### Use with TypeScript\n\nThe return type of the `jwtDecode` function is determined by the `header` property of the object passed as the second argument. If omitted (or set to false), it'll use `JwtPayload`, when true it will use `JwtHeader`. \nIf needed, you can specify what the expected return type should be by passing a type argument to the `jwtDecode` function.\n\nYou can extend both `JwtHeader` and `JwtPayload` to include non-standard claims or properties.\n\n```typescript\nimport { jwtDecode } from \"jwt-decode\";\n\nconst token = \"eyJhsw5c\";\nconst decoded = jwtDecode<JwtPayload>(token); // Returns with the JwtPayload type\n```\n\n#### Use as a CommonJS package\n\n```javascript\nconst { jwtDecode } = require('jwt-decode');\n...\n```\n\n#### Include with a script tag\n\nCopy the file `jwt-decode.js` from the root of the `build/esm` folder to your project somewhere, then import `jwtDecode` from it inside a script tag that's marked with `type=\"module\"`:\n\n```html\n<script type=\"module\">\n  import { jwtDecode } from \"/path/to/jwt-decode.js\";\n\n  const token = \"eyJhsw5c\";\n  const decoded = jwtDecode(token);\n</script>\n```\n\n## Feedback\n\n### Contributing\n\nWe appreciate feedback and contribution to this repo! Before you get started, please see the following:\n\n- [Auth0's general contribution guidelines](https://github.com/auth0/open-source-template/blob/master/GENERAL-CONTRIBUTING.md)\n- [Auth0's code of conduct guidelines](https://github.com/auth0/open-source-template/blob/master/CODE-OF-CONDUCT.md)\n\n### Raise an issue\n\nTo provide feedback or report a bug, please [raise an issue on our issue tracker](https://github.com/auth0/jwt-decode/issues).\n\n### Vulnerability Reporting\n\nPlease do not report security vulnerabilities on the public GitHub issue tracker. The [Responsible Disclosure Program](https://auth0.com/responsible-disclosure-policy) details the procedure for disclosing security issues.\n\n---\n\n<p align=\"center\">\n  <picture>\n    <source media=\"(prefers-color-scheme: light)\" srcset=\"https://cdn.auth0.com/website/sdks/logos/auth0_light_mode.png\"   width=\"150\">\n    <source media=\"(prefers-color-scheme: dark)\" srcset=\"https://cdn.auth0.com/website/sdks/logos/auth0_dark_mode.png\" width=\"150\">\n    <img alt=\"Auth0 Logo\" src=\"https://cdn.auth0.com/website/sdks/logos/auth0_light_mode.png\" width=\"150\">\n  </picture>\n</p>\n<p align=\"center\">Auth0 is an easy to implement, adaptable authentication and authorization platform. To learn more checkout <a href=\"https://auth0.com/why-auth0\">Why Auth0?</a></p>\n<p align=\"center\">\nThis project is licensed under the MIT license. See the <a href=\"./LICENSE\"> LICENSE</a> file for more info.</p>\n","publish_time":1468874259238,"_cnpm_publish_time":1468874259238,"dist-tags":{"beta":"4.0.0-beta.4","latest":"4.0.0"}}