MCPcopy Create free account
hub / github.com/Bistutu/FluentRead / parseJwt

Function parseJwt

userscripts.js:1085–1096  ·  view source on GitHub ↗
(token)

Source from the content-addressed store, hash-verified

1083
1084// 解析 jwt,返回解析后对象
1085function parseJwt(token) {
1086 try {
1087 const base64Url = token.split('.')[1];
1088 const base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/');
1089 const jsonPayload = decodeURIComponent(atob(base64).split('').map(function (c) {
1090 return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
1091 }).join(''));
1092 return JSON.parse(jsonPayload);
1093 } catch (e) {
1094 return null;
1095 }
1096}
1097
1098// endregion
1099

Callers 1

refreshTokenFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected