rest-client-sdk 7.0.3 → 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.js CHANGED
@@ -1305,6 +1305,10 @@
1305
1305
  if (accessTokenExpiresIn !== null && accessTokenExpiresIn <= EXPIRE_LIMIT_SECONDS) {
1306
1306
  return _classPrivateFieldGet(_this3, _tokenStorage).refreshToken().then(function (refreshedTokenObject) {
1307
1307
  return refreshedTokenObject.access_token;
1308
+ })["catch"](function (e) {
1309
+ _this3._handleRefreshTokenFailure(e);
1310
+
1311
+ throw e;
1308
1312
  });
1309
1313
  }
1310
1314
 
@@ -1332,6 +1336,10 @@
1332
1336
  });
1333
1337
 
1334
1338
  return _this4._fetchWithToken(input, updatedRequestParams);
1339
+ })["catch"](function (e) {
1340
+ _this4._handleRefreshTokenFailure(e);
1341
+
1342
+ throw e;
1335
1343
  });
1336
1344
  }
1337
1345
  }, {
@@ -1437,6 +1445,19 @@
1437
1445
 
1438
1446
  return object[idKey];
1439
1447
  }
1448
+ }, {
1449
+ key: "_handleRefreshTokenFailure",
1450
+ value: function _handleRefreshTokenFailure(error) {
1451
+ var _this7 = this;
1452
+
1453
+ if (error instanceof OauthError) {
1454
+ _classPrivateFieldGet(this, _tokenStorage).logout().then(function () {
1455
+ if (_this7.sdk.config.onRefreshTokenFailure) {
1456
+ _this7.sdk.config.onRefreshTokenFailure(error);
1457
+ }
1458
+ });
1459
+ }
1460
+ }
1440
1461
  }]);
1441
1462
 
1442
1463
  return AbstractClient;
@@ -2951,7 +2972,7 @@
2951
2972
  return response.json().then(function (body) {
2952
2973
  if (isOauthError(body)) {
2953
2974
  // throw error if response body is an oauth error
2954
- manageOauthError(body, response);
2975
+ manageOauthError(body, originalResponse);
2955
2976
  } else if (response.status >= 400) {
2956
2977
  // throw an error if response status code is an "error" status code
2957
2978
  throw getHttpErrorFromResponse(originalResponse);