balena-request
Advanced tools
Comparing version 11.1.0 to 11.1.1-no-refresh-on-absolute-url-a61c8bb2a7c144748048e41b201f1ee2f7d6e7c7
@@ -56,3 +56,4 @@ "use strict"; | ||
} | ||
if (urlLib.parse(options.url).protocol != null) { | ||
const isAbsoluteUrl = urlLib.parse(options.url).protocol != null; | ||
if (isAbsoluteUrl) { | ||
delete options.baseUrl; | ||
@@ -62,7 +63,12 @@ } | ||
// token, and we haven't opted out of refresh | ||
if (auth != null && options.sendToken && options.refreshToken) { | ||
const shouldRefreshKey = yield utils.shouldRefreshKey(auth); | ||
if (shouldRefreshKey) { | ||
if (auth != null && | ||
options.sendToken && | ||
options.refreshToken && | ||
(yield utils.shouldRefreshKey(auth))) { | ||
if (!isAbsoluteUrl) { | ||
yield exports.refreshToken({ baseUrl }); | ||
} | ||
if (yield auth.isExpired()) { | ||
throw new errors.BalenaExpiredToken(yield auth.getKey()); | ||
} | ||
} | ||
@@ -69,0 +75,0 @@ const authorizationHeader = options.sendToken |
@@ -7,2 +7,7 @@ # Change Log | ||
# v11.1.1 | ||
## (2020-08-13) | ||
* Stop refreshing the token on absolute urls [Thodoris Greasidis] | ||
# v11.1.0 | ||
@@ -9,0 +14,0 @@ ## (2020-07-16) |
@@ -75,3 +75,4 @@ /* | ||
} | ||
if (urlLib.parse(options.url).protocol != null) { | ||
const isAbsoluteUrl = urlLib.parse(options.url).protocol != null; | ||
if (isAbsoluteUrl) { | ||
delete options.baseUrl; | ||
@@ -82,7 +83,14 @@ } | ||
// token, and we haven't opted out of refresh | ||
if (auth != null && options.sendToken && options.refreshToken) { | ||
const shouldRefreshKey = await utils.shouldRefreshKey(auth); | ||
if (shouldRefreshKey) { | ||
if ( | ||
auth != null && | ||
options.sendToken && | ||
options.refreshToken && | ||
(await utils.shouldRefreshKey(auth)) | ||
) { | ||
if (!isAbsoluteUrl) { | ||
await exports.refreshToken({ baseUrl }); | ||
} | ||
if (await auth.isExpired()) { | ||
throw new errors.BalenaExpiredToken(await auth.getKey()); | ||
} | ||
} | ||
@@ -89,0 +97,0 @@ const authorizationHeader = options.sendToken |
{ | ||
"name": "balena-request", | ||
"version": "11.1.0", | ||
"version": "11.1.1-no-refresh-on-absolute-url-a61c8bb2a7c144748048e41b201f1ee2f7d6e7c7", | ||
"description": "Balena HTTP client", | ||
@@ -5,0 +5,0 @@ "main": "build/request.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
169304
1884
1