1let b64DecodeUnicode = str =>
2 decodeURIComponent(
3 Array.prototype.map.call(atob(str), c =>
4 '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2)
5 ).join(''))
6
7let parseJwt = token =>
8 JSON.parse(
9 b64DecodeUnicode(
10 token.split('.')[1].replace('-', '+').replace('_', '/')
11 )
12 )