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

Function parseJwt

entrypoints/service/microsoft.ts:40–51  ·  view source on GitHub ↗
(token: string)

Source from the content-addressed store, hash-verified

38
39// 解析 jwt,返回解析后对象
40function parseJwt(token: string) {
41 try {
42 const base64Url = token.split('.')[1];
43 const base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/');
44 const jsonPayload = decodeURIComponent(atob(base64).split('').map(c => {
45 return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
46 }).join(''));
47 return JSON.parse(jsonPayload);
48 } catch (e) {
49 return null;
50 }
51}
52
53export default microsoft;

Callers 1

refreshTokenFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected