jwt-decode
Advanced tools
Comparing version 2.2.0 to 3.0.0-beta.0
@@ -1,125 +0,114 @@ | ||
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
/** | ||
* The code was extracted from: | ||
* https://github.com/davidchambers/Base64.js | ||
*/ | ||
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : | ||
typeof define === 'function' && define.amd ? define(factory) : | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global['jwt-decode'] = factory()); | ||
}(this, (function () { 'use strict'; | ||
var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; | ||
/** | ||
* The code was extracted from: | ||
* https://github.com/davidchambers/Base64.js | ||
*/ | ||
function InvalidCharacterError(message) { | ||
this.message = message; | ||
} | ||
var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; | ||
InvalidCharacterError.prototype = new Error(); | ||
InvalidCharacterError.prototype.name = 'InvalidCharacterError'; | ||
function InvalidCharacterError(message) { | ||
this.message = message; | ||
} | ||
function polyfill (input) { | ||
var str = String(input).replace(/=+$/, ''); | ||
if (str.length % 4 == 1) { | ||
throw new InvalidCharacterError("'atob' failed: The string to be decoded is not correctly encoded."); | ||
} | ||
for ( | ||
// initialize result and counters | ||
var bc = 0, bs, buffer, idx = 0, output = ''; | ||
// get next character | ||
buffer = str.charAt(idx++); | ||
// character found in table? initialize bit storage and add its ascii value; | ||
~buffer && (bs = bc % 4 ? bs * 64 + buffer : buffer, | ||
// and if not first of each 4 characters, | ||
// convert the first 8 bits to one ascii character | ||
bc++ % 4) ? output += String.fromCharCode(255 & bs >> (-2 * bc & 6)) : 0 | ||
) { | ||
// try to find character in table (0-63, not found => -1) | ||
buffer = chars.indexOf(buffer); | ||
} | ||
return output; | ||
} | ||
InvalidCharacterError.prototype = new Error(); | ||
InvalidCharacterError.prototype.name = "InvalidCharacterError"; | ||
function polyfill(input) { | ||
var str = String(input).replace(/=+$/, ""); | ||
if (str.length % 4 == 1) { | ||
throw new InvalidCharacterError( | ||
"'atob' failed: The string to be decoded is not correctly encoded." | ||
); | ||
} | ||
for ( | ||
// initialize result and counters | ||
var bc = 0, bs, buffer, idx = 0, output = ""; | ||
// get next character | ||
(buffer = str.charAt(idx++)); | ||
// character found in table? initialize bit storage and add its ascii value; | ||
~buffer && | ||
((bs = bc % 4 ? bs * 64 + buffer : buffer), | ||
// and if not first of each 4 characters, | ||
// convert the first 8 bits to one ascii character | ||
bc++ % 4) ? | ||
(output += String.fromCharCode(255 & (bs >> ((-2 * bc) & 6)))) : | ||
0 | ||
) { | ||
// try to find character in table (0-63, not found => -1) | ||
buffer = chars.indexOf(buffer); | ||
} | ||
return output; | ||
} | ||
module.exports = typeof window !== 'undefined' && window.atob && window.atob.bind(window) || polyfill; | ||
var atob = (typeof window !== "undefined" && | ||
window.atob && | ||
window.atob.bind(window)) || | ||
polyfill; | ||
},{}],2:[function(require,module,exports){ | ||
var atob = require('./atob'); | ||
function b64DecodeUnicode(str) { | ||
return decodeURIComponent(atob(str).replace(/(.)/g, function (m, p) { | ||
var code = p.charCodeAt(0).toString(16).toUpperCase(); | ||
if (code.length < 2) { | ||
code = '0' + code; | ||
function b64DecodeUnicode(str) { | ||
return decodeURIComponent( | ||
atob(str).replace(/(.)/g, function(m, p) { | ||
var code = p.charCodeAt(0).toString(16).toUpperCase(); | ||
if (code.length < 2) { | ||
code = "0" + code; | ||
} | ||
return "%" + code; | ||
}) | ||
); | ||
} | ||
return '%' + code; | ||
})); | ||
} | ||
module.exports = function(str) { | ||
var output = str.replace(/-/g, "+").replace(/_/g, "/"); | ||
switch (output.length % 4) { | ||
case 0: | ||
break; | ||
case 2: | ||
output += "=="; | ||
break; | ||
case 3: | ||
output += "="; | ||
break; | ||
default: | ||
throw "Illegal base64url string!"; | ||
} | ||
function base64_url_decode(str) { | ||
var output = str.replace(/-/g, "+").replace(/_/g, "/"); | ||
switch (output.length % 4) { | ||
case 0: | ||
break; | ||
case 2: | ||
output += "=="; | ||
break; | ||
case 3: | ||
output += "="; | ||
break; | ||
default: | ||
throw "Illegal base64url string!"; | ||
} | ||
try{ | ||
return b64DecodeUnicode(output); | ||
} catch (err) { | ||
return atob(output); | ||
} | ||
}; | ||
try { | ||
return b64DecodeUnicode(output); | ||
} catch (err) { | ||
return atob(output); | ||
} | ||
} | ||
},{"./atob":1}],3:[function(require,module,exports){ | ||
'use strict'; | ||
function InvalidTokenError(message) { | ||
this.message = message; | ||
} | ||
var base64_url_decode = require('./base64_url_decode'); | ||
InvalidTokenError.prototype = new Error(); | ||
InvalidTokenError.prototype.name = "InvalidTokenError"; | ||
function InvalidTokenError(message) { | ||
this.message = message; | ||
} | ||
function jwtDecode(token, options) { | ||
if (typeof token !== "string") { | ||
throw new InvalidTokenError("Invalid token specified"); | ||
} | ||
InvalidTokenError.prototype = new Error(); | ||
InvalidTokenError.prototype.name = 'InvalidTokenError'; | ||
options = options || {}; | ||
var pos = options.header === true ? 0 : 1; | ||
try { | ||
return JSON.parse(base64_url_decode(token.split(".")[pos])); | ||
} catch (e) { | ||
throw new InvalidTokenError("Invalid token specified: " + e.message); | ||
} | ||
} | ||
module.exports = function (token,options) { | ||
if (typeof token !== 'string') { | ||
throw new InvalidTokenError('Invalid token specified'); | ||
} | ||
const wrapper = jwtDecode; | ||
wrapper.InvalidTokenError = InvalidTokenError; | ||
options = options || {}; | ||
var pos = options.header === true ? 0 : 1; | ||
try { | ||
return JSON.parse(base64_url_decode(token.split('.')[pos])); | ||
} catch (e) { | ||
throw new InvalidTokenError('Invalid token specified: ' + e.message); | ||
} | ||
}; | ||
return wrapper; | ||
module.exports.InvalidTokenError = InvalidTokenError; | ||
},{"./base64_url_decode":2}],4:[function(require,module,exports){ | ||
(function (global){ | ||
/* | ||
* | ||
* This is used to build the bundle with browserify. | ||
* | ||
* The bundle is used by people who doesn't use browserify. | ||
* Those who use browserify will install with npm and require the module, | ||
* the package.json file points to index.js. | ||
*/ | ||
var jwt_decode = require('./lib/index'); | ||
//use amd or just throught to window object. | ||
if (typeof global.window.define == 'function' && global.window.define.amd) { | ||
global.window.define('jwt_decode', function () { return jwt_decode; }); | ||
} else if (global.window) { | ||
global.window.jwt_decode = jwt_decode; | ||
} | ||
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) | ||
},{"./lib/index":3}]},{},[4]) | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9ncnVudC1icm93c2VyaWZ5L25vZGVfbW9kdWxlcy9icm93c2VyaWZ5L25vZGVfbW9kdWxlcy9icm93c2VyLXBhY2svX3ByZWx1ZGUuanMiLCJsaWIvYXRvYi5qcyIsImxpYi9iYXNlNjRfdXJsX2RlY29kZS5qcyIsImxpYi9pbmRleC5qcyIsInN0YW5kYWxvbmUuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7QUNBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQU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Y3QuXG5pZiAodHlwZW9mIGdsb2JhbC53aW5kb3cuZGVmaW5lID09ICdmdW5jdGlvbicgJiYgZ2xvYmFsLndpbmRvdy5kZWZpbmUuYW1kKSB7XG4gIGdsb2JhbC53aW5kb3cuZGVmaW5lKCdqd3RfZGVjb2RlJywgZnVuY3Rpb24gKCkgeyByZXR1cm4gand0X2RlY29kZTsgfSk7XG59IGVsc2UgaWYgKGdsb2JhbC53aW5kb3cpIHtcbiAgZ2xvYmFsLndpbmRvdy5qd3RfZGVjb2RlID0gand0X2RlY29kZTtcbn0iXX0= | ||
}))); | ||
//# sourceMappingURL=jwt-decode.js.map |
{ | ||
"name": "jwt-decode", | ||
"version": "2.2.0", | ||
"description": "Decode JWT tokens, mostly useful for browser applications.", | ||
"main": "lib/index.js", | ||
"keywords": [ | ||
"jwt", | ||
"browser" | ||
], | ||
"scripts": { | ||
"test": "grunt test" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/auth0/jwt-decode" | ||
}, | ||
"author": "Jose F. Romaniello <jfromaniello@gmail.com> (http://joseoncode.com)", | ||
"license": "MIT", | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"expect.js": "~0.2.0", | ||
"grunt": "~0.4.0", | ||
"grunt-browserify": "~5.0.0", | ||
"grunt-cli": "~0.1.9", | ||
"grunt-contrib-clean": "~0.5.0", | ||
"grunt-contrib-connect": "~0.5.0", | ||
"grunt-contrib-copy": "~0.4.1", | ||
"grunt-contrib-uglify": "~0.2.4", | ||
"grunt-contrib-watch": "~0.2.0", | ||
"grunt-exec": "~0.4.2", | ||
"grunt-s3": "~0.2.0-alpha.3", | ||
"mocha": "~1.13.0", | ||
"rimraf": "~2.2.2", | ||
"testem": "~0.5.8", | ||
"uglify-js": "~2.4.0" | ||
} | ||
"name": "jwt-decode", | ||
"version": "3.0.0-beta.0", | ||
"description": "Decode JWT tokens, mostly useful for browser applications.", | ||
"main": "dist/jwt-decode.cjs.js", | ||
"module": "dist/jwt-decode.esm.js", | ||
"keywords": [ | ||
"jwt", | ||
"browser" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/auth0/jwt-decode" | ||
}, | ||
"url": "https://github.com/auth0/jwt-decode/issues", | ||
"homepage": "https://github.com/auth0/jwt-decode#readme", | ||
"scripts": { | ||
"dev": "rollup -m -c", | ||
"build": "rimraf build && rollup -m -c --environment NODE_ENV:production", | ||
"test": "mocha" | ||
}, | ||
"author": "Jose F. Romaniello <jfromaniello@gmail.com> (http://joseoncode.com)", | ||
"contributors": [ | ||
"Sam Bellen <sam.bellen@auth0.com>" | ||
], | ||
"license": "MIT", | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"@rollup/plugin-commonjs": "^15.0.0", | ||
"@rollup/plugin-node-resolve": "^9.0.0", | ||
"expect.js": "~0.2.0", | ||
"mocha": "^8.1.3", | ||
"rimraf": "^2.2.8", | ||
"rollup": "^2.26.11", | ||
"rollup-plugin-livereload": "^2.0.0", | ||
"rollup-plugin-serve": "^1.0.4", | ||
"rollup-plugin-sourcemaps": "^0.6.2", | ||
"rollup-plugin-terser": "^7.0.2", | ||
"uglify-js": "^2.8.29" | ||
}, | ||
"files": [ | ||
"build/" | ||
] | ||
} |
@@ -1,17 +0,19 @@ | ||
__jwt-decode__ is a small browser library that helps decoding JWTs token which are Base64Url encoded. | ||
**jwt-decode** is a small browser library that helps decoding JWTs token which are Base64Url encoded. | ||
__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), [Owin Bearer JWT](https://github.com/michaelnoonan/Auth0-Owin-JwtBearerAuthentication), etc. | ||
**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), [Owin Bearer JWT](https://github.com/michaelnoonan/Auth0-Owin-JwtBearerAuthentication), etc. | ||
## Installation | ||
Install with npm, bower, or downloading from the build directory of this repository. | ||
Install with NPM or Yarn. | ||
Use with AMD, browserify or just include with an script tag. | ||
Run `npm install jwt-decode` or `yarn add jwt-decode` to install the library. | ||
## Usage | ||
~~~javascript | ||
var token = 'eyJ0eXAiO.../// jwt token'; | ||
```javascript | ||
import jwt_decode from "jwt-decode"; | ||
var token = "eyJ0eXAiO.../// jwt token"; | ||
var decoded = jwt_decode(token); | ||
console.log(decoded); | ||
@@ -24,19 +26,22 @@ | ||
*/ | ||
~~~ | ||
**Note:** A falsy token will throw an error. | ||
// decode header by passing in options (useful for when you need `kid` to verify a JWT): | ||
var decodedHeader = jwt_decode(token, { header: true }); | ||
console.log(decodedHeader); | ||
Can also be used with [browserify] or [webpack] by doing `npm install jwt-decode` and requiring: | ||
/* prints: | ||
* { typ: "JWT", | ||
* alg: "HS256" } | ||
*/ | ||
``` | ||
~~~javascript | ||
var jwtDecode = require('jwt-decode'); | ||
~~~ | ||
**Note:** A falsy or malformed token will throw an `InvalidTokenError` error. | ||
## Polymer Web Component | ||
## Older verion | ||
Can also be installed and used with [Polymer-based wrapper](https://github.com/firmfirm/f-jwt-decode). | ||
If you want to use the library trough Bower, an HTML import or include it through a `<script>` tag, use [version `v2.2.0`](https://github.com/auth0/jwt-decode/tree/v2.2.0). It has the same functionality. | ||
## Develop | ||
Run `grunt dev` and fire a browser at http://localhost:9999/test_harness.html. | ||
Run `npm run dev`, this will fire up a browser and watch the `/lib` folder. | ||
@@ -53,5 +58,2 @@ ## Issue Reporting | ||
This project is licensed under the MIT license. See the [LICENSE](LICENSE.txt) file for more info. | ||
[browserify]: http://browserify.org | ||
[webpack]: http://webpack.github.io/ | ||
This project is licensed under the MIT license. See the [LICENSE](LICENSE) file for more info. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
26568
11
1
58
0
9
110
2