@aws-sdk/credential-provider-http 3.972.47 → 3.972.49

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.
@@ -1,13 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.checkUrl = void 0;
4
- const config_1 = require("@smithy/core/config");
1
+ const { CredentialsProviderError } = require("@smithy/core/config");
5
2
  const LOOPBACK_CIDR_IPv4 = "127.0.0.0/8";
6
3
  const LOOPBACK_CIDR_IPv6 = "::1/128";
7
4
  const ECS_CONTAINER_HOST = "169.254.170.2";
8
5
  const EKS_CONTAINER_HOST_IPv4 = "169.254.170.23";
9
6
  const EKS_CONTAINER_HOST_IPv6 = "[fd00:ec2::23]";
10
- const checkUrl = (url, logger) => {
7
+ exports.checkUrl = (url, logger) => {
11
8
  if (url.protocol === "https:") {
12
9
  return;
13
10
  }
@@ -38,9 +35,8 @@ const checkUrl = (url, logger) => {
38
35
  return;
39
36
  }
40
37
  }
41
- throw new config_1.CredentialsProviderError(`URL not accepted. It must either be HTTPS or match one of the following:
38
+ throw new CredentialsProviderError(`URL not accepted. It must either be HTTPS or match one of the following:
42
39
  - loopback CIDR 127.0.0.0/8 or [::1/128]
43
40
  - ECS container host 169.254.170.2
44
41
  - EKS container host 169.254.170.23 or [fd00:ec2::23]`, { logger });
45
42
  };
46
- exports.checkUrl = checkUrl;
@@ -1,12 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fromHttp = void 0;
4
- const config_1 = require("@smithy/core/config");
5
- const fetch_http_handler_1 = require("@smithy/fetch-http-handler");
6
- const checkUrl_1 = require("./checkUrl");
7
- const requestHelpers_1 = require("./requestHelpers");
8
- const retry_wrapper_1 = require("./retry-wrapper");
9
- const fromHttp = (options = {}) => {
1
+ const { CredentialsProviderError } = require("@smithy/core/config");
2
+ const { FetchHttpHandler } = require("@smithy/fetch-http-handler");
3
+ const { checkUrl } = require("./checkUrl");
4
+ const { createGetRequest, getCredentials } = require("./requestHelpers");
5
+ const { retryWrapper } = require("./retry-wrapper");
6
+ exports.fromHttp = (options = {}) => {
10
7
  options.logger?.debug("@aws-sdk/credential-provider-http - fromHttp");
11
8
  let host;
12
9
  const full = options.credentialsFullUri;
@@ -14,18 +11,17 @@ const fromHttp = (options = {}) => {
14
11
  host = full;
15
12
  }
16
13
  else {
17
- throw new config_1.CredentialsProviderError("No HTTP credential provider host provided.", { logger: options.logger });
14
+ throw new CredentialsProviderError("No HTTP credential provider host provided.", { logger: options.logger });
18
15
  }
19
16
  const url = new URL(host);
20
- (0, checkUrl_1.checkUrl)(url, options.logger);
21
- const requestHandler = new fetch_http_handler_1.FetchHttpHandler();
22
- return (0, retry_wrapper_1.retryWrapper)(async () => {
23
- const request = (0, requestHelpers_1.createGetRequest)(url);
17
+ checkUrl(url, options.logger);
18
+ const requestHandler = new FetchHttpHandler();
19
+ return retryWrapper(async () => {
20
+ const request = createGetRequest(url);
24
21
  if (options.authorizationToken) {
25
22
  request.headers.Authorization = options.authorizationToken;
26
23
  }
27
24
  const result = await requestHandler.handle(request);
28
- return (0, requestHelpers_1.getCredentials)(result.response);
25
+ return getCredentials(result.response);
29
26
  }, options.maxRetries ?? 3, options.timeout ?? 1000);
30
27
  };
31
- exports.fromHttp = fromHttp;
@@ -1,20 +1,16 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fromHttp = void 0;
4
- const tslib_1 = require("tslib");
5
- const client_1 = require("@aws-sdk/core/client");
6
- const config_1 = require("@smithy/core/config");
7
- const node_http_handler_1 = require("@smithy/node-http-handler");
8
- const promises_1 = tslib_1.__importDefault(require("node:fs/promises"));
9
- const checkUrl_1 = require("./checkUrl");
10
- const requestHelpers_1 = require("./requestHelpers");
11
- const retry_wrapper_1 = require("./retry-wrapper");
1
+ const { setCredentialFeature } = require("@aws-sdk/core/client");
2
+ const { CredentialsProviderError } = require("@smithy/core/config");
3
+ const { NodeHttpHandler } = require("@smithy/node-http-handler");
4
+ const fs = require("node:fs/promises");
5
+ const { checkUrl } = require("./checkUrl");
6
+ const { createGetRequest, getCredentials } = require("./requestHelpers");
7
+ const { retryWrapper } = require("./retry-wrapper");
12
8
  const AWS_CONTAINER_CREDENTIALS_RELATIVE_URI = "AWS_CONTAINER_CREDENTIALS_RELATIVE_URI";
13
9
  const DEFAULT_LINK_LOCAL_HOST = "http://169.254.170.2";
14
10
  const AWS_CONTAINER_CREDENTIALS_FULL_URI = "AWS_CONTAINER_CREDENTIALS_FULL_URI";
15
11
  const AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE = "AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE";
16
12
  const AWS_CONTAINER_AUTHORIZATION_TOKEN = "AWS_CONTAINER_AUTHORIZATION_TOKEN";
17
- const fromHttp = (options = {}) => {
13
+ exports.fromHttp = (options = {}) => {
18
14
  options.logger?.debug("@aws-sdk/credential-provider-http - fromHttp");
19
15
  let host;
20
16
  const relative = options.awsContainerCredentialsRelativeUri ?? process.env[AWS_CONTAINER_CREDENTIALS_RELATIVE_URI];
@@ -41,27 +37,27 @@ const fromHttp = (options = {}) => {
41
37
  host = `${DEFAULT_LINK_LOCAL_HOST}${relative}`;
42
38
  }
43
39
  else {
44
- throw new config_1.CredentialsProviderError(`No HTTP credential provider host provided.
40
+ throw new CredentialsProviderError(`No HTTP credential provider host provided.
45
41
  Set AWS_CONTAINER_CREDENTIALS_FULL_URI or AWS_CONTAINER_CREDENTIALS_RELATIVE_URI.`, { logger: options.logger });
46
42
  }
47
43
  const url = new URL(host);
48
- (0, checkUrl_1.checkUrl)(url, options.logger);
49
- const requestHandler = node_http_handler_1.NodeHttpHandler.create({ connectionTimeout: options.timeout ?? 1000 });
44
+ checkUrl(url, options.logger);
45
+ const requestHandler = NodeHttpHandler.create({ connectionTimeout: options.timeout ?? 1000 });
50
46
  const requestTimeout = options.timeout ?? 1000;
51
- const provider = (0, retry_wrapper_1.retryWrapper)(async () => {
52
- const request = (0, requestHelpers_1.createGetRequest)(url);
47
+ const provider = retryWrapper(async () => {
48
+ const request = createGetRequest(url);
53
49
  if (token) {
54
50
  request.headers.Authorization = token;
55
51
  }
56
52
  else if (tokenFile) {
57
- request.headers.Authorization = (await promises_1.default.readFile(tokenFile)).toString();
53
+ request.headers.Authorization = (await fs.readFile(tokenFile)).toString();
58
54
  }
59
55
  try {
60
56
  const result = await requestHandler.handle(request, { requestTimeout });
61
- return (0, requestHelpers_1.getCredentials)(result.response).then((creds) => (0, client_1.setCredentialFeature)(creds, "CREDENTIALS_HTTP", "z"));
57
+ return getCredentials(result.response).then((creds) => setCredentialFeature(creds, "CREDENTIALS_HTTP", "z"));
62
58
  }
63
59
  catch (e) {
64
- throw new config_1.CredentialsProviderError(String(e), { logger: options.logger });
60
+ throw new CredentialsProviderError(String(e), { logger: options.logger });
65
61
  }
66
62
  }, options.maxRetries ?? 3, options.timeout ?? 1000);
67
63
  return async () => {
@@ -73,4 +69,3 @@ Set AWS_CONTAINER_CREDENTIALS_FULL_URI or AWS_CONTAINER_CREDENTIALS_RELATIVE_URI
73
69
  }
74
70
  };
75
71
  };
76
- exports.fromHttp = fromHttp;
@@ -1,13 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createGetRequest = createGetRequest;
4
- exports.getCredentials = getCredentials;
5
- const config_1 = require("@smithy/core/config");
6
- const protocols_1 = require("@smithy/core/protocols");
7
- const serde_1 = require("@smithy/core/serde");
8
- const serde_2 = require("@smithy/core/serde");
9
- function createGetRequest(url) {
10
- return new protocols_1.HttpRequest({
1
+ const { CredentialsProviderError } = require("@smithy/core/config");
2
+ const { HttpRequest } = require("@smithy/core/protocols");
3
+ const { parseRfc3339DateTime } = require("@smithy/core/serde");
4
+ const { sdkStreamMixin } = require("@smithy/core/serde");
5
+ exports.createGetRequest = function createGetRequest(url) {
6
+ return new HttpRequest({
11
7
  protocol: url.protocol,
12
8
  hostname: url.hostname,
13
9
  port: Number(url.port),
@@ -18,9 +14,9 @@ function createGetRequest(url) {
18
14
  }, {}),
19
15
  fragment: url.hash,
20
16
  });
21
- }
22
- async function getCredentials(response, logger) {
23
- const stream = (0, serde_2.sdkStreamMixin)(response.body);
17
+ };
18
+ exports.getCredentials = async function getCredentials(response, logger) {
19
+ const stream = sdkStreamMixin(response.body);
24
20
  const str = await stream.transformToString();
25
21
  if (response.statusCode === 200) {
26
22
  const parsed = JSON.parse(str);
@@ -28,14 +24,14 @@ async function getCredentials(response, logger) {
28
24
  typeof parsed.SecretAccessKey !== "string" ||
29
25
  typeof parsed.Token !== "string" ||
30
26
  typeof parsed.Expiration !== "string") {
31
- throw new config_1.CredentialsProviderError("HTTP credential provider response not of the required format, an object matching: " +
27
+ throw new CredentialsProviderError("HTTP credential provider response not of the required format, an object matching: " +
32
28
  "{ AccessKeyId: string, SecretAccessKey: string, Token: string, Expiration: string(rfc3339) }", { logger });
33
29
  }
34
30
  return {
35
31
  accessKeyId: parsed.AccessKeyId,
36
32
  secretAccessKey: parsed.SecretAccessKey,
37
33
  sessionToken: parsed.Token,
38
- expiration: (0, serde_1.parseRfc3339DateTime)(parsed.Expiration),
34
+ expiration: parseRfc3339DateTime(parsed.Expiration),
39
35
  };
40
36
  }
41
37
  if (response.statusCode >= 400 && response.statusCode < 500) {
@@ -44,10 +40,10 @@ async function getCredentials(response, logger) {
44
40
  parsedBody = JSON.parse(str);
45
41
  }
46
42
  catch (e) { }
47
- throw Object.assign(new config_1.CredentialsProviderError(`Server responded with status: ${response.statusCode}`, { logger }), {
43
+ throw Object.assign(new CredentialsProviderError(`Server responded with status: ${response.statusCode}`, { logger }), {
48
44
  Code: parsedBody.Code,
49
45
  Message: parsedBody.Message,
50
46
  });
51
47
  }
52
- throw new config_1.CredentialsProviderError(`Server responded with status: ${response.statusCode}`, { logger });
53
- }
48
+ throw new CredentialsProviderError(`Server responded with status: ${response.statusCode}`, { logger });
49
+ };
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.retryWrapper = void 0;
4
- const retryWrapper = (toRetry, maxRetries, delayMs) => {
1
+ exports.retryWrapper = (toRetry, maxRetries, delayMs) => {
5
2
  return async () => {
6
3
  for (let i = 0; i < maxRetries; ++i) {
7
4
  try {
@@ -14,4 +11,3 @@ const retryWrapper = (toRetry, maxRetries, delayMs) => {
14
11
  return await toRetry();
15
12
  };
16
13
  };
17
- exports.retryWrapper = retryWrapper;
@@ -1,5 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fromHttp = void 0;
4
- var fromHttp_browser_1 = require("./fromHttp/fromHttp.browser");
5
- Object.defineProperty(exports, "fromHttp", { enumerable: true, get: function () { return fromHttp_browser_1.fromHttp; } });
1
+ const { fromHttp } = require("./fromHttp/fromHttp.browser");
2
+ exports.fromHttp = fromHttp;
package/dist-cjs/index.js CHANGED
@@ -1,7 +1,2 @@
1
- 'use strict';
2
-
3
- var fromHttp = require('./fromHttp/fromHttp');
4
-
5
-
6
-
7
- exports.fromHttp = fromHttp.fromHttp;
1
+ const { fromHttp } = require("./fromHttp/fromHttp");
2
+ exports.fromHttp = fromHttp;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-sdk/credential-provider-http",
3
- "version": "3.972.47",
3
+ "version": "3.972.49",
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",
@@ -17,11 +17,11 @@
17
17
  "scripts": {
18
18
  "build": "concurrently 'yarn:build:types' 'yarn:build:es' && yarn build:cjs",
19
19
  "build:cjs": "node ../../scripts/compilation/inline",
20
- "build:es": "tsc -p tsconfig.es.json",
20
+ "build:es": "premove dist-es && tsc -p tsconfig.es.json",
21
21
  "build:include:deps": "yarn g:turbo run build -F=\"$npm_package_name\"",
22
- "build:types": "tsc -p tsconfig.types.json",
22
+ "build:types": "premove dist-types && tsc -p tsconfig.types.json",
23
23
  "build:types:downlevel": "downlevel-dts dist-types dist-types/ts3.4",
24
- "clean": "premove dist-cjs dist-es dist-types tsconfig.cjs.tsbuildinfo tsconfig.es.tsbuildinfo tsconfig.types.tsbuildinfo",
24
+ "clean": "premove dist-cjs dist-es dist-types",
25
25
  "test": "yarn g:vitest run",
26
26
  "test:watch": "yarn g:vitest watch",
27
27
  "test:integration": "yarn g:vitest run -c vitest.config.integ.mts",
@@ -38,8 +38,8 @@
38
38
  },
39
39
  "license": "Apache-2.0",
40
40
  "dependencies": {
41
- "@aws-sdk/core": "^3.974.19",
42
- "@aws-sdk/types": "^3.973.12",
41
+ "@aws-sdk/core": "^3.974.21",
42
+ "@aws-sdk/types": "^3.973.13",
43
43
  "@smithy/core": "^3.24.6",
44
44
  "@smithy/fetch-http-handler": "^5.4.6",
45
45
  "@smithy/node-http-handler": "^4.7.6",