zavadil-ts-common 1.1.69 → 1.1.71
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 +4 -7
- 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/OAuthRestClient.d.ts +3 -6
- package/dist/oauth/RestClientWithOAuth.d.ts +1 -1
- package/dist/util/JsonUtil.d.ts +1 -0
- package/package.json +1 -1
- package/src/oauth/OAuthRestClient.ts +1 -2
- package/src/oauth/OAuthTokenManager.ts +7 -10
- package/src/oauth/RestClientWithOAuth.ts +13 -16
- package/src/util/JsonUtil.ts +4 -0
@@ -3,6 +3,7 @@ import {RestClient, RestClientHeaders} from "../client";
|
|
3
3
|
import {IdTokenPayload} from "./OAuthRestClient";
|
4
4
|
import {LazyAsync} from "../cache";
|
5
5
|
import {DateUtil, StringUtil} from "../util";
|
6
|
+
import {JsonUtil} from "../util/JsonUtil";
|
6
7
|
|
7
8
|
export type ServerOAuthInfoPayload = {
|
8
9
|
debugMode?: boolean;
|
@@ -59,13 +60,16 @@ export class RestClientWithOAuth extends RestClient {
|
|
59
60
|
return true;
|
60
61
|
}
|
61
62
|
).catch(
|
62
|
-
() =>
|
63
|
-
(
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
63
|
+
(reason) => {
|
64
|
+
console.log('OAuth initialization failed:', reason);
|
65
|
+
return this.getServerInfo().then(
|
66
|
+
(si) => {
|
67
|
+
const documentlocation = `${si.oauthServerUrl}/login?app_name=${si.targetAudience}&redirect_url=${document.location}`;
|
68
|
+
console.log('Redirecting:', documentlocation);
|
69
|
+
return Promise.resolve(false);
|
70
|
+
}
|
71
|
+
)
|
72
|
+
}
|
69
73
|
);
|
70
74
|
}
|
71
75
|
|
@@ -82,15 +86,8 @@ export class RestClientWithOAuth extends RestClient {
|
|
82
86
|
return up.get('token');
|
83
87
|
}
|
84
88
|
|
85
|
-
getIdTokenFromLocalStorage(): IdTokenPayload | null {
|
86
|
-
|
87
|
-
if (!raw) return null;
|
88
|
-
const obj = JSON.parse(raw);
|
89
|
-
return {
|
90
|
-
idToken: obj.idToken,
|
91
|
-
issuedAt: DateUtil.parseDate(obj.issuedAt) || new Date(),
|
92
|
-
expires: DateUtil.parseDate(obj.expires)
|
93
|
-
}
|
89
|
+
getIdTokenFromLocalStorage(): IdTokenPayload | null | undefined {
|
90
|
+
return JsonUtil.parse(localStorage.getItem('id-token'));
|
94
91
|
}
|
95
92
|
|
96
93
|
saveIdTokenToLocalStorage(token: IdTokenPayload | null) {
|
package/src/util/JsonUtil.ts
CHANGED