@aws-sdk/credential-provider-http 3.496.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.
@@ -7,7 +7,8 @@ const checkUrl_1 = require("./checkUrl");
7
7
  const requestHelpers_1 = require("./requestHelpers");
8
8
  const retry_wrapper_1 = require("./retry-wrapper");
9
9
  const fromHttp = (options) => {
10
- var _a, _b;
10
+ var _a, _b, _c;
11
+ (_a = options.logger) === null || _a === void 0 ? void 0 : _a.debug("@aws-sdk/credential-provider-http", "fromHttp");
11
12
  let host;
12
13
  const full = options.credentialsFullUri;
13
14
  if (full) {
@@ -26,6 +27,6 @@ const fromHttp = (options) => {
26
27
  }
27
28
  const result = await requestHandler.handle(request);
28
29
  return (0, requestHelpers_1.getCredentials)(result.response);
29
- }, (_a = options.maxRetries) !== null && _a !== void 0 ? _a : 3, (_b = options.timeout) !== null && _b !== void 0 ? _b : 1000);
30
+ }, (_b = options.maxRetries) !== null && _b !== void 0 ? _b : 3, (_c = options.timeout) !== null && _c !== void 0 ? _c : 1000);
30
31
  };
31
32
  exports.fromHttp = fromHttp;
@@ -14,12 +14,13 @@ 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;
17
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
18
+ (_a = options.logger) === null || _a === void 0 ? void 0 : _a.debug("@aws-sdk/credential-provider-http", "fromHttp");
18
19
  let host;
19
- const relative = (_a = options.awsContainerCredentialsRelativeUri) !== null && _a !== void 0 ? _a : process.env[AWS_CONTAINER_CREDENTIALS_RELATIVE_URI];
20
- const full = (_b = options.awsContainerCredentialsFullUri) !== null && _b !== void 0 ? _b : process.env[AWS_CONTAINER_CREDENTIALS_FULL_URI];
21
- const token = (_c = options.awsContainerAuthorizationToken) !== null && _c !== void 0 ? _c : process.env[AWS_CONTAINER_AUTHORIZATION_TOKEN];
22
- const tokenFile = (_d = options.awsContainerAuthorizationTokenFile) !== null && _d !== void 0 ? _d : process.env[AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE];
20
+ const relative = (_b = options.awsContainerCredentialsRelativeUri) !== null && _b !== void 0 ? _b : process.env[AWS_CONTAINER_CREDENTIALS_RELATIVE_URI];
21
+ const full = (_c = options.awsContainerCredentialsFullUri) !== null && _c !== void 0 ? _c : process.env[AWS_CONTAINER_CREDENTIALS_FULL_URI];
22
+ const token = (_d = options.awsContainerAuthorizationToken) !== null && _d !== void 0 ? _d : process.env[AWS_CONTAINER_AUTHORIZATION_TOKEN];
23
+ const tokenFile = (_e = options.awsContainerAuthorizationTokenFile) !== null && _e !== void 0 ? _e : process.env[AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE];
23
24
  if (relative && full) {
24
25
  console.warn("AWS SDK HTTP credentials provider:", "you have set both awsContainerCredentialsRelativeUri and awsContainerCredentialsFullUri.");
25
26
  console.warn("awsContainerCredentialsFullUri will take precedence.");
@@ -35,11 +36,15 @@ const fromHttp = (options) => {
35
36
  host = `${DEFAULT_LINK_LOCAL_HOST}${relative}`;
36
37
  }
37
38
  else {
38
- 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.`);
39
41
  }
40
42
  const url = new URL(host);
41
43
  (0, checkUrl_1.checkUrl)(url);
42
- 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
+ });
43
48
  return (0, retry_wrapper_1.retryWrapper)(async () => {
44
49
  const request = (0, requestHelpers_1.createGetRequest)(url);
45
50
  if (token) {
@@ -48,8 +53,13 @@ const fromHttp = (options) => {
48
53
  else if (tokenFile) {
49
54
  request.headers.Authorization = (await promises_1.default.readFile(tokenFile)).toString();
50
55
  }
51
- const result = await requestHandler.handle(request);
52
- return (0, requestHelpers_1.getCredentials)(result.response);
53
- }, (_e = options.maxRetries) !== null && _e !== void 0 ? _e : 3, (_f = options.timeout) !== null && _f !== void 0 ? _f : 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);
54
64
  };
55
65
  exports.fromHttp = fromHttp;
@@ -4,6 +4,7 @@ import { checkUrl } from "./checkUrl";
4
4
  import { createGetRequest, getCredentials } from "./requestHelpers";
5
5
  import { retryWrapper } from "./retry-wrapper";
6
6
  export const fromHttp = (options) => {
7
+ options.logger?.debug("@aws-sdk/credential-provider-http", "fromHttp");
7
8
  let host;
8
9
  const full = options.credentialsFullUri;
9
10
  if (full) {
@@ -10,6 +10,7 @@ const AWS_CONTAINER_CREDENTIALS_FULL_URI = "AWS_CONTAINER_CREDENTIALS_FULL_URI";
10
10
  const AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE = "AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE";
11
11
  const AWS_CONTAINER_AUTHORIZATION_TOKEN = "AWS_CONTAINER_AUTHORIZATION_TOKEN";
12
12
  export const fromHttp = (options) => {
13
+ options.logger?.debug("@aws-sdk/credential-provider-http", "fromHttp");
13
14
  let host;
14
15
  const relative = options.awsContainerCredentialsRelativeUri ?? process.env[AWS_CONTAINER_CREDENTIALS_RELATIVE_URI];
15
16
  const full = options.awsContainerCredentialsFullUri ?? process.env[AWS_CONTAINER_CREDENTIALS_FULL_URI];
@@ -30,11 +31,15 @@ export const fromHttp = (options) => {
30
31
  host = `${DEFAULT_LINK_LOCAL_HOST}${relative}`;
31
32
  }
32
33
  else {
33
- 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.`);
34
36
  }
