fix(core): update

This commit is contained in:
2022-12-31 20:49:34 +01:00
parent 93cbd9bcbe
commit bae4429dde
5 changed files with 48 additions and 76 deletions

View File

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

View File

@ -1,16 +1,8 @@
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];
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');
}
const plainJsonString = plugins.smartstring.base64.decode(dataBase64);
return JSON.parse(plainJsonString);
};

View File

@ -1,3 +1,3 @@
import * as smartenv from '@pushrocks/smartenv';
import * as smartstring from '@pushrocks/smartstring';
export { smartenv };
export { smartstring };