UNPKG
gnar-edge
Version:
latest (2.0.8)
2.0.8
2.0.7
2.0.6
2.0.4
2.0.3
2.0.2
2.0.1
2.0.0
1.0.10
1.0.9
1.0.8
1.0.7
1.0.6
1.0.5
1.0.4
1.0.3
1.0.2
1.0.1
1.0.0
A sharp set of utilities: base64, drain, handleChange, jwt, notifications
gitlab.com/gnaar/edge
gnar-edge
/
es
/
jwtDecode.js
11 lines
(9 loc)
•
246 B
JavaScript
View Raw
1
2
3
4
5
6
7
8
9
10
11
import
base64
from
'./base64'
;
export
default
token => {
const
[ , payload ] = token.
split
(
'.'
).
reverse
();
try
{
return
JSON
.
parse
(base64.
decode
(payload)); }
catch
(e) {
throw
new
TypeError
(
`Invalid JWT token: "
${token}
"`
); } };