@aloma.io/integration-sdk 3.3.69 → 3.3.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/build/internal/index.mjs +5 -5
- package/package.json +1 -1
- package/src/internal/index.mjs +28 -23
package/build/internal/index.mjs
CHANGED
@@ -140,7 +140,7 @@ class OAuthFetcher extends Fetcher {
|
|
140
140
|
}
|
141
141
|
catch (e) {
|
142
142
|
oauth.invalidate(e);
|
143
|
-
throw
|
143
|
+
throw e;
|
144
144
|
}
|
145
145
|
}
|
146
146
|
async onError(e, url, options, retries, args, rateLimit) {
|
@@ -208,10 +208,10 @@ class OAuth {
|
|
208
208
|
async invalidate(err) {
|
209
209
|
if (true)
|
210
210
|
return;
|
211
|
-
if (this._data.access_token ===
|
211
|
+
if (this._data.access_token === "invalid")
|
212
212
|
return;
|
213
|
-
console.log(
|
214
|
-
await this.update(
|
213
|
+
console.log("could not obtain access token, marking connector as disconnected", err);
|
214
|
+
await this.update("invalid", null);
|
215
215
|
}
|
216
216
|
getClient(arg = {}) {
|
217
217
|
const client = new OAuthFetcher({ ...arg, oauth: this });
|
@@ -430,7 +430,7 @@ ${text}
|
|
430
430
|
const packet = transport.newPacket({});
|
431
431
|
packet.method("connector.config-update");
|
432
432
|
packet.args({
|
433
|
-
value
|
433
|
+
value,
|
434
434
|
});
|
435
435
|
transport.send(packet);
|
436
436
|
};
|
package/package.json
CHANGED
package/src/internal/index.mjs
CHANGED
@@ -63,13 +63,16 @@ class Fetcher {
|
|
63
63
|
var local = this;
|
64
64
|
|
65
65
|
return new Promise((resolve, reject) => {
|
66
|
-
setTimeout(
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
66
|
+
setTimeout(
|
67
|
+
async () => {
|
68
|
+
try {
|
69
|
+
resolve(await local.fetch(url, options, retries, args));
|
70
|
+
} catch (e) {
|
71
|
+
reject(e);
|
72
|
+
}
|
73
|
+
},
|
74
|
+
rateLimit ? 10000 : 500,
|
75
|
+
);
|
73
76
|
});
|
74
77
|
}
|
75
78
|
|
@@ -159,9 +162,8 @@ class OAuthFetcher extends Fetcher {
|
|
159
162
|
if (!force && oauth.accessToken()) return oauth.accessToken();
|
160
163
|
|
161
164
|
const refreshToken = oauth.refreshToken();
|
162
|
-
|
163
|
-
try
|
164
|
-
{
|
165
|
+
|
166
|
+
try {
|
165
167
|
if (!refreshToken) {
|
166
168
|
throw new Error("have no access_token and no refresh_token");
|
167
169
|
}
|
@@ -175,10 +177,10 @@ class OAuthFetcher extends Fetcher {
|
|
175
177
|
} else {
|
176
178
|
throw new Error("could not obtain access token via refresh token");
|
177
179
|
}
|
178
|
-
} catch(e) {
|
180
|
+
} catch (e) {
|
179
181
|
oauth.invalidate(e);
|
180
|
-
|
181
|
-
throw
|
182
|
+
|
183
|
+
throw e;
|
182
184
|
}
|
183
185
|
}
|
184
186
|
|
@@ -206,7 +208,7 @@ class OAuthFetcher extends Fetcher {
|
|
206
208
|
async periodicRefresh() {
|
207
209
|
const local = this,
|
208
210
|
oauth = local.oauth;
|
209
|
-
|
211
|
+
|
210
212
|
if (!oauth.refreshToken()) return;
|
211
213
|
|
212
214
|
await local.getToken(true);
|
@@ -265,14 +267,17 @@ class OAuth {
|
|
265
267
|
await client.periodicRefresh();
|
266
268
|
}
|
267
269
|
}
|
268
|
-
|
270
|
+
|
269
271
|
async invalidate(err) {
|
270
272
|
if (true) return;
|
271
|
-
if (this._data.access_token ===
|
272
|
-
|
273
|
-
console.log(
|
274
|
-
|
275
|
-
|
273
|
+
if (this._data.access_token === "invalid") return;
|
274
|
+
|
275
|
+
console.log(
|
276
|
+
"could not obtain access token, marking connector as disconnected",
|
277
|
+
err,
|
278
|
+
);
|
279
|
+
|
280
|
+
await this.update("invalid", null);
|
276
281
|
}
|
277
282
|
|
278
283
|
getClient(arg = {}) {
|
@@ -529,13 +534,13 @@ ${text}
|
|
529
534
|
|
530
535
|
const saveOAuthResult = async (what) => {
|
531
536
|
const jwe = await config.validateKeys("RSA-OAEP-256");
|
532
|
-
const value = await jwe.encrypt(what, "none", config.id())
|
533
|
-
|
537
|
+
const value = await jwe.encrypt(what, "none", config.id());
|
538
|
+
|
534
539
|
const packet = transport.newPacket({});
|
535
540
|
|
536
541
|
packet.method("connector.config-update");
|
537
542
|
packet.args({
|
538
|
-
value
|
543
|
+
value,
|
539
544
|
});
|
540
545
|
|
541
546
|
transport.send(packet);
|