4 Commits

Author SHA1 Message Date
63c8dcd1a5 1.0.4 2022-12-22 17:23:23 +01:00
239fd7f000 fix(core): update 2022-12-22 17:23:23 +01:00
90b3ff40f4 1.0.3 2022-12-22 17:21:44 +01:00
fcc2bc2759 fix(core): update 2022-12-22 17:21:43 +01:00
7 changed files with 39 additions and 18 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "@pushrocks/webjwt", "name": "@pushrocks/webjwt",
"version": "1.0.2", "version": "1.0.4",
"private": false, "private": false,
"description": "a package to handle jwt in the web", "description": "a package to handle jwt in the web",
"main": "dist_ts/index.js", "main": "dist_ts/index.js",
@ -17,11 +17,14 @@
"@gitzone/tsbuild": "^2.1.25", "@gitzone/tsbuild": "^2.1.25",
"@gitzone/tsbundle": "^2.0.5", "@gitzone/tsbundle": "^2.0.5",
"@gitzone/tsdoc": "^1.1.10", "@gitzone/tsdoc": "^1.1.10",
"@gitzone/tsrun": "^1.2.39",
"@gitzone/tstest": "^1.0.44", "@gitzone/tstest": "^1.0.44",
"@pushrocks/tapbundle": "^5.0.3", "@pushrocks/tapbundle": "^5.0.3",
"@types/node": "^17.0.41" "@types/node": "^17.0.41"
}, },
"dependencies": {}, "dependencies": {
"@pushrocks/smartenv": "^5.0.3"
},
"browserslist": [ "browserslist": [
"last 1 chrome versions" "last 1 chrome versions"
], ],

15
pnpm-lock.yaml generated
View File

@ -4,14 +4,20 @@ specifiers:
'@gitzone/tsbuild': ^2.1.25 '@gitzone/tsbuild': ^2.1.25
'@gitzone/tsbundle': ^2.0.5 '@gitzone/tsbundle': ^2.0.5
'@gitzone/tsdoc': ^1.1.10 '@gitzone/tsdoc': ^1.1.10
'@gitzone/tsrun': ^1.2.39
'@gitzone/tstest': ^1.0.44 '@gitzone/tstest': ^1.0.44
'@pushrocks/smartenv': ^5.0.3
'@pushrocks/tapbundle': ^5.0.3 '@pushrocks/tapbundle': ^5.0.3
'@types/node': ^17.0.41 '@types/node': ^17.0.41
dependencies:
'@pushrocks/smartenv': 5.0.3
devDependencies: devDependencies:
'@gitzone/tsbuild': 2.1.65 '@gitzone/tsbuild': 2.1.65
'@gitzone/tsbundle': 2.0.7 '@gitzone/tsbundle': 2.0.7
'@gitzone/tsdoc': 1.1.12 '@gitzone/tsdoc': 1.1.12
'@gitzone/tsrun': 1.2.39_@types+node@17.0.45
'@gitzone/tstest': 1.0.74_@types+node@17.0.45 '@gitzone/tstest': 1.0.74_@types+node@17.0.45
'@pushrocks/tapbundle': 5.0.4 '@pushrocks/tapbundle': 5.0.4
'@types/node': 17.0.45 '@types/node': 17.0.45
@ -412,7 +418,6 @@ packages:
resolution: {integrity: sha512-/cgEDhOIo9LB5Vd2BVO9+QrjC38w872iy7w88UWuwz7obVILWOHl3MYMHAKFqXexuwKpQ/y/Klu2xQHtOPgi6Q==} resolution: {integrity: sha512-/cgEDhOIo9LB5Vd2BVO9+QrjC38w872iy7w88UWuwz7obVILWOHl3MYMHAKFqXexuwKpQ/y/Klu2xQHtOPgi6Q==}
dependencies: dependencies:
'@pushrocks/smartpromise': 3.1.7 '@pushrocks/smartpromise': 3.1.7
dev: true
/@pushrocks/smarterror/2.0.1: /@pushrocks/smarterror/2.0.1:
resolution: {integrity: sha512-3OrF5me+/sy5VgwR/tfCqs7qhb0Ywzgn8tTThRUZnCGas0aindISzMiW7cIro3RlFykmtPmdTztC9Ostu2ioeA==} resolution: {integrity: sha512-3OrF5me+/sy5VgwR/tfCqs7qhb0Ywzgn8tTThRUZnCGas0aindISzMiW7cIro3RlFykmtPmdTztC9Ostu2ioeA==}
@ -643,7 +648,6 @@ packages:
/@pushrocks/smartpromise/3.1.7: /@pushrocks/smartpromise/3.1.7:
resolution: {integrity: sha512-2gLQCeviEJwZ+cHHtK2Ks98brZatGC6dPXKIs1tVgJsiNgRFjnp90fESuJ1Pmoe7RrS+7J3mO4NtsFHAJJ/y5w==} resolution: {integrity: sha512-2gLQCeviEJwZ+cHHtK2Ks98brZatGC6dPXKIs1tVgJsiNgRFjnp90fESuJ1Pmoe7RrS+7J3mO4NtsFHAJJ/y5w==}
dev: true
/@pushrocks/smartpuppeteer/2.0.2: /@pushrocks/smartpuppeteer/2.0.2:
resolution: {integrity: sha512-l3tqnD6Evseofq1avHsMy2FXXEmCd4Z+nm3xmMWS7nWvP9qTbJIn0XguOBaUIAhR8zE53UKPXs5/qBqXVNZDDQ==} resolution: {integrity: sha512-l3tqnD6Evseofq1avHsMy2FXXEmCd4Z+nm3xmMWS7nWvP9qTbJIn0XguOBaUIAhR8zE53UKPXs5/qBqXVNZDDQ==}
@ -1328,6 +1332,11 @@ packages:
- utf-8-validate - utf-8-validate
dev: true dev: true
/@xmldom/xmldom/0.8.6:
resolution: {integrity: sha512-uRjjusqpoqfmRkTaNuLJ2VohVr67Q5YwDATW3VU7PfzTj6IRaihGrYI7zckGZjxQPBIp63nfvJbM+Yu5ICh0Bg==}
engines: {node: '>=10.0.0'}
dev: true
/accepts/1.3.8: /accepts/1.3.8:
resolution: {integrity: sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==} resolution: {integrity: sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==}
engines: {node: '>= 0.6'} engines: {node: '>= 0.6'}
@ -3453,6 +3462,8 @@ packages:
resolution: {integrity: sha512-mXF9AIgnvq1DP/ZM2R28tAfxP2wKZHYa2DjV0R1KCwcqSzm5Iqh1XQq9rdfAt6dp2DuPP0VHZIaCALc2v1cL5A==} resolution: {integrity: sha512-mXF9AIgnvq1DP/ZM2R28tAfxP2wKZHYa2DjV0R1KCwcqSzm5Iqh1XQq9rdfAt6dp2DuPP0VHZIaCALc2v1cL5A==}
engines: {node: '>=14.18.0', npm: '>=6.14.15'} engines: {node: '>=14.18.0', npm: '>=6.14.15'}
hasBin: true hasBin: true
dependencies:
'@xmldom/xmldom': 0.8.6
dev: true dev: true
bundledDependencies: bundledDependencies:
- '@xmldom/xmldom' - '@xmldom/xmldom'

