jwt-check-expiry
Version:
check JWT is expired or not.
33 lines • 1.32 kB
JavaScript
;
/**
* The code is taken from:
* https://github.com/davidchambers/Base64.js
*/
Object.defineProperty(exports, "__esModule", { value: true });
var base64chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
function atobPolyfill(input) {
var output = '';
var str = String(input).replace(/=+$/, '');
if (str.length % 4 === 1) {
throw new Error("'atob' failed: The string to be decoded is not correctly encoded.");
}
for (
// initialize result and counters
var bc = 0, bs = 0, buffer = void 0, idx = 0;
// 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 = base64chars.indexOf(buffer);
}
return output;
}
exports.default = (typeof window !== 'undefined' && window.atob && window.atob.bind(window)) || atobPolyfill;
//# sourceMappingURL=atob.js.map