@gandalan/weblibs 0.0.40 → 0.0.41

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 +14 -5
  2. package/package.json +1 -1
package/api/IDAS.js CHANGED
@@ -26,6 +26,11 @@ export class IDAS {
26
26
  return data;
27
27
  }
28
28
 
29
+ authorizeWithJwt(jwtToken) {
30
+ localStorage.setItem('IDAS_AuthJwtToken', jwtToken);
31
+ restClient = new RESTClient(apiBaseUrl, jwtToken, true);
32
+ }
33
+
29
34
  async authenticateWithSSO(forceRenew = false) {
30
35
  if (!authToken)
31
36
  {
@@ -42,16 +47,20 @@ export class IDAS {
42
47
  }
43
48
  }
44
49
 
45
- async authenticateWithJwt() {
50
+ async authenticateWithJwt(authPath) {
46
51
  if (!authJwtToken) {
52
+ const authEndpoint = (new URL(window.location.href).origin) + authPath;
53
+ let authUrlCallback = `${authEndpoint}?r=%target%&t=%jwt%`;
54
+ authUrlCallback = authUrlCallback.replace('%target%', encodeURIComponent(window.location.href));
55
+
47
56
  const url = new URL(apiBaseUrl);
48
57
  url.pathname = "/Session";
49
- url.search = "?a=" + appToken;
50
- url.search = url.search + "&r=%target%";
51
- let jwtAuthUrl = url.toString();
58
+ url.search = `?a=${appToken}&r=${encodeURIComponent(authUrlCallback)}`;
59
+ let jwtUrl = url.toString();
52
60
 
53
- var jwtUrl = jwtAuthUrl.replace("%target%", encodeURIComponent(window.location.href));
54
61
  window.location = jwtUrl;
62
+ } else {
63
+ restClient = new RESTClient(apiBaseUrl, authJwtToken, true);
55
64
  }
56
65
  }
57
66
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gandalan/weblibs",
3
- "version": "0.0.40",
3
+ "version": "0.0.41",
4
4
  "description": "WebLibs for Gandalan JS/TS/Svelte projects",
5
5
  "author": "Philipp Reif",
6
6
  "license": "ISC",