@gandalan/weblibs 1.0.28 → 1.0.30
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 -15
- package/api/authUtils.js +5 -11
- package/package.json +1 -1
package/api/IDAS.js
CHANGED
|
@@ -4,33 +4,22 @@ import jwt_decode from 'jwt-decode';
|
|
|
4
4
|
|
|
5
5
|
export function IDASFactory(settings)
|
|
6
6
|
{
|
|
7
|
-
/*let defaultSettings = {
|
|
8
|
-
appToken: localStorage.getItem("IDAS_AppToken"),
|
|
9
|
-
mandantGuid: localStorage.getItem("IDAS_MandantGuid"),
|
|
10
|
-
apiBaseurl: localStorage.getItem("IDAS_ApiBaseUrl"),
|
|
11
|
-
authUrl : localStorage.getItem("IDAS_ApiBaseUrl"),
|
|
12
|
-
jwtRefreshToken: localStorage.getItem("IDAS_AuthJwtRefreshToken"),
|
|
13
|
-
jwtCallbackPath: localStorage.getItem("IDAS_AuthJwtCallbackPath"),
|
|
14
|
-
};
|
|
15
|
-
settings = { ...defaultSettings, ...settings };*/
|
|
16
|
-
let idas = undefined;
|
|
17
7
|
if (!isInvalid(settings))
|
|
18
8
|
{
|
|
19
|
-
|
|
20
|
-
idas = new IDAS(settings);
|
|
9
|
+
return new IDAS(settings);
|
|
21
10
|
}
|
|
22
|
-
else throw("Invalid settings: call
|
|
23
|
-
return idas;
|
|
11
|
+
else throw("Invalid settings: call initIDAS() first to obtain a valid settings!");
|
|
24
12
|
}
|
|
25
13
|
|
|
26
14
|
class IDAS
|
|
27
15
|
{
|
|
28
16
|
restClient = undefined;
|
|
29
|
-
mandantGuid =
|
|
17
|
+
mandantGuid = undefined;
|
|
30
18
|
|
|
31
19
|
constructor(settings)
|
|
32
20
|
{
|
|
33
21
|
this.settings = settings;
|
|
22
|
+
this.mandantGuid = settings.mandantGuid; // for backwards compatiblity only
|
|
34
23
|
this.restClient = new RESTClient(settings);
|
|
35
24
|
}
|
|
36
25
|
|
package/api/authUtils.js
CHANGED
|
@@ -14,15 +14,7 @@ export async function initIDAS(appToken) {
|
|
|
14
14
|
if (urlParams.has("j")) jwtToken = urlParams.get("j");
|
|
15
15
|
if (urlParams.has("t")) jwtRefreshToken = urlParams.get("t");
|
|
16
16
|
|
|
17
|
-
let settings = {
|
|
18
|
-
appToken,
|
|
19
|
-
mandantGuid,
|
|
20
|
-
apiBaseurl,
|
|
21
|
-
jwtToken: jwtToken,
|
|
22
|
-
jwtRefreshToken,
|
|
23
|
-
//jwtCallbackPath: localStorage.getItem("IDAS_AuthJwtCallbackPath")
|
|
24
|
-
}
|
|
25
|
-
|
|
17
|
+
let settings = { appToken, mandantGuid, apiBaseurl, jwtToken, jwtRefreshToken };
|
|
26
18
|
try {
|
|
27
19
|
await setup(settings);
|
|
28
20
|
if (isInvalid(settings))
|
|
@@ -35,7 +27,6 @@ export async function initIDAS(appToken) {
|
|
|
35
27
|
return settings;
|
|
36
28
|
}
|
|
37
29
|
|
|
38
|
-
|
|
39
30
|
export async function setup(settings)
|
|
40
31
|
{
|
|
41
32
|
console.log("Setup IDAS");
|
|
@@ -95,13 +86,16 @@ export async function tryRenew(settings)
|
|
|
95
86
|
localStorage.setItem("IDAS_AuthJwtRefreshToken", refreshToken);
|
|
96
87
|
}
|
|
97
88
|
|
|
89
|
+
let mandantGuid = decoded["mandantGuid"] || "";
|
|
90
|
+
if (mandantGuid)
|
|
91
|
+
settings.mandantGuid = mandantGuid;
|
|
92
|
+
|
|
98
93
|
if (isInvalid(settings))
|
|
99
94
|
console.log("Token is already expired!");
|
|
100
95
|
}
|
|
101
96
|
|
|
102
97
|
export function redirectToLogin(settings, authPath)
|
|
103
98
|
{
|
|
104
|
-
//localStorage.setItem("IDAS_AuthJwtCallbackPath", authPath || "");
|
|
105
99
|
const authEndpoint = (new URL(window.location.href).origin) + authPath;
|
|
106
100
|
let authUrlCallback = `${authEndpoint}?r=%target%&j=%jwt%&m=%mandant%`;
|
|
107
101
|
authUrlCallback = authUrlCallback.replace("%target%", encodeURIComponent(window.location.href));
|