@gandalan/weblibs 1.0.21 → 1.0.23
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 +11 -8
- package/api/authUtils.js +2 -2
- package/package.json +1 -1
package/api/IDAS.js
CHANGED
|
@@ -2,16 +2,19 @@ import { jwtTokenInvalid } from "./authUtils";
|
|
|
2
2
|
import { RESTClient } from "./RESTClient";
|
|
3
3
|
import jwt_decode from 'jwt-decode';
|
|
4
4
|
|
|
5
|
-
export function IDASFactory(settings
|
|
6
|
-
appToken : localStorage.getItem("IDAS_AppToken"),
|
|
7
|
-
mandantGuid : localStorage.getItem("IDAS_MandantGuid"),
|
|
8
|
-
apiBaseurl : localStorage.getItem("IDAS_ApiBaseUrl"),
|
|
9
|
-
jwtRefreshToken : localStorage.getItem("IDAS_AuthJwtRefreshToken"),
|
|
10
|
-
jwtCallbackPath : localStorage.getItem("IDAS_AuthJwtCallbackPath")
|
|
11
|
-
})
|
|
5
|
+
export function IDASFactory(settings)
|
|
12
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 };
|
|
13
16
|
let idas = undefined;
|
|
14
|
-
if (!jwtTokenInvalid(settings))
|
|
17
|
+
if (!jwtTokenInvalid(settings))
|
|
15
18
|
{
|
|
16
19
|
console.log("init: with JWT token");
|
|
17
20
|
idas = new IDAS(settings);
|
package/api/authUtils.js
CHANGED
|
@@ -41,7 +41,7 @@ export function jwtTokenInvalid(settings)
|
|
|
41
41
|
export async function jwtTokenRenew(settings)
|
|
42
42
|
{
|
|
43
43
|
console.log("try to refresh");
|
|
44
|
-
const renewSettings = { ...settings, jwtToken : undefined };
|
|
44
|
+
const renewSettings = { ...settings, jwtToken : undefined, apiBaseurl : settings.authUrl || settings.apiBaseurl };
|
|
45
45
|
let api = new RESTClient(renewSettings);
|
|
46
46
|
const payload = { "Token" : settings.jwtRefreshToken };
|
|
47
47
|
const response = await api.put("LoginJwt/Refresh", payload);
|
|
@@ -68,7 +68,7 @@ export function jwtAuthenticateOnBackend(settings, authPath)
|
|
|
68
68
|
let authUrlCallback = `${authEndpoint}?r=%target%&j=%jwt%&m=%mandant%`;
|
|
69
69
|
authUrlCallback = authUrlCallback.replace("%target%", encodeURIComponent(window.location.href));
|
|
70
70
|
|
|
71
|
-
const url = new URL(settings.apiBaseurl);
|
|
71
|
+
const url = new URL(settings.authUrl || settings.apiBaseurl);
|
|
72
72
|
url.pathname = "/Session";
|
|
73
73
|
url.search = `?a=${settings.appToken}&r=${encodeURIComponent(authUrlCallback)}`;
|
|
74
74
|
let jwtUrl = url.toString();
|