@snyk/docker-registry-v2-client
Advanced tools
Comparing version 2.7.1 to 2.7.2
@@ -9,2 +9,3 @@ "use strict"; | ||
const MAX_RETRIES = 1; | ||
const MAX_REDIRECTS = 5; | ||
async function registryV2Call(registryBase, endpoint, accept, username, password, reqOptions = {}) { | ||
@@ -167,3 +168,10 @@ const reqConfig = buildUnauthenticatedV2RequestConfig(registryBase, endpoint, accept, reqOptions); | ||
} | ||
// Handle redirect while following up to MAX_REDIRECTS | ||
async function handleRedirect(err, config) { | ||
return handleRedirectRec(err, config, MAX_REDIRECTS); | ||
} | ||
async function handleRedirectRec(err, config, maxRedirects = 0) { | ||
if (maxRedirects === 0) { | ||
throw err; | ||
} | ||
// ACR does not handle redirects well, where automatic redirects | ||
@@ -184,3 +192,11 @@ // fail due to an unexpected authorization header. | ||
config.uri = redirectUrl; | ||
return await needle_1.needleWrapper(config, MAX_RETRIES); | ||
try { | ||
return await needle_1.needleWrapper(config, MAX_RETRIES); | ||
} | ||
catch (err) { | ||
if (isRedirectStatus(err.statusCode)) { | ||
return await handleRedirectRec(err, config, maxRedirects - 1); | ||
} | ||
throw err; | ||
} | ||
} | ||
@@ -187,0 +203,0 @@ /* |
@@ -45,3 +45,3 @@ { | ||
}, | ||
"version": "2.7.1" | ||
"version": "2.7.2" | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
56439
727