@gandalan/weblibs 1.1.3 → 1.1.5
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.
- package/api/IDAS.js +4 -4
- package/api/authUtils.js +5 -5
- package/package.json +9 -9
package/api/IDAS.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isInvalid, currentToken} from "./authUtils";
|
|
2
2
|
import { RESTClient } from "./RESTClient";
|
|
3
|
-
import
|
|
3
|
+
import { jwtDecode } from "jwt-decode";
|
|
4
4
|
|
|
5
5
|
export function IDASFactory(settings)
|
|
6
6
|
{
|
|
@@ -37,7 +37,7 @@ class IDAS
|
|
|
37
37
|
return [];
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
const decoded =
|
|
40
|
+
const decoded = jwtDecode(currentToken);
|
|
41
41
|
return decoded.rights;
|
|
42
42
|
},
|
|
43
43
|
getRoles()
|
|
@@ -47,7 +47,7 @@ class IDAS
|
|
|
47
47
|
return [];
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
const decoded =
|
|
50
|
+
const decoded = jwtDecode(currentToken);
|
|
51
51
|
return decoded.role;
|
|
52
52
|
},
|
|
53
53
|
hasRight(code)
|
|
@@ -65,7 +65,7 @@ class IDAS
|
|
|
65
65
|
return undefined;
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
const decoded =
|
|
68
|
+
const decoded = jwtDecode(currentToken);
|
|
69
69
|
return decoded.id;
|
|
70
70
|
},
|
|
71
71
|
};
|
package/api/authUtils.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable no-console */
|
|
2
|
-
import
|
|
2
|
+
import { jwtDecode } from "jwt-decode";
|
|
3
3
|
|
|
4
4
|
export let currentToken = undefined;
|
|
5
5
|
export let currentRefreshToken = undefined;
|
|
@@ -70,7 +70,7 @@ export async function setup(settings)
|
|
|
70
70
|
else
|
|
71
71
|
{
|
|
72
72
|
console.log("Settings already have a valid JWT token, nothing to do");
|
|
73
|
-
let decoded =
|
|
73
|
+
let decoded = jwtDecode(currentToken);
|
|
74
74
|
let refreshToken = decoded["refreshToken"] || "";
|
|
75
75
|
if (refreshToken)
|
|
76
76
|
{
|
|
@@ -99,7 +99,7 @@ function startRefreshTimer(settings)
|
|
|
99
99
|
{
|
|
100
100
|
if (currentToken)
|
|
101
101
|
{
|
|
102
|
-
let decoded =
|
|
102
|
+
let decoded = jwtDecode(currentToken);
|
|
103
103
|
const utcNow = Date.parse(new Date().toUTCString()) / 1000;
|
|
104
104
|
if (decoded && utcNow > decoded.exp - 120)
|
|
105
105
|
{
|
|
@@ -115,7 +115,7 @@ export function isInvalid(settings)
|
|
|
115
115
|
{
|
|
116
116
|
return true;
|
|
117
117
|
}
|
|
118
|
-
let decoded =
|
|
118
|
+
let decoded = jwtDecode(currentToken);
|
|
119
119
|
const utcNow = Date.parse(new Date().toUTCString()) / 1000;
|
|
120
120
|
if (decoded && decoded.exp > utcNow)
|
|
121
121
|
{
|
|
@@ -139,7 +139,7 @@ export async function tryRenew(settings)
|
|
|
139
139
|
currentToken = token;
|
|
140
140
|
//console.log("Got JWT token:", currentToken);
|
|
141
141
|
|
|
142
|
-
let decoded =
|
|
142
|
+
let decoded = jwtDecode(currentToken);
|
|
143
143
|
let refreshToken = decoded["refreshToken"] || "";
|
|
144
144
|
if (refreshToken)
|
|
145
145
|
{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gandalan/weblibs",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.5",
|
|
4
4
|
"description": "WebLibs for Gandalan JS/TS/Svelte projects",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"gandalan"
|
|
@@ -20,18 +20,18 @@
|
|
|
20
20
|
"lint:fix": "eslint . --fix"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@mdi/js": "^7.
|
|
24
|
-
"axios": "^
|
|
25
|
-
"jwt-decode": "^
|
|
23
|
+
"@mdi/js": "^7.3.67",
|
|
24
|
+
"axios": "^1.6.1",
|
|
25
|
+
"jwt-decode": "^4.0.0",
|
|
26
26
|
"svelte-table": "^0.6.1"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@babel/eslint-parser": "^7.
|
|
29
|
+
"@babel/eslint-parser": "^7.23.3",
|
|
30
30
|
"chota": "^0.9.2",
|
|
31
|
-
"eslint": "^8.
|
|
32
|
-
"eslint-plugin-svelte": "^2.
|
|
33
|
-
"svelte": "^4.2.
|
|
34
|
-
"svelte-check": "^3.
|
|
31
|
+
"eslint": "^8.53.0",
|
|
32
|
+
"eslint-plugin-svelte": "^2.35.0",
|
|
33
|
+
"svelte": "^4.2.3",
|
|
34
|
+
"svelte-check": "^3.6.0",
|
|
35
35
|
"svelte-chota": "^1.8.6"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|