@gandalan/weblibs 1.0.2 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/api/IDAS.js +32 -0
  2. package/package.json +1 -1
package/api/IDAS.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { RESTClient } from './RESTClient';
2
+ import jwt_decode from 'jwt-decode';
2
3
 
3
4
  let appToken = localStorage.getItem('IDAS_AppToken') || '66B70E0B-F7C4-4829-B12A-18AD309E3970';
4
5
  let authToken = localStorage.getItem('IDAS_AuthToken');
@@ -72,6 +73,37 @@ class IDAS {
72
73
 
73
74
  mandantGuid = localStorage.getItem('IDAS_MandantGuid');
74
75
 
76
+ claims = {
77
+ hasClaim(key) {
78
+ if (!authJwtToken) {
79
+ return false;
80
+ }
81
+
82
+ try {
83
+ let decoded = jwt_decode(authJwtToken);
84
+ let val = decoded[key];
85
+ return val !== undefined;
86
+ }
87
+ catch {}
88
+
89
+ return false;
90
+ },
91
+
92
+ getClaim(key) {
93
+ if (!authJwtToken) {
94
+ return;
95
+ }
96
+
97
+ try {
98
+ let decoded = jwt_decode(authJwtToken);
99
+ return decoded[key];
100
+ }
101
+ catch {}
102
+
103
+ return;
104
+ }
105
+ }
106
+
75
107
  auth = {
76
108
  _self: this,
77
109
  async getCurrentAuthToken() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gandalan/weblibs",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "WebLibs for Gandalan JS/TS/Svelte projects",
5
5
  "author": "Philipp Reif",
6
6
  "license": "ISC",