@gandalan/weblibs 1.0.28 → 1.0.29
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 +1 -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");
|
|
@@ -101,7 +92,6 @@ export async function tryRenew(settings)
|
|
|
101
92
|
|
|
102
93
|
export function redirectToLogin(settings, authPath)
|
|
103
94
|
{
|
|
104
|
-
//localStorage.setItem("IDAS_AuthJwtCallbackPath", authPath || "");
|
|
105
95
|
const authEndpoint = (new URL(window.location.href).origin) + authPath;
|
|
106
96
|
let authUrlCallback = `${authEndpoint}?r=%target%&j=%jwt%&m=%mandant%`;
|
|
107
97
|
authUrlCallback = authUrlCallback.replace("%target%", encodeURIComponent(window.location.href));
|