webjwt/ts/index.ts

9 lines
311 B
TypeScript
Raw Permalink Normal View History

2022-12-22 16:12:15 +00:00
import * as plugins from './webjwt.plugins.js';
export const getDataFromJwtString = <T = any>(jwtString: string): T => {
const splitted = jwtString.split('.');
const dataBase64 = splitted[1];
2022-12-31 19:49:34 +00:00
const plainJsonString = plugins.smartstring.base64.decode(dataBase64);
2022-12-22 16:21:43 +00:00
return JSON.parse(plainJsonString);
2022-12-22 16:23:23 +00:00
};