fix(core): update

This commit is contained in:
2022-12-22 17:21:43 +01:00
parent 15525b4731
commit fcc2bc2759
6 changed files with 33 additions and 8 deletions

View File

@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@pushrocks/webjwt',
version: '1.0.2',
version: '1.0.3',
description: 'a package to handle jwt in the web'
}

View File

@ -1,8 +1,16 @@
import * as plugins from './webjwt.plugins.js';
export const getDataFromJwtString = <T = any>(jwtString: string): T => {
const smartenvInstance = new plugins.smartenv.Smartenv();
const splitted = jwtString.split('.');
const dataBase64 = splitted[1];
// @ts-ignore
return JSON.parse(atob(dataBase64));
let plainJsonString: string;
if (smartenvInstance.isBrowser) {
// @ts-ignore
plainJsonString = atob(dataBase64);
} else if (smartenvInstance.isNode) {
let buff = new Buffer(dataBase64, 'base64');
plainJsonString = buff.toString('ascii');
}
return JSON.parse(plainJsonString);
}

View File

@ -1,2 +1,5 @@
const removeme = {};
export { removeme };
import * as smartenv from '@pushrocks/smartenv';
export {
smartenv
}