Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
93cbd9bcbe | |||
b716e160e0 | |||
63c8dcd1a5 | |||
239fd7f000 | |||
90b3ff40f4 | |||
fcc2bc2759 |
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@pushrocks/webjwt",
|
||||
"version": "1.0.2",
|
||||
"version": "1.0.5",
|
||||
"private": false,
|
||||
"description": "a package to handle jwt in the web",
|
||||
"main": "dist_ts/index.js",
|
||||
@ -17,11 +17,14 @@
|
||||
"@gitzone/tsbuild": "^2.1.25",
|
||||
"@gitzone/tsbundle": "^2.0.5",
|
||||
"@gitzone/tsdoc": "^1.1.10",
|
||||
"@gitzone/tsrun": "^1.2.39",
|
||||
"@gitzone/tstest": "^1.0.44",
|
||||
"@pushrocks/tapbundle": "^5.0.3",
|
||||
"@types/node": "^17.0.41"
|
||||
"@types/node": "^18.11.17"
|
||||
},
|
||||
"dependencies": {
|
||||
"@pushrocks/smartenv": "^5.0.3"
|
||||
},
|
||||
"dependencies": {},
|
||||
"browserslist": [
|
||||
"last 1 chrome versions"
|
||||
],
|
||||
|
37
pnpm-lock.yaml
generated
37
pnpm-lock.yaml
generated
@ -4,17 +4,23 @@ specifiers:
|
||||
'@gitzone/tsbuild': ^2.1.25
|
||||
'@gitzone/tsbundle': ^2.0.5
|
||||
'@gitzone/tsdoc': ^1.1.10
|
||||
'@gitzone/tsrun': ^1.2.39
|
||||
'@gitzone/tstest': ^1.0.44
|
||||
'@pushrocks/smartenv': ^5.0.3
|
||||
'@pushrocks/tapbundle': ^5.0.3
|
||||
'@types/node': ^17.0.41
|
||||
'@types/node': ^18.11.17
|
||||
|
||||
dependencies:
|
||||
'@pushrocks/smartenv': 5.0.3
|
||||
|
||||
devDependencies:
|
||||
'@gitzone/tsbuild': 2.1.65
|
||||
'@gitzone/tsbundle': 2.0.7
|
||||
'@gitzone/tsdoc': 1.1.12
|
||||
'@gitzone/tstest': 1.0.74_@types+node@17.0.45
|
||||
'@gitzone/tsrun': 1.2.39_@types+node@18.11.17
|
||||
'@gitzone/tstest': 1.0.74_@types+node@18.11.17
|
||||
'@pushrocks/tapbundle': 5.0.4
|
||||
'@types/node': 17.0.45
|
||||
'@types/node': 18.11.17
|
||||
|
||||
packages:
|
||||
|
||||
@ -162,13 +168,13 @@ packages:
|
||||
- supports-color
|
||||
dev: true
|
||||
|
||||
/@gitzone/tsrun/1.2.39_@types+node@17.0.45:
|
||||
/@gitzone/tsrun/1.2.39_@types+node@18.11.17:
|
||||
resolution: {integrity: sha512-gLqKOic3T1GIdqsp+T5g1OewfboMJKKMr7/SJgBuMx4BUEBfW7TYhqk6psgfewhHs/zKII5rWbbPauykkKlYIg==}
|
||||
hasBin: true
|
||||
dependencies:
|
||||
'@pushrocks/smartfile': 10.0.5
|
||||
'@pushrocks/smartshell': 2.0.30
|
||||
ts-node: 10.9.1_zpb5kzpnyozdjq4cwaojlul57u
|
||||
ts-node: 10.9.1_moeqx3xmzxqxagf2sz6mqkbb7m
|
||||
typescript: 4.9.4
|
||||
transitivePeerDependencies:
|
||||
- '@swc/core'
|
||||
@ -177,12 +183,12 @@ packages:
|
||||
- supports-color
|
||||
dev: true
|
||||
|
||||
/@gitzone/tstest/1.0.74_@types+node@17.0.45:
|
||||
/@gitzone/tstest/1.0.74_@types+node@18.11.17:
|
||||
resolution: {integrity: sha512-6V8bsfvpnODWqrkdooVqcOS1z5GA8dMDnLCOHnr/SUTeie3ox8KGpckwiZ+gTfz9WvzX6+KLVTZNYKGOaNbmMQ==}
|
||||
hasBin: true
|
||||
dependencies:
|
||||
'@gitzone/tsbundle': 2.0.7
|
||||
'@gitzone/tsrun': 1.2.39_@types+node@17.0.45
|
||||
'@gitzone/tsrun': 1.2.39_@types+node@18.11.17
|
||||
'@pushrocks/consolecolor': 2.0.1
|
||||
'@pushrocks/smartbrowser': 2.0.5
|
||||
'@pushrocks/smartdelay': 2.0.13
|
||||
@ -412,7 +418,6 @@ packages:
|
||||
resolution: {integrity: sha512-/cgEDhOIo9LB5Vd2BVO9+QrjC38w872iy7w88UWuwz7obVILWOHl3MYMHAKFqXexuwKpQ/y/Klu2xQHtOPgi6Q==}
|
||||
dependencies:
|
||||
'@pushrocks/smartpromise': 3.1.7
|
||||
dev: true
|
||||
|
||||
/@pushrocks/smarterror/2.0.1:
|
||||
resolution: {integrity: sha512-3OrF5me+/sy5VgwR/tfCqs7qhb0Ywzgn8tTThRUZnCGas0aindISzMiW7cIro3RlFykmtPmdTztC9Ostu2ioeA==}
|
||||
@ -643,7 +648,6 @@ packages:
|
||||
|
||||
/@pushrocks/smartpromise/3.1.7:
|
||||
resolution: {integrity: sha512-2gLQCeviEJwZ+cHHtK2Ks98brZatGC6dPXKIs1tVgJsiNgRFjnp90fESuJ1Pmoe7RrS+7J3mO4NtsFHAJJ/y5w==}
|
||||
dev: true
|
||||
|
||||
/@pushrocks/smartpuppeteer/2.0.2:
|
||||
resolution: {integrity: sha512-l3tqnD6Evseofq1avHsMy2FXXEmCd4Z+nm3xmMWS7nWvP9qTbJIn0XguOBaUIAhR8zE53UKPXs5/qBqXVNZDDQ==}
|
||||
@ -1135,10 +1139,6 @@ packages:
|
||||
resolution: {integrity: sha512-K0VQKziLUWkVKiRVrx4a40iPaxTUefQmjtkQofBkYRcoaaL/8rhwDWww9qWbrgicNOgnpIsMxyNIUM4+n6dUIA==}
|
||||
dev: true
|
||||
|
||||
/@types/node/17.0.45:
|
||||
resolution: {integrity: sha512-w+tIMs3rq2afQdsPJlODhoUEKzFP1ayaoyl1CcnwtIlsVe7K7bA1NGm4s3PraqTLlXnbIN84zuBlxBWo1u9BLw==}
|
||||
dev: true
|
||||
|
||||
/@types/node/18.11.17:
|
||||
resolution: {integrity: sha512-HJSUJmni4BeDHhfzn6nF0sVmd1SMezP7/4F0Lq+aXzmp2xm9O7WXrUtHW/CHlYVtZUbByEvWidHqRtcJXGF2Ng==}
|
||||
dev: true
|
||||
@ -1328,6 +1328,11 @@ packages:
|
||||
- utf-8-validate
|
||||
dev: true
|
||||
|
||||
/@xmldom/xmldom/0.8.6:
|
||||
resolution: {integrity: sha512-uRjjusqpoqfmRkTaNuLJ2VohVr67Q5YwDATW3VU7PfzTj6IRaihGrYI7zckGZjxQPBIp63nfvJbM+Yu5ICh0Bg==}
|
||||
engines: {node: '>=10.0.0'}
|
||||
dev: true
|
||||
|
||||
/accepts/1.3.8:
|
||||
resolution: {integrity: sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==}
|
||||
engines: {node: '>= 0.6'}
|
||||
@ -3453,6 +3458,8 @@ packages:
|
||||
resolution: {integrity: sha512-mXF9AIgnvq1DP/ZM2R28tAfxP2wKZHYa2DjV0R1KCwcqSzm5Iqh1XQq9rdfAt6dp2DuPP0VHZIaCALc2v1cL5A==}
|
||||
engines: {node: '>=14.18.0', npm: '>=6.14.15'}
|
||||
hasBin: true
|
||||
dependencies:
|
||||
'@xmldom/xmldom': 0.8.6
|
||||
dev: true
|
||||
bundledDependencies:
|
||||
- '@xmldom/xmldom'
|
||||
@ -4069,7 +4076,7 @@ packages:
|
||||
hasBin: true
|
||||
dev: true
|
||||
|
||||
/ts-node/10.9.1_zpb5kzpnyozdjq4cwaojlul57u:
|
||||
/ts-node/10.9.1_moeqx3xmzxqxagf2sz6mqkbb7m:
|
||||
resolution: {integrity: sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==}
|
||||
hasBin: true
|
||||
peerDependencies:
|
||||
@ -4088,7 +4095,7 @@ packages:
|
||||
'@tsconfig/node12': 1.0.11
|
||||
'@tsconfig/node14': 1.0.3
|
||||
'@tsconfig/node16': 1.0.3
|
||||
'@types/node': 17.0.45
|
||||
'@types/node': 18.11.17
|
||||
acorn: 8.8.1
|
||||
acorn-walk: 8.2.0
|
||||
arg: 4.1.3
|
||||
|
@ -21,7 +21,6 @@ Code Style | [](htt
|
||||
PackagePhobia (total standalone install weight) | [](https://lossless.cloud)
|
||||
PackagePhobia (package size on registry) | [](https://lossless.cloud)
|
||||
BundlePhobia (total size when bundled) | [](https://lossless.cloud)
|
||||
Platform support | [](https://lossless.cloud) [](https://lossless.cloud)
|
||||
|
||||
## Usage
|
||||
|
||||
@ -33,7 +32,6 @@ We are always happy for code contributions. If you are not the code contributing
|
||||
|
||||
For further information read the linked docs at the top of this readme.
|
||||
|
||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||
## Legal
|
||||
> MIT licensed | **©** [Task Venture Capital GmbH](https://task.vc)
|
||||
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
||||
|
||||
[](https://maintainedby.lossless.com)
|
||||
|
@ -4,10 +4,10 @@ import * as webjwt from '../ts/index.js';
|
||||
tap.test('first test', async () => {
|
||||
const originalString = JSON.stringify({
|
||||
a: {
|
||||
"complex_2": {
|
||||
"object": "yes",
|
||||
}
|
||||
}
|
||||
complex_2: {
|
||||
object: 'yes',
|
||||
},
|
||||
},
|
||||
});
|
||||
const stringToDecode = `abc.${btoa(originalString)}.rthgf`;
|
||||
const result = webjwt.getDataFromJwtString(stringToDecode);
|
@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@pushrocks/webjwt',
|
||||
version: '1.0.2',
|
||||
version: '1.0.5',
|
||||
description: 'a package to handle jwt in the web'
|
||||
}
|
||||
|
14
ts/index.ts
14
ts/index.ts
@ -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);
|
||||
};
|
||||
|
@ -1,2 +1,3 @@
|
||||
const removeme = {};
|
||||
export { removeme };
|
||||
import * as smartenv from '@pushrocks/smartenv';
|
||||
|
||||
export { smartenv };
|
||||
|
Reference in New Issue
Block a user