zavadil-ts-common 1.2.23 → 1.2.25
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/dist/index.d.ts +3 -3
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/oauth/RestClientWithOAuth.d.ts +3 -3
- package/package.json +1 -1
- package/src/oauth/RestClientWithOAuth.ts +10 -14
@@ -40,8 +40,7 @@ export class RestClientWithOAuth extends RestClient {
|
|
40
40
|
return this.setIdTokenRaw(urlToken)
|
41
41
|
.then(() => {
|
42
42
|
console.log("Redirecting to url without id token");
|
43
|
-
this.deleteIdTokenFromUrl();
|
44
|
-
//document.location =;
|
43
|
+
document.location = this.deleteIdTokenFromUrl();
|
45
44
|
});
|
46
45
|
} else {
|
47
46
|
const storageToken = this.getIdTokenFromLocalStorage();
|
@@ -61,7 +60,7 @@ export class RestClientWithOAuth extends RestClient {
|
|
61
60
|
console.log('OAuth initialization failed:', reason);
|
62
61
|
return this.getServerInfo().then(
|
63
62
|
(si) => {
|
64
|
-
const location = `${si.oauthServerUrl}/login?app_name=${si.targetAudience}&redirect_url=${
|
63
|
+
const location = `${si.oauthServerUrl}/login?app_name=${si.targetAudience}&redirect_url=${this.deleteIdTokenFromUrl()}`;
|
65
64
|
console.log('Redirecting to login page:', location);
|
66
65
|
document.location = location;
|
67
66
|
}
|
@@ -87,10 +86,13 @@ export class RestClientWithOAuth extends RestClient {
|
|
87
86
|
return this.defaultPrivilege;
|
88
87
|
}
|
89
88
|
|
90
|
-
deleteIdTokenFromUrl() {
|
89
|
+
deleteIdTokenFromUrl(): string {
|
91
90
|
const up = new URLSearchParams(document.location.search);
|
92
91
|
up.delete(this.tokenName);
|
93
|
-
|
92
|
+
const loc = new Location();
|
93
|
+
loc.replace(document.location.toString());
|
94
|
+
loc.search = up.toString();
|
95
|
+
return loc.toString();
|
94
96
|
}
|
95
97
|
|
96
98
|
getIdTokenFromUrl(): string | null {
|
@@ -170,19 +172,13 @@ export class RestClientWithOAuth extends RestClient {
|
|
170
172
|
}
|
171
173
|
|
172
174
|
/**
|
173
|
-
* Try to obtain access token, then return
|
175
|
+
* Try to obtain access token, then return if everything is okay.
|
174
176
|
* This is basically only used when initializing and trying to determine whether we need to redirect user to login page
|
175
177
|
*/
|
176
|
-
checkAccessToken(privilege?: string): Promise<
|
178
|
+
checkAccessToken(privilege?: string): Promise<any> {
|
177
179
|
return this.getTokenManager()
|
178
180
|
.then(tm => tm.getAccessToken(StringUtil.getNonEmpty(privilege, this.defaultPrivilege)))
|
179
|
-
.
|
180
|
-
.catch(
|
181
|
-
(e) => {
|
182
|
-
console.error('Access token check failed:', e);
|
183
|
-
return false;
|
184
|
-
}
|
185
|
-
);
|
181
|
+
.catch((e) => Promise.reject(`Access token check failed: ${e}`));
|
186
182
|
}
|
187
183
|
|
188
184
|
}
|