@ethlete/query 0.1.0-next.11 → 0.1.0-next.12
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/esm2020/lib/auth/auth-provider.types.mjs +1 -1
- package/esm2020/lib/auth/bearer-auth-provider.mjs +9 -1
- package/fesm2015/ethlete-query.mjs +9 -1
- package/fesm2015/ethlete-query.mjs.map +1 -1
- package/fesm2020/ethlete-query.mjs +8 -0
- package/fesm2020/ethlete-query.mjs.map +1 -1
- package/lib/auth/auth-provider.types.d.ts +5 -0
- package/lib/auth/bearer-auth-provider.d.ts +1 -0
- package/package.json +1 -1
|
@@ -320,6 +320,7 @@ class BearerAuthProvider {
|
|
|
320
320
|
this._config = _config;
|
|
321
321
|
this._refreshToken = null;
|
|
322
322
|
this._refreshTimerSubscription = null;
|
|
323
|
+
this._failureCount = 0;
|
|
323
324
|
this.queryClient = null;
|
|
324
325
|
this.onRefreshInitiation$ = new Subject();
|
|
325
326
|
this.onRefreshSuccess$ = new Subject();
|
|
@@ -335,6 +336,7 @@ class BearerAuthProvider {
|
|
|
335
336
|
this._refreshTimerSubscription = null;
|
|
336
337
|
}
|
|
337
338
|
_setupRefresh(config) {
|
|
339
|
+
this.cleanUp();
|
|
338
340
|
const bearer = decryptBearer(this._token);
|
|
339
341
|
if (!bearer) {
|
|
340
342
|
return;
|
|
@@ -385,6 +387,8 @@ class BearerAuthProvider {
|
|
|
385
387
|
this._token = tokens.token;
|
|
386
388
|
this._refreshToken = tokens.refreshToken;
|
|
387
389
|
this.onRefreshSuccess$.next(tokens);
|
|
390
|
+
this._setupRefresh(config);
|
|
391
|
+
this._failureCount = 0;
|
|
388
392
|
}
|
|
389
393
|
catch (error) {
|
|
390
394
|
if (error instanceof Error) {
|
|
@@ -393,6 +397,10 @@ class BearerAuthProvider {
|
|
|
393
397
|
else {
|
|
394
398
|
this.onRefreshFailure$.next(error);
|
|
395
399
|
}
|
|
400
|
+
this._failureCount++;
|
|
401
|
+
if (this._failureCount <= (config.maxRefreshAttempts ?? 3)) {
|
|
402
|
+
this._setupRefresh(config);
|
|
403
|
+
}
|
|
396
404
|
}
|
|
397
405
|
}
|
|
398
406
|
}
|