rest-client-sdk
Advanced tools
Comparing version 2.1.0 to 2.2.0
@@ -5,2 +5,9 @@ # Changelog | ||
## 2.2.0 | ||
### Changed | ||
* Add possibility to pass null as tokenStorage argument of the sdk | ||
* switch method names \_doFetch and \_fetchWithToken in AbstractClient for coherence | ||
## 2.1.0 | ||
@@ -7,0 +14,0 @@ |
@@ -1007,3 +1007,3 @@ import diff from 'deep-diff'; | ||
return this._doFetch(url.toString(), init); | ||
return this._fetchWithToken(url.toString(), init); | ||
} | ||
@@ -1043,4 +1043,4 @@ }, { | ||
}, { | ||
key: '_doFetch', | ||
value: function _doFetch(input, init) { | ||
key: '_fetchWithToken', | ||
value: function _fetchWithToken(input, init) { | ||
var _this3 = this; | ||
@@ -1052,5 +1052,9 @@ | ||
return this._tokenStorage.getAccessToken().then(function (token) { | ||
return _this3._fetchWithToken(token, input, init); | ||
}); | ||
if (this._tokenStorage) { | ||
return this._tokenStorage.getAccessToken().then(function (token) { | ||
return _this3._doFetch(token, input, init); | ||
}); | ||
} | ||
return this._doFetch(null, input, init); | ||
} | ||
@@ -1073,3 +1077,3 @@ }, { | ||
return _this4._doFetch(input, params); | ||
return _this4._fetchWithToken(input, params); | ||
}).catch(function () { | ||
@@ -1093,4 +1097,4 @@ throw new AccessDeniedError('Unable to renew access_token', response); | ||
}, { | ||
key: '_fetchWithToken', | ||
value: function _fetchWithToken(accessToken, input, init) { | ||
key: '_doFetch', | ||
value: function _doFetch(accessToken, input, init) { | ||
var _this5 = this; | ||
@@ -1101,6 +1105,9 @@ | ||
var baseHeaders = { | ||
Authorization: this.sdk.config.authorizationType + ' ' + accessToken, | ||
'Content-Type': 'application/json' | ||
}; | ||
if (accessToken) { | ||
baseHeaders.Authorization = this.sdk.config.authorizationType + ' ' + accessToken; | ||
} | ||
var currentUri = (typeof window === 'undefined' ? 'undefined' : _typeof(window)) === 'object' && window.location && window.location.href; | ||
@@ -1107,0 +1114,0 @@ if (currentUri) { |
@@ -1013,3 +1013,3 @@ (function (global, factory) { | ||
return this._doFetch(url.toString(), init); | ||
return this._fetchWithToken(url.toString(), init); | ||
} | ||
@@ -1049,4 +1049,4 @@ }, { | ||
}, { | ||
key: '_doFetch', | ||
value: function _doFetch(input, init) { | ||
key: '_fetchWithToken', | ||
value: function _fetchWithToken(input, init) { | ||
var _this3 = this; | ||
@@ -1058,5 +1058,9 @@ | ||
return this._tokenStorage.getAccessToken().then(function (token) { | ||
return _this3._fetchWithToken(token, input, init); | ||
}); | ||
if (this._tokenStorage) { | ||
return this._tokenStorage.getAccessToken().then(function (token) { | ||
return _this3._doFetch(token, input, init); | ||
}); | ||
} | ||
return this._doFetch(null, input, init); | ||
} | ||
@@ -1079,3 +1083,3 @@ }, { | ||
return _this4._doFetch(input, params); | ||
return _this4._fetchWithToken(input, params); | ||
}).catch(function () { | ||
@@ -1099,4 +1103,4 @@ throw new AccessDeniedError('Unable to renew access_token', response); | ||
}, { | ||
key: '_fetchWithToken', | ||
value: function _fetchWithToken(accessToken, input, init) { | ||
key: '_doFetch', | ||
value: function _doFetch(accessToken, input, init) { | ||
var _this5 = this; | ||
@@ -1107,6 +1111,9 @@ | ||
var baseHeaders = { | ||
Authorization: this.sdk.config.authorizationType + ' ' + accessToken, | ||
'Content-Type': 'application/json' | ||
}; | ||
if (accessToken) { | ||
baseHeaders.Authorization = this.sdk.config.authorizationType + ' ' + accessToken; | ||
} | ||
var currentUri = (typeof window === 'undefined' ? 'undefined' : _typeof(window)) === 'object' && window.location && window.location.href; | ||
@@ -1113,0 +1120,0 @@ if (currentUri) { |
{ | ||
"name": "rest-client-sdk", | ||
"version": "v2.1.0", | ||
"version": "v2.2.0", | ||
"description": "Rest Client SDK for API", | ||
@@ -23,3 +23,3 @@ "main": "dist/index.js", | ||
"babel-core": "^6.24.1", | ||
"babel-jest": "^22.1.0", | ||
"babel-jest": "^22.2.0", | ||
"babel-plugin-external-helpers": "^6.22.0", | ||
@@ -26,0 +26,0 @@ "babel-preset-env": "^1.6.1", |
@@ -190,3 +190,3 @@ import URI from 'urijs'; | ||
return this._doFetch(url.toString(), init); | ||
return this._fetchWithToken(url.toString(), init); | ||
} | ||
@@ -224,3 +224,3 @@ | ||
_doFetch(input, init) { | ||
_fetchWithToken(input, init) { | ||
if (!input) { | ||
@@ -230,5 +230,9 @@ throw new Error('input is empty'); | ||
return this._tokenStorage | ||
.getAccessToken() | ||
.then(token => this._fetchWithToken(token, input, init)); | ||
if (this._tokenStorage) { | ||
return this._tokenStorage | ||
.getAccessToken() | ||
.then(token => this._doFetch(token, input, init)); | ||
} | ||
return this._doFetch(null, input, init); | ||
} | ||
@@ -252,3 +256,3 @@ | ||
return this._doFetch(input, params); | ||
return this._fetchWithToken(input, params); | ||
}) | ||
@@ -283,10 +287,15 @@ .catch(() => { | ||
_fetchWithToken(accessToken, input, init) { | ||
_doFetch(accessToken, input, init) { | ||
let params = init; | ||
const baseHeaders = { | ||
Authorization: `${this.sdk.config.authorizationType} ${accessToken}`, | ||
'Content-Type': 'application/json', | ||
}; | ||
if (accessToken) { | ||
baseHeaders.Authorization = `${ | ||
this.sdk.config.authorizationType | ||
} ${accessToken}`; | ||
} | ||
const currentUri = | ||
@@ -293,0 +302,0 @@ typeof window === 'object' && window.location && window.location.href; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
327665
4201