rest-client-sdk 7.5.0 → 7.6.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/README.md +21 -0
- package/dist/index.cjs +33 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +33 -9
- package/dist/index.mjs.map +1 -1
- package/dist/types/RestClientSdkInterface.d.ts +1 -0
- package/dist/types/TokenGenerator/AbstractTokenGenerator.d.ts +5 -1
- package/dist/types/TokenGenerator/AuthorizationCodeFlowTokenGenerator.d.ts +1 -0
- package/dist/types/TokenGenerator/ClientCredentialsGenerator.d.ts +1 -0
- package/dist/types/TokenGenerator/PasswordGenerator.d.ts +1 -0
- package/dist/types/client/AbstractClient.d.ts +1 -0
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1060,7 +1060,11 @@ var AbstractClient = /*#__PURE__*/function () {
|
|
|
1060
1060
|
var _this6 = this;
|
|
1061
1061
|
var params = requestParams;
|
|
1062
1062
|
var baseHeaders = {};
|
|
1063
|
-
|
|
1063
|
+
|
|
1064
|
+
// a FormData body must let fetch set the Content-Type itself,
|
|
1065
|
+
// with the multipart/form-data boundary
|
|
1066
|
+
var isFormDataBody = FormData !== undefined && params.body instanceof FormData;
|
|
1067
|
+
if ((params.method !== 'GET' || params.method !== 'GET' && params.method !== 'DELETE') && !isFormDataBody) {
|
|
1064
1068
|
baseHeaders = {
|
|
1065
1069
|
'Content-Type': 'application/json'
|
|
1066
1070
|
};
|
|
@@ -1087,7 +1091,7 @@ var AbstractClient = /*#__PURE__*/function () {
|
|
|
1087
1091
|
url: input
|
|
1088
1092
|
}, params));
|
|
1089
1093
|
}
|
|
1090
|
-
return
|
|
1094
|
+
return this._fetch(input, params).then(function (response) {
|
|
1091
1095
|
if (_this6.sdk.logger) {
|
|
1092
1096
|
_this6.sdk.logger.logResponse(response, logId);
|
|
1093
1097
|
}
|
|
@@ -1101,6 +1105,14 @@ var AbstractClient = /*#__PURE__*/function () {
|
|
|
1101
1105
|
throw httpError;
|
|
1102
1106
|
});
|
|
1103
1107
|
}
|
|
1108
|
+
}, {
|
|
1109
|
+
key: "_fetch",
|
|
1110
|
+
value: function _fetch(input, init) {
|
|
1111
|
+
var _this$sdk$config$fetc;
|
|
1112
|
+
// eslint-disable-next-line no-restricted-globals -- default for the injectable fetch
|
|
1113
|
+
var fetchFn = (_this$sdk$config$fetc = this.sdk.config.fetch) !== null && _this$sdk$config$fetc !== void 0 ? _this$sdk$config$fetc : fetch;
|
|
1114
|
+
return fetchFn(input, init);
|
|
1115
|
+
}
|
|
1104
1116
|
}, {
|
|
1105
1117
|
key: "_getEntityIdentifier",
|
|
1106
1118
|
value: function _getEntityIdentifier(object) {
|
|
@@ -1864,6 +1876,7 @@ var RestClientSdk = /*#__PURE__*/function () {
|
|
|
1864
1876
|
}]);
|
|
1865
1877
|
}();
|
|
1866
1878
|
|
|
1879
|
+
// accepts any config type, but a `fetch` key must be a fetch function when there is one
|
|
1867
1880
|
var AbstractTokenGenerator = /*#__PURE__*/function () {
|
|
1868
1881
|
function AbstractTokenGenerator(tokenGeneratorConfig, logger) {
|
|
1869
1882
|
_classCallCheck(this, AbstractTokenGenerator);
|
|
@@ -1878,9 +1891,20 @@ var AbstractTokenGenerator = /*#__PURE__*/function () {
|
|
|
1878
1891
|
}
|
|
1879
1892
|
}
|
|
1880
1893
|
return _createClass(AbstractTokenGenerator, [{
|
|
1894
|
+
key: "_fetch",
|
|
1895
|
+
value: function _fetch(input, init) {
|
|
1896
|
+
var _config$fetch;
|
|
1897
|
+
// WithOptionalFetch guarantees this type, but TypeScript cannot read a key from a conditional constraint
|
|
1898
|
+
var config = this.tokenGeneratorConfig;
|
|
1899
|
+
// eslint-disable-next-line no-restricted-globals -- default for the injectable fetch
|
|
1900
|
+
var fetchFn = (_config$fetch = config === null || config === void 0 ? void 0 : config.fetch) !== null && _config$fetch !== void 0 ? _config$fetch : fetch;
|
|
1901
|
+
return fetchFn(input, init);
|
|
1902
|
+
}
|
|
1903
|
+
|
|
1904
|
+
/** @deprecated */
|
|
1905
|
+
}, {
|
|
1881
1906
|
key: "_manageOauthError",
|
|
1882
|
-
value:
|
|
1883
|
-
function _manageOauthError(response) {
|
|
1907
|
+
value: function _manageOauthError(response) {
|
|
1884
1908
|
return response.clone().json().then(function (body) {
|
|
1885
1909
|
if (body.error === 'invalid_grant') {
|
|
1886
1910
|
throw new InvalidGrantError(body.error, getHttpErrorFromResponse(response));
|
|
@@ -1948,7 +1972,7 @@ var AuthorizationCodeFlowTokenGenerator = /*#__PURE__*/function (_AbstractTokenG
|
|
|
1948
1972
|
url: url
|
|
1949
1973
|
}, params));
|
|
1950
1974
|
}
|
|
1951
|
-
return
|
|
1975
|
+
return this._fetch(url, params);
|
|
1952
1976
|
}
|
|
1953
1977
|
|
|
1954
1978
|
/**
|
|
@@ -1982,7 +2006,7 @@ var AuthorizationCodeFlowTokenGenerator = /*#__PURE__*/function (_AbstractTokenG
|
|
|
1982
2006
|
url: url
|
|
1983
2007
|
}, params));
|
|
1984
2008
|
}
|
|
1985
|
-
return
|
|
2009
|
+
return this._fetch(url, params);
|
|
1986
2010
|
}
|
|
1987
2011
|
}, {
|
|
1988
2012
|
key: "checkTokenGeneratorConfig",
|
|
@@ -2095,7 +2119,7 @@ var ClientCredentialsGenerator = /*#__PURE__*/function (_AbstractTokenGenerat) {
|
|
|
2095
2119
|
url: url
|
|
2096
2120
|
}, params));
|
|
2097
2121
|
}
|
|
2098
|
-
return
|
|
2122
|
+
return this._fetch(url, params);
|
|
2099
2123
|
}
|
|
2100
2124
|
}, {
|
|
2101
2125
|
key: "refreshToken",
|
|
@@ -2160,7 +2184,7 @@ var PasswordGenerator = /*#__PURE__*/function (_AbstractTokenGenerat) {
|
|
|
2160
2184
|
url: url
|
|
2161
2185
|
}, params));
|
|
2162
2186
|
}
|
|
2163
|
-
return
|
|
2187
|
+
return this._fetch(url, params);
|
|
2164
2188
|
}
|
|
2165
2189
|
}, {
|
|
2166
2190
|
key: "refreshToken",
|
|
@@ -2191,7 +2215,7 @@ var PasswordGenerator = /*#__PURE__*/function (_AbstractTokenGenerat) {
|
|
|
2191
2215
|
url: url
|
|
2192
2216
|
}, params));
|
|
2193
2217
|
}
|
|
2194
|
-
return
|
|
2218
|
+
return this._fetch(url, params);
|
|
2195
2219
|
}
|
|
2196
2220
|
}, {
|
|
2197
2221
|
key: "checkTokenGeneratorConfig",
|