@aloma.io/integration-sdk 3.7.37 → 3.7.39

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.
@@ -2,6 +2,7 @@ import Fetcher from "./fetcher.mjs";
2
2
  declare class OAuthFetcher extends Fetcher {
3
3
  oauth: any;
4
4
  _getToken: any;
5
+ used: boolean;
5
6
  constructor({ oauth, retry, getToken, baseUrl, onResponse, customize }: {
6
7
  oauth: any;
7
8
  retry?: number | undefined;
@@ -2,17 +2,19 @@ import Fetcher from "./fetcher.mjs";
2
2
  class OAuthFetcher extends Fetcher {
3
3
  oauth;
4
4
  _getToken;
5
+ used = false;
5
6
  constructor({ oauth, retry = 5, getToken, baseUrl, onResponse, customize }) {
6
7
  super({ retry, baseUrl, onResponse, customize });
7
8
  this.oauth = oauth;
8
9
  this._getToken = getToken;
9
10
  }
10
11
  async __healthCheck() {
11
- if (!this.oauth.accessToken())
12
+ if (this.used && !this.oauth.accessToken())
12
13
  throw new Error('no access token');
13
14
  }
14
15
  async getToken(force) {
15
16
  var local = this, oauth = local.oauth;
17
+ this.used = true;
16
18
  if (local._getToken)
17
19
  return local._getToken(force);
18
20
  if (!force && oauth.accessToken())
@@ -106,9 +108,7 @@ export class OAuth {
106
108
  }
107
109
  }
108
110
  async invalidate(err) {
109
- if (true)
110
- return;
111
- //if (this._data.access_token === "invalid") return;
111
+ this._data.access_token = null;
112
112
  }
113
113
  getClient(arg = {}) {
114
114
  const client = new OAuthFetcher({ ...arg, oauth: this });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aloma.io/integration-sdk",
3
- "version": "3.7.37",
3
+ "version": "3.7.39",
4
4
  "description": "",
5
5
  "author": "aloma.io",
6
6
  "license": "Apache-2.0",
@@ -3,6 +3,7 @@ import Fetcher from "./fetcher.mjs";
3
3
  class OAuthFetcher extends Fetcher {
4
4
  oauth: any;
5
5
  _getToken: any;
6
+ used: boolean = false;
6
7
  constructor({ oauth, retry = 5, getToken, baseUrl, onResponse, customize }) {
7
8
  super({ retry, baseUrl, onResponse, customize });
8
9
 
@@ -11,13 +12,15 @@ class OAuthFetcher extends Fetcher {
11
12
  }
12
13
 
13
14
  async __healthCheck() {
14
- if (!this.oauth.accessToken()) throw new Error('no access token');
15
+ if (this.used && !this.oauth.accessToken()) throw new Error('no access token');
15
16
  }
16
17
 
17
18
  async getToken(force) {
18
19
  var local = this,
19
20
  oauth = local.oauth;
20
-
21
+
22
+ this.used = true;
23
+
21
24
  if (local._getToken) return local._getToken(force);
22
25
 
23
26
  if (!force && oauth.accessToken()) return oauth.accessToken();
@@ -139,8 +142,7 @@ export class OAuth {
139
142
  }
140
143
 
141
144
  async invalidate(err) {
142
- if (true) return;
143
- //if (this._data.access_token === "invalid") return;
145
+ this._data.access_token = null;
144
146
  }
145
147
 
146
148
  getClient(arg: any = {}) {