rest-client-sdk 7.1.0 → 7.1.1
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/dist/index.es.js +18 -7
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +18 -7
- package/dist/index.js.map +1 -1
- package/dist/types/client/AbstractClient.d.ts +1 -0
- package/package.json +1 -1
- package/src/client/AbstractClient.ts +16 -8
package/package.json
CHANGED
|
@@ -386,7 +386,11 @@ class AbstractClient<D extends MetadataDefinition> {
|
|
|
386
386
|
.refreshToken()
|
|
387
387
|
.then(
|
|
388
388
|
(refreshedTokenObject) => refreshedTokenObject.access_token
|
|
389
|
-
)
|
|
389
|
+
).catch((e) => {
|
|
390
|
+
this._handleRefreshTokenFailure(e);
|
|
391
|
+
|
|
392
|
+
throw e;
|
|
393
|
+
});
|
|
390
394
|
}
|
|
391
395
|
|
|
392
396
|
return this.#tokenStorage.getAccessToken();
|
|
@@ -415,13 +419,7 @@ class AbstractClient<D extends MetadataDefinition> {
|
|
|
415
419
|
return this._fetchWithToken(input, updatedRequestParams);
|
|
416
420
|
})
|
|
417
421
|
.catch((e) => {
|
|
418
|
-
|
|
419
|
-
this.#tokenStorage.logout().then(() => {
|
|
420
|
-
if (this.sdk.config.onRefreshTokenFailure) {
|
|
421
|
-
this.sdk.config.onRefreshTokenFailure(e);
|
|
422
|
-
}
|
|
423
|
-
});
|
|
424
|
-
}
|
|
422
|
+
this._handleRefreshTokenFailure(e);
|
|
425
423
|
|
|
426
424
|
throw e;
|
|
427
425
|
});
|
|
@@ -532,6 +530,16 @@ class AbstractClient<D extends MetadataDefinition> {
|
|
|
532
530
|
// @ts-ignore
|
|
533
531
|
return object[idKey];
|
|
534
532
|
}
|
|
533
|
+
|
|
534
|
+
private _handleRefreshTokenFailure(error: Error): void {
|
|
535
|
+
if (error instanceof OauthError) {
|
|
536
|
+
this.#tokenStorage.logout().then(() => {
|
|
537
|
+
if (this.sdk.config.onRefreshTokenFailure) {
|
|
538
|
+
this.sdk.config.onRefreshTokenFailure(error);
|
|
539
|
+
}
|
|
540
|
+
});
|
|
541
|
+
}
|
|
542
|
+
}
|
|
535
543
|
}
|
|
536
544
|
|
|
537
545
|
export default AbstractClient;
|