zavadil-ts-common 1.1.58 → 1.1.60

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.
@@ -21,6 +21,9 @@ export class LazyAsync<T> {
21
21
  this.cache = v;
22
22
  this.promise = undefined;
23
23
  return v;
24
+ }).catch((err) => {
25
+ this.promise = undefined;
26
+ throw err;
24
27
  });
25
28
  }
26
29
 
@@ -58,13 +58,13 @@ export class OAuthTokenManager {
58
58
  }
59
59
 
60
60
  reset() {
61
+ console.log('resetting');
61
62
  this.setIdToken(undefined);
62
63
  this.accessTokens.clear();
63
64
  }
64
65
 
65
66
  getIdToken(): Promise<string> {
66
67
  if (this.idToken === undefined || !this.hasValidIdToken()) {
67
- console.log('no id token?', this.idToken)
68
68
  return Promise.reject("No valid ID token!");
69
69
  }
70
70
  if (this.isTokenReadyForRefresh(this.idToken.issuedAt, this.idToken.expires)) {
@@ -81,6 +81,7 @@ export class OAuthTokenManager {
81
81
  }
82
82
 
83
83
  setIdToken(token?: IdTokenPayload) {
84
+ console.log('setting id token', token);
84
85
  if (!this.isValidIdToken(token)) {
85
86
  throw new Error("Received ID token is not valid!");
86
87
  }
@@ -89,6 +90,7 @@ export class OAuthTokenManager {
89
90
  }
90
91
 
91
92
  verifyIdToken(token: string): Promise<boolean> {
93
+ console.log('verifying id token', token);
92
94
  return this.oAuthServer.verifyIdToken(token)
93
95
  .then((t) => this.setIdToken(t))
94
96
  .then(() => true)
@@ -48,6 +48,7 @@ export class RestClientWithOAuth extends RestClient {
48
48
  */
49
49
  initialize(): Promise<boolean> {
50
50
  return this.initializeIdToken()
51
+ .then((result) => console.log('initialized', result ? 'success' : 'problem'))
51
52
  .then(() => this.checkAccessToken())
52
53
  .catch(
53
54
  () => this.getServerInfo().then(
@@ -131,6 +132,7 @@ export class RestClientWithOAuth extends RestClient {
131
132
  }
132
133
 
133
134
  setIdTokenRaw(token: string): Promise<boolean> {
135
+ console.log('setting raw token', token);
134
136
  return this.getTokenManager()
135
137
  .then(m => m.verifyIdToken(token))
136
138
  }
@@ -153,6 +155,7 @@ export class RestClientWithOAuth extends RestClient {
153
155
  * This is basically only used when initializing and trying to determine whether we need to redirect user to login page
154
156
  */
155
157
  checkAccessToken(privilege?: string): Promise<boolean> {
158
+ console.log('checking access token', privilege);
156
159
  return this.getTokenManager()
157
160
  .then(tm => tm.getAccessToken(StringUtil.getNonEmpty(privilege, this.defaultPrivilege)))
158
161
  .then((accessToken) => true);