35
37
  const url = new URL(host);
36
38
  checkUrl(url);
37
- const requestHandler = new NodeHttpHandler();
39
+ const requestHandler = new NodeHttpHandler({
40
+ requestTimeout: options.timeout ?? 1000,
41
+ connectionTimeout: options.timeout ?? 1000,
42
+ });
38
43
  return retryWrapper(async () => {
39
44
  const request = createGetRequest(url);
40
45
  if (token) {
@@ -43,7 +48,12 @@ export const fromHttp = (options) => {
43
48
  else if (tokenFile) {
44
49
  request.headers.Authorization = (await fs.readFile(tokenFile)).toString();
45
50
  }
46
- const result = await requestHandler.handle(request);
47
- 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
+ }
48
58
  }, options.maxRetries ?? 3, options.timeout ?? 1000);
49
59
  };
@@ -1,9 +1,10 @@
1
+ import type { CredentialProviderOptions } from "@aws-sdk/types";
1
2
  /**
2
3
  * @public
3
4
  *
4
5
  * Input for the fromHttp function in the HTTP Credentials Provider for Node.js.
5
6
  */
6
- export interface FromHttpOptions {
7
+ export interface FromHttpOptions extends CredentialProviderOptions {
7
8
  /**
8
9
  * If this value is provided, it will be used as-is.
9
10
  *
@@ -1,4 +1,5 @@
1
- export interface FromHttpOptions {
1
+ import { CredentialProviderOptions } from "@aws-sdk/types";
2
+ export interface FromHttpOptions extends CredentialProviderOptions {
2
3
  awsContainerCredentialsFullUri?: string;
3
4
  awsContainerCredentialsRelativeUri?: string;
4
5
  awsContainerAuthorizationTokenFile?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-sdk/credential-provider-http",
3
- "version": "3.496.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",
@@ -26,7 +26,7 @@
26
26
  },
27
27
  "license": "Apache-2.0",
28
28
  "dependencies": {
29
- "@aws-sdk/types": "3.496.0",
29
+ "@aws-sdk/types": "3.502.0",
30
30
  "@smithy/fetch-http-handler": "^2.4.1",
31
31
  "@smithy/node-http-handler": "^2.3.1",
32
32
  "@smithy/property-provider": "^2.1.1",