rest-client-sdk
Advanced tools
Comparing version 3.1.0 to 3.1.1
# Changelog | ||
## 3.1.1 | ||
### Changed | ||
* Read json response in \_manageUnauthorized when www-authenticate header is not available | ||
## 3.1.0 | ||
@@ -4,0 +10,0 @@ |
@@ -1093,2 +1093,4 @@ import diff from 'deep-diff'; | ||
value: function _manageUnauthorized(response, input, init) { | ||
var _this5 = this; | ||
// https://tools.ietf.org/html/rfc2617#section-1.2 | ||
@@ -1101,4 +1103,14 @@ var authorizationHeader = response.headers.get('www-authenticate'); | ||
} | ||
throw new UnauthorizedError('Unable to access ressource: 401 found !', response); | ||
} else { | ||
// if www-authenticate header is missing, try and read json response | ||
return response.json().then(function (body) { | ||
if (_this5._tokenStorage && body.error === 'invalid_grant') { | ||
return _this5._refreshTokenAndRefetch(response, input, init); | ||
} | ||
throw new UnauthorizedError('Unable to access ressource: 401 found !', response); | ||
}).catch(function () { | ||
throw new UnauthorizedError('Unable to access ressource: 401 found !', response); | ||
}); | ||
} | ||
throw new UnauthorizedError('Unable to access ressource: 401 found !', response); | ||
} | ||
@@ -1108,3 +1120,3 @@ }, { | ||
value: function _doFetch(accessToken, input, init) { | ||
var _this5 = this; | ||
var _this6 = this; | ||
@@ -1145,3 +1157,3 @@ var params = init; | ||
if (response.status === 401) { | ||
return _this5._manageUnauthorized(response, input, params); | ||
return _this6._manageUnauthorized(response, input, params); | ||
} | ||
@@ -1148,0 +1160,0 @@ |
@@ -1099,2 +1099,4 @@ (function (global, factory) { | ||
value: function _manageUnauthorized(response, input, init) { | ||
var _this5 = this; | ||
// https://tools.ietf.org/html/rfc2617#section-1.2 | ||
@@ -1107,4 +1109,14 @@ var authorizationHeader = response.headers.get('www-authenticate'); | ||
} | ||
throw new UnauthorizedError('Unable to access ressource: 401 found !', response); | ||
} else { | ||
// if www-authenticate header is missing, try and read json response | ||
return response.json().then(function (body) { | ||
if (_this5._tokenStorage && body.error === 'invalid_grant') { | ||
return _this5._refreshTokenAndRefetch(response, input, init); | ||
} | ||
throw new UnauthorizedError('Unable to access ressource: 401 found !', response); | ||
}).catch(function () { | ||
throw new UnauthorizedError('Unable to access ressource: 401 found !', response); | ||
}); | ||
} | ||
throw new UnauthorizedError('Unable to access ressource: 401 found !', response); | ||
} | ||
@@ -1114,3 +1126,3 @@ }, { | ||
value: function _doFetch(accessToken, input, init) { | ||
var _this5 = this; | ||
var _this6 = this; | ||
@@ -1151,3 +1163,3 @@ var params = init; | ||
if (response.status === 401) { | ||
return _this5._manageUnauthorized(response, input, params); | ||
return _this6._manageUnauthorized(response, input, params); | ||
} | ||
@@ -1154,0 +1166,0 @@ |
{ | ||
"name": "rest-client-sdk", | ||
"version": "v3.1.0", | ||
"version": "v3.1.1", | ||
"description": "Rest Client SDK for API", | ||
@@ -38,3 +38,3 @@ "main": "dist/index.js", | ||
"immutable": "^4.0.0-rc.9", | ||
"jest": "^23.1.0", | ||
"jest": "^23.1.1", | ||
"lint-staged": "^7.0.3", | ||
@@ -47,3 +47,3 @@ "pluralize": "^7.0.0", | ||
"rollup-plugin-commonjs": "^9.1.0", | ||
"rollup-plugin-node-resolve": "^3.1.0" | ||
"rollup-plugin-node-resolve": "^3.1.1" | ||
}, | ||
@@ -50,0 +50,0 @@ "optionalDependencies": { |
@@ -263,7 +263,26 @@ import URI from 'urijs'; | ||
} | ||
throw new UnauthorizedError( | ||
'Unable to access ressource: 401 found !', | ||
response | ||
); | ||
} else { | ||
// if www-authenticate header is missing, try and read json response | ||
return response | ||
.json() | ||
.then(body => { | ||
if (this._tokenStorage && body.error === 'invalid_grant') { | ||
return this._refreshTokenAndRefetch(response, input, init); | ||
} | ||
throw new UnauthorizedError( | ||
'Unable to access ressource: 401 found !', | ||
response | ||
); | ||
}) | ||
.catch(() => { | ||
throw new UnauthorizedError( | ||
'Unable to access ressource: 401 found !', | ||
response | ||
); | ||
}); | ||
} | ||
throw new UnauthorizedError( | ||
'Unable to access ressource: 401 found !', | ||
response | ||
); | ||
} | ||
@@ -270,0 +289,0 @@ |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
343436
4365
10