rest-client-sdk 7.5.0 → 7.6.0

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.mjs CHANGED
@@ -1087,7 +1087,7 @@ var AbstractClient = /*#__PURE__*/function () {
1087
1087
  url: input
1088
1088
  }, params));
1089
1089
  }
1090
- return fetch(input, params).then(function (response) {
1090
+ return this._fetch(input, params).then(function (response) {
1091
1091
  if (_this6.sdk.logger) {
1092
1092
  _this6.sdk.logger.logResponse(response, logId);
1093
1093
  }
@@ -1101,6 +1101,14 @@ var AbstractClient = /*#__PURE__*/function () {
1101
1101
  throw httpError;
1102
1102
  });
1103
1103
  }
1104
+ }, {
1105
+ key: "_fetch",
1106
+ value: function _fetch(input, init) {
1107
+ var _this$sdk$config$fetc;
1108
+ // eslint-disable-next-line no-restricted-globals -- default for the injectable fetch
1109
+ var fetchFn = (_this$sdk$config$fetc = this.sdk.config.fetch) !== null && _this$sdk$config$fetc !== void 0 ? _this$sdk$config$fetc : fetch;
1110
+ return fetchFn(input, init);
1111
+ }
1104
1112
  }, {
1105
1113
  key: "_getEntityIdentifier",
1106
1114
  value: function _getEntityIdentifier(object) {
@@ -1864,6 +1872,7 @@ var RestClientSdk = /*#__PURE__*/function () {
1864
1872
  }]);
1865
1873
  }();
1866
1874
 
1875
+ // accepts any config type, but a `fetch` key must be a fetch function when there is one
1867
1876
  var AbstractTokenGenerator = /*#__PURE__*/function () {
1868
1877
  function AbstractTokenGenerator(tokenGeneratorConfig, logger) {
1869
1878
  _classCallCheck(this, AbstractTokenGenerator);
@@ -1878,9 +1887,20 @@ var AbstractTokenGenerator = /*#__PURE__*/function () {
1878
1887
  }
1879
1888
  }
1880
1889
  return _createClass(AbstractTokenGenerator, [{
1890
+ key: "_fetch",
1891
+ value: function _fetch(input, init) {
1892
+ var _config$fetch;
1893
+ // WithOptionalFetch guarantees this type, but TypeScript cannot read a key from a conditional constraint
1894
+ var config = this.tokenGeneratorConfig;
1895
+ // eslint-disable-next-line no-restricted-globals -- default for the injectable fetch
1896
+ var fetchFn = (_config$fetch = config === null || config === void 0 ? void 0 : config.fetch) !== null && _config$fetch !== void 0 ? _config$fetch : fetch;
1897
+ return fetchFn(input, init);
1898
+ }
1899
+
1900
+ /** @deprecated */
1901
+ }, {
1881
1902
  key: "_manageOauthError",
1882
- value: /** @deprecated */
1883
- function _manageOauthError(response) {
1903
+ value: function _manageOauthError(response) {
1884
1904
  return response.clone().json().then(function (body) {
1885
1905
  if (body.error === 'invalid_grant') {
1886
1906
  throw new InvalidGrantError(body.error, getHttpErrorFromResponse(response));
@@ -1948,7 +1968,7 @@ var AuthorizationCodeFlowTokenGenerator = /*#__PURE__*/function (_AbstractTokenG
1948
1968
  url: url
1949
1969
  }, params));
1950
1970
  }
1951
- return fetch(url, params);
1971
+ return this._fetch(url, params);
1952
1972
  }
1953
1973
 
1954
1974
  /**
@@ -1982,7 +2002,7 @@ var AuthorizationCodeFlowTokenGenerator = /*#__PURE__*/function (_AbstractTokenG
1982
2002
  url: url
1983
2003
  }, params));
1984
2004
  }
1985
- return fetch(url, params);
2005
+ return this._fetch(url, params);
1986
2006
  }
1987
2007
  }, {
1988
2008
  key: "checkTokenGeneratorConfig",
@@ -2095,7 +2115,7 @@ var ClientCredentialsGenerator = /*#__PURE__*/function (_AbstractTokenGenerat) {
2095
2115
  url: url
2096
2116
  }, params));
2097
2117
  }
2098
- return fetch(url, params);
2118
+ return this._fetch(url, params);
2099
2119
  }
2100
2120
  }, {
2101
2121
  key: "refreshToken",
@@ -2160,7 +2180,7 @@ var PasswordGenerator = /*#__PURE__*/function (_AbstractTokenGenerat) {
2160
2180
  url: url
2161
2181
  }, params));
2162
2182
  }
2163
- return fetch(url, params);
2183
+ return this._fetch(url, params);
2164
2184
  }
2165
2185
  }, {
2166
2186
  key: "refreshToken",
@@ -2191,7 +2211,7 @@ var PasswordGenerator = /*#__PURE__*/function (_AbstractTokenGenerat) {
2191
2211
  url: url
2192
2212
  }, params));
2193
2213
  }
2194
- return fetch(url, params);
2214
+ return this._fetch(url, params);
2195
2215
  }
2196
2216
  }, {
2197
2217
  key: "checkTokenGeneratorConfig",