View File

@ -21,7 +21,6 @@ Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](htt
PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@pushrocks/webjwt)](https://lossless.cloud) PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@pushrocks/webjwt)](https://lossless.cloud)
PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@pushrocks/webjwt)](https://lossless.cloud) PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@pushrocks/webjwt)](https://lossless.cloud)
BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@pushrocks/webjwt)](https://lossless.cloud) BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@pushrocks/webjwt)](https://lossless.cloud)
Platform support | [![Supports Windows 10](https://badgen.net/badge/supports%20Windows%2010/yes/green?icon=windows)](https://lossless.cloud) [![Supports Mac OS X](https://badgen.net/badge/supports%20Mac%20OS%20X/yes/green?icon=apple)](https://lossless.cloud)
## Usage ## 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. 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) | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
[![repo-footer](https://lossless.gitlab.io/publicrelations/repofooter.svg)](https://maintainedby.lossless.com)

View File

@ -4,10 +4,10 @@ import * as webjwt from '../ts/index.js';
tap.test('first test', async () => { tap.test('first test', async () => {
const originalString = JSON.stringify({ const originalString = JSON.stringify({
a: { a: {
"complex_2": { complex_2: {
"object": "yes", object: 'yes',
} },
} },
}); });
const stringToDecode = `abc.${btoa(originalString)}.rthgf`; const stringToDecode = `abc.${btoa(originalString)}.rthgf`;
const result = webjwt.getDataFromJwtString(stringToDecode); const result = webjwt.getDataFromJwtString(stringToDecode);

View File

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

View File

@ -1,8 +1,16 @@
import * as plugins from './webjwt.plugins.js'; import * as plugins from './webjwt.plugins.js';
export const getDataFromJwtString = <T = any>(jwtString: string): T => { export const getDataFromJwtString = <T = any>(jwtString: string): T => {
const smartenvInstance = new plugins.smartenv.Smartenv();
const splitted = jwtString.split('.'); const splitted = jwtString.split('.');
const dataBase64 = splitted[1]; const dataBase64 = splitted[1];
// @ts-ignore let plainJsonString: string;
return JSON.parse(atob(dataBase64)); 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,3 @@
const removeme = {}; import * as smartenv from '@pushrocks/smartenv';
export { removeme };
export { smartenv };