fix(core): update
This commit is contained in:
@ -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'
|
||||
}
|
||||
|
10
ts/index.ts
10
ts/index.ts
@ -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);
|
||||
};
|
||||
|
@ -1,3 +1,3 @@
|
||||
import * as smartenv from '@pushrocks/smartenv';
|
||||
import * as smartstring from '@pushrocks/smartstring';
|
||||
|
||||
export { smartenv };
|
||||
export { smartstring };
|
||||
|
Reference in New Issue
Block a user