@gandalan/weblibs 0.0.16 → 0.0.17

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 +6 -18
  2. package/package.json +1 -1
package/api/IDAS.js CHANGED
@@ -1,25 +1,13 @@
1
1
  import { RESTClient } from "./RESTClient";
2
2
 
3
- /*if (window.location.search) {
4
- var urlParams = new URLSearchParams(location.search);
5
- if (urlParams.has("t"))
6
- localStorage.setItem("IDAS_AuthToken", urlParams.get("t"));
7
- if (urlParams.has("m"))
8
- localStorage.setItem("IDAS_MandantGuid", urlParams.get("m"));
9
- if (urlParams.has("a"))
10
- localStorage.setItem("IDAS_ApiBaseUrl", urlParams.get("a"));
11
- window.location = window.location.origin;
12
- }*/
13
-
14
3
  let appToken = localStorage.getItem("IDAS_AppToken") || "66B70E0B-F7C4-4829-B12A-18AD309E3970";
15
4
  let authToken = localStorage.getItem("IDAS_AuthToken");
16
- //let mandantGuid = localStorage.getItem("IDAS_MandantGuid");
17
5
  let apiBaseUrl = localStorage.getItem("IDAS_ApiBaseUrl") || "https://api.dev.idas-cloudservices.net/api/";
18
- //let siteBaseUrl = localStorage.getItem("SiteBaseUrl") || window.location.protocol + "//" + window.location.host;
19
6
 
20
- let ssoAuthUrl = apiBaseUrl + "/SSO?a=" + appToken + "&r=%target%%3Ft=%token%%26m=%mandant%";
21
- ssoAuthUrl = ssoAuthUrl.replace('/api/', '/');
22
- ssoAuthUrl = ssoAuthUrl.replace('//', '/');
7
+ const url = new URL(apiBaseUrl);
8
+ url.pathname = "/SSO";
9
+ url.search = "?a=" + appToken + "&r=%target%%3Ft=%token%%26m=%mandant%";
10
+ let ssoAuthUrl = url.toString();
23
11
 
24
12
  let restClient = new RESTClient(apiBaseUrl, authToken);
25
13
  restClient.onError = (error, message) => {
@@ -27,7 +15,7 @@ restClient.onError = (error, message) => {
27
15
  {
28
16
  //console.log(message+" would remove Token");
29
17
  localStorage.removeItem("IDAS_AuthToken");
30
- var ssoURL = ssoAuthUrl.replace("%target%", window.location.origin);
18
+ var ssoURL = ssoAuthUrl.replace("%target%", encodeURIComponent(window.location.origin));
31
19
  window.location = ssoURL;
32
20
  }
33
21
  }
@@ -50,7 +38,7 @@ export class IDAS
50
38
  async authenticateWithSSO() {
51
39
  if (!authToken)
52
40
  {
53
- var ssoURL = ssoAuthUrl.replace("%target%", window.location.origin);
41
+ var ssoURL = ssoAuthUrl.replace("%target%", encodeURIComponent(window.location.origin));
54
42
  window.location = ssoURL;
55
43
  }
56
44
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gandalan/weblibs",
3
- "version": "0.0.16",
3
+ "version": "0.0.17",
4
4
  "description": "WebLibs for Gandalan JS/TS/Svelte projects",
5
5
  "author": "Philipp Reif",
6
6
  "license": "ISC",