@aws-sdk/credential-provider-http 3.502.0 → 3.503.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.
@@ -14,7 +14,7 @@ const AWS_CONTAINER_CREDENTIALS_FULL_URI = "AWS_CONTAINER_CREDENTIALS_FULL_URI";
14
14
  const AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE = "AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE";
15
15
  const AWS_CONTAINER_AUTHORIZATION_TOKEN = "AWS_CONTAINER_AUTHORIZATION_TOKEN";
16
16
  const fromHttp = (options) => {
17
- var _a, _b, _c, _d, _e, _f, _g;
17
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
18
18
  (_a = options.logger) === null || _a === void 0 ? void 0 : _a.debug("@aws-sdk/credential-provider-http", "fromHttp");
19
19
  let host;
20
20
  const relative = (_b = options.awsContainerCredentialsRelativeUri) !== null && _b !== void 0 ? _b : process.env[AWS_CONTAINER_CREDENTIALS_RELATIVE_URI];
@@ -36,11 +36,15 @@ const fromHttp = (options) => {
36
36
  host = `${DEFAULT_LINK_LOCAL_HOST}${relative}`;
37
37
  }
38
38
  else {
39
- throw new property_provider_1.CredentialsProviderError("No HTTP credential provider host provided.");
39
+ throw new property_provider_1.CredentialsProviderError(`No HTTP credential provider host provided.
40
+ Set AWS_CONTAINER_CREDENTIALS_FULL_URI or AWS_CONTAINER_CREDENTIALS_RELATIVE_URI.`);
40
41
  }
41
42
  const url = new URL(host);
42
43
  (0, checkUrl_1.checkUrl)(url);
43
- const requestHandler = new node_http_handler_1.NodeHttpHandler();
44
+ const requestHandler = new node_http_handler_1.NodeHttpHandler({
45
+ requestTimeout: (_f = options.timeout) !== null && _f !== void 0 ? _f : 1000,
46
+ connectionTimeout: (_g = options.timeout) !== null && _g !== void 0 ? _g : 1000,
47
+ });
44
48
  return (0, retry_wrapper_1.retryWrapper)(async () => {
45
49
  const request = (0, requestHelpers_1.createGetRequest)(url);
46
50
  if (token) {
@@ -49,8 +53,13 @@ const fromHttp = (options) => {
49
53
  else if (tokenFile) {
50
54
  request.headers.Authorization = (await promises_1.default.readFile(tokenFile)).toString();
51
55
  }
52
- const result = await requestHandler.handle(request);
53
- return (0, requestHelpers_1.getCredentials)(result.response);
54
- }, (_f = options.maxRetries) !== null && _f !== void 0 ? _f : 3, (_g = options.timeout) !== null && _g !== void 0 ? _g : 1000);
56
+ try {
57
+ const result = await requestHandler.handle(request);
58
+ return (0, requestHelpers_1.getCredentials)(result.response);
59
+ }
60
+ catch (e) {
61
+ throw new property_provider_1.CredentialsProviderError(String(e));
62
+ }
63
+ }, (_h = options.maxRetries) !== null && _h !== void 0 ? _h : 3, (_j = options.timeout) !== null && _j !== void 0 ? _j : 1000);
55
64
  };
56
65
  exports.fromHttp = fromHttp;
@@ -31,11 +31,15 @@ export const fromHttp = (options) => {
31
31
  host = `${DEFAULT_LINK_LOCAL_HOST}${relative}`;
32
32
  }
33
33
  else {
34
- throw new CredentialsProviderError("No HTTP credential provider host provided.");
34
+ throw new CredentialsProviderError(`No HTTP credential provider host provided.
35
+ Set AWS_CONTAINER_CREDENTIALS_FULL_URI or AWS_CONTAINER_CREDENTIALS_RELATIVE_URI.`);
35
36
  }
36
37
  const url = new URL(host);
37
38
  checkUrl(url);
38
- const requestHandler = new NodeHttpHandler();
39
+ const requestHandler = new NodeHttpHandler({
40
+ requestTimeout: options.timeout ?? 1000,
41
+ connectionTimeout: options.timeout ?? 1000,
42
+ });
39
43
  return retryWrapper(async () => {
40
44
  const request = createGetRequest(url);
41
45
  if (token) {
@@ -44,7 +48,12 @@ export const fromHttp = (options) => {
44
48
  else if (tokenFile) {
45
49
  request.headers.Authorization = (await fs.readFile(tokenFile)).toString();
46
50
  }
47
- const result = await requestHandler.handle(request);
48
- return getCredentials(result.response);
51
+ try {
52
+ const result = await requestHandler.handle(request);
53
+ return getCredentials(result.response);
54
+ }
55
+ catch (e) {
56
+ throw new CredentialsProviderError(String(e));
57
+ }
49
58
  }, options.maxRetries ?? 3, options.timeout ?? 1000);
50
59
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-sdk/credential-provider-http",
3
- "version": "3.502.0",
3
+ "version": "3.503.1",
4
4
  "description": "AWS credential provider for containers and HTTP sources",
5
5
  "main": "./dist-cjs/index.js",
6
6
  "module": "./dist-es/index.js",