zavadil-ts-common 1.1.63 → 1.1.65

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zavadil-ts-common",
3
- "version": "1.1.63",
3
+ "version": "1.1.65",
4
4
  "description": "Common types and components for Typescript UI apps.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",
@@ -70,6 +70,7 @@ export class OAuthTokenManager {
70
70
  getIdToken(): Promise<string> {
71
71
  console.log('getting id token', this.idToken);
72
72
  if (this.idToken === undefined || !this.hasValidIdToken()) {
73
+ console.log('rejecting id token', this.idToken, this.hasValidIdToken());
73
74
  return Promise.reject("No valid ID token!");
74
75
  }
75
76
  if (this.isTokenReadyForRefresh(this.idToken.issuedAt, this.idToken.expires)) {
@@ -80,7 +81,7 @@ export class OAuthTokenManager {
80
81
  this.setIdToken(t);
81
82
  return t.idToken;
82
83
  }
83
- )
84
+ );
84
85
  }
85
86
  return Promise.resolve(this.idToken.idToken);
86
87
  }
@@ -114,6 +115,7 @@ export class OAuthTokenManager {
114
115
  }
115
116
 
116
117
  private getAccessTokenInternal(privilege: string): Promise<AccessTokenPayload> {
118
+ console.log('loading access token', privilege);
117
119
  return this.getIdToken()
118
120
  .then(
119
121
  (idToken: string) => this.oAuthServer
@@ -158,7 +158,13 @@ export class RestClientWithOAuth extends RestClient {
158
158
  console.log('checking access token', privilege);
159
159
  return this.getTokenManager()
160
160
  .then(tm => tm.getAccessToken(StringUtil.getNonEmpty(privilege, this.defaultPrivilege)))
161
- .then((accessToken) => true);
161
+ .then(
162
+ (accessToken) => true,
163
+ (r) => {
164
+ console.error('check failed', r);
165
+ return false;
166
+ }
167
+ );
162
168
  }
163
169
 
164
170
  }