1JSON Web Token is an Internet standard for creating data with optional
2signature and/or optional encryption whose payload holds JSON that asserts
3some number of claims.
4
5The tokens are signed either using a private secret or a public/private key.
1function parseJwt (token) {
2 var base64Url = token.split('.')[1];
3 var base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/');
4 var jsonPayload = decodeURIComponent(atob(base64).split('').map(function(c) {
5 return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
6 }).join(''));
7
8 return JSON.parse(jsonPayload);
9};