@cdk8s/awscdk-resolver 0.0.613 → 0.0.615
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.
- package/.jsii +3 -3
- package/lib/resolve.js +1 -1
- package/node_modules/@aws-sdk/client-cloudformation/dist-cjs/index.js +3710 -15
- package/node_modules/@aws-sdk/client-cloudformation/dist-types/runtimeConfig.browser.d.ts +1 -1
- package/node_modules/@aws-sdk/client-cloudformation/dist-types/runtimeConfig.d.ts +1 -1
- package/node_modules/@aws-sdk/client-cloudformation/dist-types/runtimeConfig.native.d.ts +1 -1
- package/node_modules/@aws-sdk/client-cloudformation/dist-types/ts3.4/runtimeConfig.browser.d.ts +7 -1
- package/node_modules/@aws-sdk/client-cloudformation/dist-types/ts3.4/runtimeConfig.d.ts +7 -1
- package/node_modules/@aws-sdk/client-cloudformation/dist-types/ts3.4/runtimeConfig.native.d.ts +7 -1
- package/node_modules/@aws-sdk/client-cloudformation/package.json +8 -8
- package/node_modules/@aws-sdk/core/account-id-endpoint.d.ts +1 -3
- package/node_modules/@aws-sdk/core/client.d.ts +1 -3
- package/node_modules/@aws-sdk/core/httpAuthSchemes.d.ts +1 -3
- package/node_modules/@aws-sdk/core/package.json +8 -14
- package/node_modules/@aws-sdk/core/protocols.d.ts +1 -3
- package/node_modules/@aws-sdk/core/util.d.ts +1 -3
- package/node_modules/@aws-sdk/credential-provider-env/package.json +5 -5
- package/node_modules/@aws-sdk/credential-provider-http/dist-cjs/index.js +172 -1
- package/node_modules/@aws-sdk/credential-provider-http/package.json +8 -10
- package/node_modules/@aws-sdk/credential-provider-ini/package.json +13 -13
- package/node_modules/@aws-sdk/credential-provider-login/package.json +6 -6
- package/node_modules/@aws-sdk/credential-provider-node/package.json +11 -11
- package/node_modules/@aws-sdk/credential-provider-process/package.json +5 -5
- package/node_modules/@aws-sdk/credential-provider-sso/package.json +7 -7
- package/node_modules/@aws-sdk/credential-provider-web-identity/dist-cjs/index.js +58 -3
- package/node_modules/@aws-sdk/credential-provider-web-identity/package.json +7 -8
- package/node_modules/@aws-sdk/nested-clients/cognito-identity.d.ts +1 -3
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/cognito-identity/index.js +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/signin/index.js +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso/index.js +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso-oidc/index.js +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sts/index.js +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/cognito-identity/runtimeConfig.browser.d.ts +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/cognito-identity/runtimeConfig.d.ts +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/cognito-identity/runtimeConfig.native.d.ts +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/signin/runtimeConfig.browser.d.ts +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/signin/runtimeConfig.d.ts +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/signin/runtimeConfig.native.d.ts +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sso/runtimeConfig.browser.d.ts +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sso/runtimeConfig.d.ts +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sso/runtimeConfig.native.d.ts +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sso-oidc/runtimeConfig.browser.d.ts +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sso-oidc/runtimeConfig.d.ts +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sso-oidc/runtimeConfig.native.d.ts +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sts/runtimeConfig.browser.d.ts +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sts/runtimeConfig.d.ts +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sts/runtimeConfig.native.d.ts +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/cognito-identity/runtimeConfig.browser.d.ts +7 -1
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/cognito-identity/runtimeConfig.d.ts +7 -1
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/cognito-identity/runtimeConfig.native.d.ts +7 -1
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/signin/runtimeConfig.browser.d.ts +7 -1
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/signin/runtimeConfig.d.ts +7 -1
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/signin/runtimeConfig.native.d.ts +7 -1
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sso/runtimeConfig.browser.d.ts +7 -1
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sso/runtimeConfig.d.ts +7 -1
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sso/runtimeConfig.native.d.ts +7 -1
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sso-oidc/runtimeConfig.browser.d.ts +7 -1
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sso-oidc/runtimeConfig.d.ts +7 -1
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sso-oidc/runtimeConfig.native.d.ts +7 -1
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sts/runtimeConfig.browser.d.ts +7 -1
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sts/runtimeConfig.d.ts +7 -1
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sts/runtimeConfig.native.d.ts +7 -1
- package/node_modules/@aws-sdk/nested-clients/package.json +8 -8
- package/node_modules/@aws-sdk/nested-clients/signin.d.ts +1 -3
- package/node_modules/@aws-sdk/nested-clients/sso-oidc.d.ts +1 -3
- package/node_modules/@aws-sdk/nested-clients/sso.d.ts +1 -3
- package/node_modules/@aws-sdk/nested-clients/sts.d.ts +1 -3
- package/node_modules/@aws-sdk/signature-v4-multi-region/package.json +4 -4
- package/node_modules/@aws-sdk/token-providers/package.json +6 -6
- package/node_modules/@aws-sdk/types/package.json +2 -2
- package/node_modules/@aws-sdk/xml-builder/dist-cjs/index.js +236 -3
- package/node_modules/@aws-sdk/xml-builder/package.json +3 -4
- package/node_modules/@smithy/core/dist-cjs/submodules/checksum/index.browser.js +358 -145
- package/node_modules/@smithy/core/dist-cjs/submodules/checksum/index.js +462 -142
- package/node_modules/@smithy/core/dist-cjs/submodules/checksum/index.native.js +358 -145
- package/node_modules/@smithy/core/dist-cjs/submodules/config/index.js +108 -63
- package/node_modules/@smithy/core/dist-cjs/submodules/event-streams/index.browser.js +11 -8
- package/node_modules/@smithy/core/dist-cjs/submodules/event-streams/index.js +11 -8
- package/node_modules/@smithy/core/dist-cjs/submodules/protocols/index.js +5 -2
- package/node_modules/@smithy/core/dist-cjs/submodules/serde/index.browser.js +30 -36
- package/node_modules/@smithy/core/dist-cjs/submodules/serde/index.js +54 -110
- package/node_modules/@smithy/core/dist-cjs/submodules/serde/index.native.js +30 -36
- package/node_modules/@smithy/core/dist-es/submodules/checksum/crc32/Crc32Js.js +30 -0
- package/node_modules/@smithy/core/dist-es/submodules/checksum/crc32/Crc32Node.js +24 -0
- package/node_modules/@smithy/core/dist-es/submodules/checksum/index.browser.js +7 -1
- package/node_modules/@smithy/core/dist-es/submodules/checksum/index.js +7 -1
- package/node_modules/@smithy/core/dist-es/submodules/checksum/index.native.js +7 -1
- package/node_modules/@smithy/core/dist-es/submodules/checksum/md5/Md5Js.js +92 -0
- package/node_modules/@smithy/core/dist-es/submodules/checksum/md5/Md5Node.js +29 -0
- package/node_modules/@smithy/core/dist-es/submodules/checksum/sha256/Sha256Js.js +179 -0
- package/node_modules/@smithy/core/dist-es/submodules/checksum/sha256/Sha256Node.js +59 -0
- package/node_modules/@smithy/core/dist-es/submodules/checksum/sha256/Sha256WebCrypto.js +71 -0
- package/node_modules/@smithy/core/dist-es/submodules/config/config-resolver/regionConfig/config.js +6 -1
- package/node_modules/@smithy/core/dist-es/submodules/config/config-resolver/regionConfig/getInstanceMetadataRegion.js +92 -0
- package/node_modules/@smithy/core/dist-es/submodules/config/defaults-mode/constants.js +3 -0
- package/node_modules/@smithy/core/dist-es/submodules/config/defaults-mode/resolveDefaultsModeConfig.js +3 -56
- package/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-codec/EventStreamCodec.js +5 -3
- package/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-codec/splitMessage.js +7 -6
- package/node_modules/@smithy/core/dist-es/submodules/protocols/HttpProtocol.js +4 -1
- package/node_modules/@smithy/core/dist-es/submodules/serde/concatBytes.js +15 -0
- package/node_modules/@smithy/core/dist-es/submodules/serde/index.browser.js +2 -0
- package/node_modules/@smithy/core/dist-es/submodules/serde/index.js +2 -0
- package/node_modules/@smithy/core/dist-es/submodules/serde/index.native.js +2 -0
- package/node_modules/@smithy/core/dist-es/submodules/serde/util-stream/checksum/ChecksumStream.js +4 -0
- package/node_modules/@smithy/core/dist-es/submodules/serde/util-stream/headStream.js +2 -1
- package/node_modules/@smithy/core/dist-es/submodules/serde/util-stream/stream-collector.browser.js +12 -38
- package/node_modules/@smithy/core/dist-es/submodules/serde/util-stream/stream-collector.js +18 -33
- package/node_modules/@smithy/core/dist-es/submodules/serde/util-utf8/toUint8Array.browser.js +3 -0
- package/node_modules/@smithy/core/dist-es/submodules/serde/util-utf8/toUint8Array.js +3 -0
- package/node_modules/@smithy/core/dist-types/submodules/checksum/crc32/Crc32Js.d.ts +18 -0
- package/node_modules/@smithy/core/dist-types/submodules/checksum/crc32/Crc32Node.d.ts +18 -0
- package/node_modules/@smithy/core/dist-types/submodules/checksum/index.browser.d.ts +7 -1
- package/node_modules/@smithy/core/dist-types/submodules/checksum/index.d.ts +7 -1
- package/node_modules/@smithy/core/dist-types/submodules/checksum/index.native.d.ts +7 -1
- package/node_modules/@smithy/core/dist-types/submodules/checksum/md5/Md5Js.d.ts +19 -0
- package/node_modules/@smithy/core/dist-types/submodules/checksum/md5/Md5Node.d.ts +17 -0
- package/node_modules/@smithy/core/dist-types/submodules/checksum/sha256/Sha256Js.d.ts +28 -0
- package/node_modules/@smithy/core/dist-types/submodules/checksum/sha256/Sha256Node.d.ts +13 -0
- package/node_modules/@smithy/core/dist-types/submodules/checksum/sha256/Sha256WebCrypto.d.ts +22 -0
- package/node_modules/@smithy/core/dist-types/submodules/config/config-resolver/regionConfig/getInstanceMetadataRegion.d.ts +7 -0
- package/node_modules/@smithy/core/dist-types/submodules/config/defaults-mode/constants.d.ts +12 -0
- package/node_modules/@smithy/core/dist-types/submodules/serde/concatBytes.d.ts +6 -0
- package/node_modules/@smithy/core/dist-types/submodules/serde/index.browser.d.ts +2 -0
- package/node_modules/@smithy/core/dist-types/submodules/serde/index.d.ts +2 -0
- package/node_modules/@smithy/core/dist-types/submodules/serde/index.native.d.ts +2 -0
- package/node_modules/@smithy/core/dist-types/submodules/serde/util-stream/checksum/ChecksumStream.d.ts +9 -0
- package/node_modules/@smithy/core/dist-types/submodules/serde/util-stream/stream-collector.browser.d.ts +8 -2
- package/node_modules/@smithy/core/dist-types/submodules/serde/util-stream/stream-collector.d.ts +4 -1
- package/node_modules/@smithy/core/package.json +4 -4
- package/node_modules/@smithy/credential-provider-imds/package.json +2 -2
- package/node_modules/@smithy/fetch-http-handler/dist-cjs/index.js +2 -55
- package/node_modules/@smithy/fetch-http-handler/dist-es/index.js +2 -2
- package/node_modules/@smithy/fetch-http-handler/dist-types/index.d.ts +2 -2
- package/node_modules/@smithy/fetch-http-handler/package.json +2 -2
- package/node_modules/@smithy/node-http-handler/dist-cjs/index.js +3 -51
- package/node_modules/@smithy/node-http-handler/dist-es/index.js +3 -3
- package/node_modules/@smithy/node-http-handler/dist-types/index.d.ts +3 -3
- package/node_modules/@smithy/node-http-handler/package.json +2 -2
- package/node_modules/@smithy/signature-v4/package.json +2 -3
- package/package.json +5 -5
- package/node_modules/@aws-crypto/crc32/CHANGELOG.md +0 -100
- package/node_modules/@aws-crypto/crc32/LICENSE +0 -201
- package/node_modules/@aws-crypto/crc32/README.md +0 -16
- package/node_modules/@aws-crypto/crc32/build/main/aws_crc32.d.ts +0 -7
- package/node_modules/@aws-crypto/crc32/build/main/aws_crc32.js +0 -31
- package/node_modules/@aws-crypto/crc32/build/main/aws_crc32.js.map +0 -1
- package/node_modules/@aws-crypto/crc32/build/main/index.d.ts +0 -7
- package/node_modules/@aws-crypto/crc32/build/main/index.js +0 -108
- package/node_modules/@aws-crypto/crc32/build/main/index.js.map +0 -1
- package/node_modules/@aws-crypto/crc32/build/module/aws_crc32.d.ts +0 -7
- package/node_modules/@aws-crypto/crc32/build/module/aws_crc32.js +0 -28
- package/node_modules/@aws-crypto/crc32/build/module/aws_crc32.js.map +0 -1
- package/node_modules/@aws-crypto/crc32/build/module/index.d.ts +0 -7
- package/node_modules/@aws-crypto/crc32/build/module/index.js +0 -103
- package/node_modules/@aws-crypto/crc32/build/module/index.js.map +0 -1
- package/node_modules/@aws-crypto/crc32/package.json +0 -32
- package/node_modules/@aws-crypto/crc32/src/aws_crc32.ts +0 -24
- package/node_modules/@aws-crypto/crc32/src/index.ts +0 -92
- package/node_modules/@aws-crypto/crc32/tsconfig.json +0 -9
- package/node_modules/@aws-crypto/crc32/tsconfig.module.json +0 -7
- package/node_modules/@aws-sdk/client-cloudformation/dist-cjs/auth/httpAuthSchemeProvider.js +0 -40
- package/node_modules/@aws-sdk/client-cloudformation/dist-cjs/endpoint/bdd.js +0 -49
- package/node_modules/@aws-sdk/client-cloudformation/dist-cjs/endpoint/endpointResolver.js +0 -14
- package/node_modules/@aws-sdk/client-cloudformation/dist-cjs/models/CloudFormationServiceException.js +0 -8
- package/node_modules/@aws-sdk/client-cloudformation/dist-cjs/models/errors.js +0 -407
- package/node_modules/@aws-sdk/client-cloudformation/dist-cjs/runtimeConfig.browser.js +0 -32
- package/node_modules/@aws-sdk/client-cloudformation/dist-cjs/runtimeConfig.js +0 -45
- package/node_modules/@aws-sdk/client-cloudformation/dist-cjs/runtimeConfig.native.js +0 -12
- package/node_modules/@aws-sdk/client-cloudformation/dist-cjs/runtimeConfig.shared.js +0 -39
- package/node_modules/@aws-sdk/client-cloudformation/dist-cjs/schemas/schemas_0.js +0 -3022
- package/node_modules/@aws-sdk/core/dist-cjs/submodules/client/index.browser.js +0 -869
- package/node_modules/@aws-sdk/core/dist-cjs/submodules/client/index.native.js +0 -862
- package/node_modules/@aws-sdk/credential-provider-http/dist-cjs/fromHttp/checkUrl.js +0 -42
- package/node_modules/@aws-sdk/credential-provider-http/dist-cjs/fromHttp/fromHttp.browser.js +0 -27
- package/node_modules/@aws-sdk/credential-provider-http/dist-cjs/fromHttp/fromHttp.js +0 -71
- package/node_modules/@aws-sdk/credential-provider-http/dist-cjs/fromHttp/requestHelpers.js +0 -49
- package/node_modules/@aws-sdk/credential-provider-http/dist-cjs/fromHttp/retry-wrapper.js +0 -13
- package/node_modules/@aws-sdk/credential-provider-http/dist-cjs/index.browser.js +0 -2
- package/node_modules/@aws-sdk/credential-provider-web-identity/dist-cjs/fromTokenFile.js +0 -29
- package/node_modules/@aws-sdk/credential-provider-web-identity/dist-cjs/fromWebToken.js +0 -25
- package/node_modules/@aws-sdk/xml-builder/dist-cjs/xml-parser.browser.js +0 -57
- package/node_modules/@aws-sdk/xml-builder/dist-cjs/xml-parser.js +0 -234
- package/node_modules/@smithy/core/dist-es/submodules/checksum/md5-js/constants.js +0 -3
- package/node_modules/@smithy/core/dist-es/submodules/checksum/md5-js/md5.js +0 -168
- package/node_modules/@smithy/core/dist-types/submodules/checksum/md5-js/constants.d.ts +0 -12
- package/node_modules/@smithy/core/dist-types/submodules/checksum/md5-js/md5.d.ts +0 -16
- package/node_modules/@smithy/fetch-http-handler/dist-es/stream-collector.js +0 -53
- package/node_modules/@smithy/fetch-http-handler/dist-types/stream-collector.d.ts +0 -2
- package/node_modules/@smithy/node-http-handler/dist-es/stream-collector/collector.js +0 -8
- package/node_modules/@smithy/node-http-handler/dist-es/stream-collector/index.js +0 -41
- package/node_modules/@smithy/node-http-handler/dist-types/stream-collector/collector.d.ts +0 -5
- package/node_modules/@smithy/node-http-handler/dist-types/stream-collector/index.d.ts +0 -7
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
const { CredentialsProviderError } = require("@smithy/core/config");
|
|
2
|
-
const LOOPBACK_CIDR_IPv4 = "127.0.0.0/8";
|
|
3
|
-
const LOOPBACK_CIDR_IPv6 = "::1/128";
|
|
4
|
-
const ECS_CONTAINER_HOST = "169.254.170.2";
|
|
5
|
-
const EKS_CONTAINER_HOST_IPv4 = "169.254.170.23";
|
|
6
|
-
const EKS_CONTAINER_HOST_IPv6 = "[fd00:ec2::23]";
|
|
7
|
-
exports.checkUrl = (url, logger) => {
|
|
8
|
-
if (url.protocol === "https:") {
|
|
9
|
-
return;
|
|
10
|
-
}
|
|
11
|
-
if (url.hostname === ECS_CONTAINER_HOST ||
|
|
12
|
-
url.hostname === EKS_CONTAINER_HOST_IPv4 ||
|
|
13
|
-
url.hostname === EKS_CONTAINER_HOST_IPv6) {
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
if (url.hostname.includes("[")) {
|
|
17
|
-
if (url.hostname === "[::1]" || url.hostname === "[0000:0000:0000:0000:0000:0000:0000:0001]") {
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
if (url.hostname === "localhost") {
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
const ipComponents = url.hostname.split(".");
|
|
26
|
-
const inRange = (component) => {
|
|
27
|
-
const num = parseInt(component, 10);
|
|
28
|
-
return 0 <= num && num <= 255;
|
|
29
|
-
};
|
|
30
|
-
if (ipComponents[0] === "127" &&
|
|
31
|
-
inRange(ipComponents[1]) &&
|
|
32
|
-
inRange(ipComponents[2]) &&
|
|
33
|
-
inRange(ipComponents[3]) &&
|
|
34
|
-
ipComponents.length === 4) {
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
throw new CredentialsProviderError(`URL not accepted. It must either be HTTPS or match one of the following:
|
|
39
|
-
- loopback CIDR 127.0.0.0/8 or [::1/128]
|
|
40
|
-
- ECS container host 169.254.170.2
|
|
41
|
-
- EKS container host 169.254.170.23 or [fd00:ec2::23]`, { logger });
|
|
42
|
-
};
|
package/node_modules/@aws-sdk/credential-provider-http/dist-cjs/fromHttp/fromHttp.browser.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
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 = {}) => {
|
|
7
|
-
options.logger?.debug("@aws-sdk/credential-provider-http - fromHttp");
|
|
8
|
-
let host;
|
|
9
|
-
const full = options.credentialsFullUri;
|
|
10
|
-
if (full) {
|
|
11
|
-
host = full;
|
|
12
|
-
}
|
|
13
|
-
else {
|
|
14
|
-
throw new CredentialsProviderError("No HTTP credential provider host provided.", { logger: options.logger });
|
|
15
|
-
}
|
|
16
|
-
const url = new URL(host);
|
|
17
|
-
checkUrl(url, options.logger);
|
|
18
|
-
const requestHandler = new FetchHttpHandler();
|
|
19
|
-
return retryWrapper(async () => {
|
|
20
|
-
const request = createGetRequest(url);
|
|
21
|
-
if (options.authorizationToken) {
|
|
22
|
-
request.headers.Authorization = options.authorizationToken;
|
|
23
|
-
}
|
|
24
|
-
const result = await requestHandler.handle(request);
|
|
25
|
-
return getCredentials(result.response);
|
|
26
|
-
}, options.maxRetries ?? 3, options.timeout ?? 1000);
|
|
27
|
-
};
|
|
@@ -1,71 +0,0 @@
|
|
|
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");
|
|
8
|
-
const AWS_CONTAINER_CREDENTIALS_RELATIVE_URI = "AWS_CONTAINER_CREDENTIALS_RELATIVE_URI";
|
|
9
|
-
const DEFAULT_LINK_LOCAL_HOST = "http://169.254.170.2";
|
|
10
|
-
const AWS_CONTAINER_CREDENTIALS_FULL_URI = "AWS_CONTAINER_CREDENTIALS_FULL_URI";
|
|
11
|
-
const AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE = "AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE";
|
|
12
|
-
const AWS_CONTAINER_AUTHORIZATION_TOKEN = "AWS_CONTAINER_AUTHORIZATION_TOKEN";
|
|
13
|
-
exports.fromHttp = (options = {}) => {
|
|
14
|
-
options.logger?.debug("@aws-sdk/credential-provider-http - fromHttp");
|
|
15
|
-
let host;
|
|
16
|
-
const relative = options.awsContainerCredentialsRelativeUri ?? process.env[AWS_CONTAINER_CREDENTIALS_RELATIVE_URI];
|
|
17
|
-
const full = options.awsContainerCredentialsFullUri ?? process.env[AWS_CONTAINER_CREDENTIALS_FULL_URI];
|
|
18
|
-
const token = options.awsContainerAuthorizationToken ?? process.env[AWS_CONTAINER_AUTHORIZATION_TOKEN];
|
|
19
|
-
const tokenFile = options.awsContainerAuthorizationTokenFile ?? process.env[AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE];
|
|
20
|
-
const warn = options.logger?.constructor?.name === "NoOpLogger" || !options.logger?.warn
|
|
21
|
-
? console.warn
|
|
22
|
-
: options.logger.warn.bind(options.logger);
|
|
23
|
-
if (relative && full) {
|
|
24
|
-
warn("@aws-sdk/credential-provider-http: " +
|
|
25
|
-
"you have set both awsContainerCredentialsRelativeUri and awsContainerCredentialsFullUri.");
|
|
26
|
-
warn("awsContainerCredentialsFullUri will take precedence.");
|
|
27
|
-
}
|
|
28
|
-
if (token && tokenFile) {
|
|
29
|
-
warn("@aws-sdk/credential-provider-http: " +
|
|
30
|
-
"you have set both awsContainerAuthorizationToken and awsContainerAuthorizationTokenFile.");
|
|
31
|
-
warn("awsContainerAuthorizationToken will take precedence.");
|
|
32
|
-
}
|
|
33
|
-
if (full) {
|
|
34
|
-
host = full;
|
|
35
|
-
}
|
|
36
|
-
else if (relative) {
|
|
37
|
-
host = `${DEFAULT_LINK_LOCAL_HOST}${relative}`;
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
throw new CredentialsProviderError(`No HTTP credential provider host provided.
|
|
41
|
-
Set AWS_CONTAINER_CREDENTIALS_FULL_URI or AWS_CONTAINER_CREDENTIALS_RELATIVE_URI.`, { logger: options.logger });
|
|
42
|
-
}
|
|
43
|
-
const url = new URL(host);
|
|
44
|
-
checkUrl(url, options.logger);
|
|
45
|
-
const requestHandler = NodeHttpHandler.create({ connectionTimeout: options.timeout ?? 1000 });
|
|
46
|
-
const requestTimeout = options.timeout ?? 1000;
|
|
47
|
-
const provider = retryWrapper(async () => {
|
|
48
|
-
const request = createGetRequest(url);
|
|
49
|
-
if (token) {
|
|
50
|
-
request.headers.Authorization = token;
|
|
51
|
-
}
|
|
52
|
-
else if (tokenFile) {
|
|
53
|
-
request.headers.Authorization = (await fs.readFile(tokenFile)).toString();
|
|
54
|
-
}
|
|
55
|
-
try {
|
|
56
|
-
const result = await requestHandler.handle(request, { requestTimeout });
|
|
57
|
-
return getCredentials(result.response).then((creds) => setCredentialFeature(creds, "CREDENTIALS_HTTP", "z"));
|
|
58
|
-
}
|
|
59
|
-
catch (e) {
|
|
60
|
-
throw new CredentialsProviderError(String(e), { logger: options.logger });
|
|
61
|
-
}
|
|
62
|
-
}, options.maxRetries ?? 3, options.timeout ?? 1000);
|
|
63
|
-
return async () => {
|
|
64
|
-
try {
|
|
65
|
-
return await provider();
|
|
66
|
-
}
|
|
67
|
-
finally {
|
|
68
|
-
requestHandler.destroy?.();
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
};
|
|
@@ -1,49 +0,0 @@
|
|
|
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({
|
|
7
|
-
protocol: url.protocol,
|
|
8
|
-
hostname: url.hostname,
|
|
9
|
-
port: Number(url.port),
|
|
10
|
-
path: url.pathname,
|
|
11
|
-
query: Array.from(url.searchParams.entries()).reduce((acc, [k, v]) => {
|
|
12
|
-
acc[k] = v;
|
|
13
|
-
return acc;
|
|
14
|
-
}, {}),
|
|
15
|
-
fragment: url.hash,
|
|
16
|
-
});
|
|
17
|
-
};
|
|
18
|
-
exports.getCredentials = async function getCredentials(response, logger) {
|
|
19
|
-
const stream = sdkStreamMixin(response.body);
|
|
20
|
-
const str = await stream.transformToString();
|
|
21
|
-
if (response.statusCode === 200) {
|
|
22
|
-
const parsed = JSON.parse(str);
|
|
23
|
-
if (typeof parsed.AccessKeyId !== "string" ||
|
|
24
|
-
typeof parsed.SecretAccessKey !== "string" ||
|
|
25
|
-
typeof parsed.Token !== "string" ||
|
|
26
|
-
typeof parsed.Expiration !== "string") {
|
|
27
|
-
throw new CredentialsProviderError("HTTP credential provider response not of the required format, an object matching: " +
|
|
28
|
-
"{ AccessKeyId: string, SecretAccessKey: string, Token: string, Expiration: string(rfc3339) }", { logger });
|
|
29
|
-
}
|
|
30
|
-
return {
|
|
31
|
-
accessKeyId: parsed.AccessKeyId,
|
|
32
|
-
secretAccessKey: parsed.SecretAccessKey,
|
|
33
|
-
sessionToken: parsed.Token,
|
|
34
|
-
expiration: parseRfc3339DateTime(parsed.Expiration),
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
if (response.statusCode >= 400 && response.statusCode < 500) {
|
|
38
|
-
let parsedBody = {};
|
|
39
|
-
try {
|
|
40
|
-
parsedBody = JSON.parse(str);
|
|
41
|
-
}
|
|
42
|
-
catch (e) { }
|
|
43
|
-
throw Object.assign(new CredentialsProviderError(`Server responded with status: ${response.statusCode}`, { logger }), {
|
|
44
|
-
Code: parsedBody.Code,
|
|
45
|
-
Message: parsedBody.Message,
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
throw new CredentialsProviderError(`Server responded with status: ${response.statusCode}`, { logger });
|
|
49
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
exports.retryWrapper = (toRetry, maxRetries, delayMs) => {
|
|
2
|
-
return async () => {
|
|
3
|
-
for (let i = 0; i < maxRetries; ++i) {
|
|
4
|
-
try {
|
|
5
|
-
return await toRetry();
|
|
6
|
-
}
|
|
7
|
-
catch (e) {
|
|
8
|
-
await new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
return await toRetry();
|
|
12
|
-
};
|
|
13
|
-
};
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
const { setCredentialFeature } = require("@aws-sdk/core/client");
|
|
2
|
-
const { CredentialsProviderError, externalDataInterceptor } = require("@smithy/core/config");
|
|
3
|
-
const { readFileSync } = require("node:fs");
|
|
4
|
-
const { fromWebToken } = require("./fromWebToken");
|
|
5
|
-
const ENV_TOKEN_FILE = "AWS_WEB_IDENTITY_TOKEN_FILE";
|
|
6
|
-
const ENV_ROLE_ARN = "AWS_ROLE_ARN";
|
|
7
|
-
const ENV_ROLE_SESSION_NAME = "AWS_ROLE_SESSION_NAME";
|
|
8
|
-
exports.fromTokenFile = (init = {}) => async (awsIdentityProperties) => {
|
|
9
|
-
init.logger?.debug("@aws-sdk/credential-provider-web-identity - fromTokenFile");
|
|
10
|
-
const webIdentityTokenFile = init?.webIdentityTokenFile ?? process.env[ENV_TOKEN_FILE];
|
|
11
|
-
const roleArn = init?.roleArn ?? process.env[ENV_ROLE_ARN];
|
|
12
|
-
const roleSessionName = init?.roleSessionName ?? process.env[ENV_ROLE_SESSION_NAME];
|
|
13
|
-
if (!webIdentityTokenFile || !roleArn) {
|
|
14
|
-
throw new CredentialsProviderError("Web identity configuration not specified", {
|
|
15
|
-
logger: init.logger,
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
const credentials = await fromWebToken({
|
|
19
|
-
...init,
|
|
20
|
-
webIdentityToken: externalDataInterceptor?.getTokenRecord?.()[webIdentityTokenFile] ??
|
|
21
|
-
readFileSync(webIdentityTokenFile, { encoding: "ascii" }),
|
|
22
|
-
roleArn,
|
|
23
|
-
roleSessionName,
|
|
24
|
-
})(awsIdentityProperties);
|
|
25
|
-
if (webIdentityTokenFile === process.env[ENV_TOKEN_FILE]) {
|
|
26
|
-
setCredentialFeature(credentials, "CREDENTIALS_ENV_VARS_STS_WEB_ID_TOKEN", "h");
|
|
27
|
-
}
|
|
28
|
-
return credentials;
|
|
29
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
exports.fromWebToken = (init) => async (awsIdentityProperties) => {
|
|
2
|
-
init.logger?.debug("@aws-sdk/credential-provider-web-identity - fromWebToken");
|
|
3
|
-
const { roleArn, roleSessionName, webIdentityToken, providerId, policyArns, policy, durationSeconds } = init;
|
|
4
|
-
let { roleAssumerWithWebIdentity } = init;
|
|
5
|
-
if (!roleAssumerWithWebIdentity) {
|
|
6
|
-
const { getDefaultRoleAssumerWithWebIdentity } = require("@aws-sdk/nested-clients/sts");
|
|
7
|
-
roleAssumerWithWebIdentity = getDefaultRoleAssumerWithWebIdentity({
|
|
8
|
-
...init.clientConfig,
|
|
9
|
-
credentialProviderLogger: init.logger,
|
|
10
|
-
parentClientConfig: {
|
|
11
|
-
...awsIdentityProperties?.callerClientConfig,
|
|
12
|
-
...init.parentClientConfig,
|
|
13
|
-
},
|
|
14
|
-
}, init.clientPlugins);
|
|
15
|
-
}
|
|
16
|
-
return roleAssumerWithWebIdentity({
|
|
17
|
-
RoleArn: roleArn,
|
|
18
|
-
RoleSessionName: roleSessionName ?? `aws-sdk-js-session-${Date.now()}`,
|
|
19
|
-
WebIdentityToken: webIdentityToken,
|
|
20
|
-
ProviderId: providerId,
|
|
21
|
-
PolicyArns: policyArns,
|
|
22
|
-
Policy: policy,
|
|
23
|
-
DurationSeconds: durationSeconds,
|
|
24
|
-
});
|
|
25
|
-
};
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
let parser;
|
|
2
|
-
exports.parseXML = function parseXML(xmlString) {
|
|
3
|
-
if (!parser) {
|
|
4
|
-
parser = new DOMParser();
|
|
5
|
-
}
|
|
6
|
-
const xmlDocument = parser.parseFromString(xmlString, "application/xml");
|
|
7
|
-
if (xmlDocument.getElementsByTagName("parsererror").length > 0) {
|
|
8
|
-
throw new Error("DOMParser XML parsing error.");
|
|
9
|
-
}
|
|
10
|
-
const xmlToObj = (node) => {
|
|
11
|
-
if (node.nodeType === Node.TEXT_NODE) {
|
|
12
|
-
if (node.textContent?.trim()) {
|
|
13
|
-
return node.textContent;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
if (node.nodeType === Node.ELEMENT_NODE) {
|
|
17
|
-
const element = node;
|
|
18
|
-
if (element.attributes.length === 0 && element.childNodes.length === 0) {
|
|
19
|
-
return "";
|
|
20
|
-
}
|
|
21
|
-
const obj = {};
|
|
22
|
-
const attributes = Array.from(element.attributes);
|
|
23
|
-
for (const attr of attributes) {
|
|
24
|
-
obj[`${attr.name}`] = attr.value;
|
|
25
|
-
}
|
|
26
|
-
const childNodes = Array.from(element.childNodes);
|
|
27
|
-
for (const child of childNodes) {
|
|
28
|
-
const childResult = xmlToObj(child);
|
|
29
|
-
if (childResult != null) {
|
|
30
|
-
const childName = child.nodeName;
|
|
31
|
-
if (childNodes.length === 1 && attributes.length === 0 && childName === "#text") {
|
|
32
|
-
return childResult;
|
|
33
|
-
}
|
|
34
|
-
if (childName in obj) {
|
|
35
|
-
if (Array.isArray(obj[childName])) {
|
|
36
|
-
obj[childName].push(childResult);
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
obj[childName] = [obj[childName], childResult];
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
obj[childName] = childResult;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
else if (childNodes.length === 1 && attributes.length === 0) {
|
|
47
|
-
return element.textContent;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
return obj;
|
|
51
|
-
}
|
|
52
|
-
return null;
|
|
53
|
-
};
|
|
54
|
-
return {
|
|
55
|
-
[xmlDocument.documentElement.nodeName]: xmlToObj(xmlDocument.documentElement),
|
|
56
|
-
};
|
|
57
|
-
};
|
|
@@ -1,234 +0,0 @@
|
|
|
1
|
-
exports.parseXML = function parseXML(xml) {
|
|
2
|
-
const state = new AwsXmlParser(xml);
|
|
3
|
-
return state.parse();
|
|
4
|
-
};
|
|
5
|
-
class AwsXmlParser {
|
|
6
|
-
x;
|
|
7
|
-
i = 0;
|
|
8
|
-
z;
|
|
9
|
-
constructor(x) {
|
|
10
|
-
this.x = x;
|
|
11
|
-
this.x = x.replace(/\r\n?/g, "\n");
|
|
12
|
-
this.z = this.x.length;
|
|
13
|
-
}
|
|
14
|
-
parse() {
|
|
15
|
-
const p = this;
|
|
16
|
-
const { z } = p;
|
|
17
|
-
while (p.i < z) {
|
|
18
|
-
p.trim();
|
|
19
|
-
if (p.i >= z) {
|
|
20
|
-
break;
|
|
21
|
-
}
|
|
22
|
-
if (p.isNext("<?")) {
|
|
23
|
-
p.readTo("?>");
|
|
24
|
-
p.trim();
|
|
25
|
-
}
|
|
26
|
-
else if (p.isNext("<!--")) {
|
|
27
|
-
p.readTo("-->");
|
|
28
|
-
p.trim();
|
|
29
|
-
}
|
|
30
|
-
else if (p.isNext("<!DOCTYPE", false)) {
|
|
31
|
-
p.skipDoctype();
|
|
32
|
-
p.trim();
|
|
33
|
-
}
|
|
34
|
-
else if (p.x[p.i] === "<") {
|
|
35
|
-
const root = p.parseTag();
|
|
36
|
-
return { [root.tag]: root.value };
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
throw new Error("@aws-sdk XML parse error: unexpected content.");
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
throw new Error("@aws-sdk XML parse error: no root element.");
|
|
43
|
-
}
|
|
44
|
-
isNext(s, caseSensitive = true) {
|
|
45
|
-
const p = this;
|
|
46
|
-
if (caseSensitive) {
|
|
47
|
-
return p.x.startsWith(s, p.i);
|
|
48
|
-
}
|
|
49
|
-
return p.x.toLowerCase().startsWith(s.toLowerCase(), p.i);
|
|
50
|
-
}
|
|
51
|
-
readTo(stop) {
|
|
52
|
-
const p = this;
|
|
53
|
-
const _i = p.x.indexOf(stop, p.i);
|
|
54
|
-
if (_i === -1) {
|
|
55
|
-
throw new Error(`@aws-sdk XML parse error: expected "${stop}" not found.`);
|
|
56
|
-
}
|
|
57
|
-
const result = p.x.slice(p.i, _i);
|
|
58
|
-
p.i = _i + stop.length;
|
|
59
|
-
return result;
|
|
60
|
-
}
|
|
61
|
-
trim() {
|
|
62
|
-
const p = this;
|
|
63
|
-
while (p.i < p.z && " \t\r\n".includes(p.x[p.i])) {
|
|
64
|
-
++p.i;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
readAttrValue() {
|
|
68
|
-
const p = this;
|
|
69
|
-
const quote = p.x[p.i];
|
|
70
|
-
++p.i;
|
|
71
|
-
let value = "";
|
|
72
|
-
while (p.i < p.z && p.x[p.i] !== quote) {
|
|
73
|
-
value += p.x[p.i++];
|
|
74
|
-
}
|
|
75
|
-
++p.i;
|
|
76
|
-
return p.decodeEntities(value);
|
|
77
|
-
}
|
|
78
|
-
parseTag() {
|
|
79
|
-
const p = this;
|
|
80
|
-
++p.i;
|
|
81
|
-
let tag = "";
|
|
82
|
-
while (p.i < p.z && !" \t\r\n>/".includes(p.x[p.i])) {
|
|
83
|
-
tag += p.x[p.i++];
|
|
84
|
-
}
|
|
85
|
-
let hasAttrs = false;
|
|
86
|
-
const attrs = Object.create(null);
|
|
87
|
-
while (p.i < p.z) {
|
|
88
|
-
p.trim();
|
|
89
|
-
if (">/".includes(p.x[p.i])) {
|
|
90
|
-
break;
|
|
91
|
-
}
|
|
92
|
-
let name = "";
|
|
93
|
-
while (p.i < p.z && !"= \t\r\n>/?".includes(p.x[p.i])) {
|
|
94
|
-
name += p.x[p.i++];
|
|
95
|
-
}
|
|
96
|
-
p.trim();
|
|
97
|
-
if (p.x[p.i] !== "=") {
|
|
98
|
-
break;
|
|
99
|
-
}
|
|
100
|
-
++p.i;
|
|
101
|
-
p.trim();
|
|
102
|
-
attrs[name] = p.readAttrValue();
|
|
103
|
-
hasAttrs = true;
|
|
104
|
-
}
|
|
105
|
-
if (p.i >= p.z) {
|
|
106
|
-
throw new Error("@aws-sdk XML parse error: unexpected end of input.");
|
|
107
|
-
}
|
|
108
|
-
if (p.x[p.i] === "/") {
|
|
109
|
-
++p.i;
|
|
110
|
-
if (p.i >= p.z || p.x[p.i] !== ">") {
|
|
111
|
-
throw new Error("@aws-sdk XML parse error: expected > at the end of self-closing tag.");
|
|
112
|
-
}
|
|
113
|
-
++p.i;
|
|
114
|
-
Object.setPrototypeOf(attrs, Object.prototype);
|
|
115
|
-
return { tag, value: hasAttrs ? attrs : "" };
|
|
116
|
-
}
|
|
117
|
-
if (p.x[p.i] !== ">") {
|
|
118
|
-
throw new Error("@aws-sdk XML parse error: expected > at the end of opening tag.");
|
|
119
|
-
}
|
|
120
|
-
++p.i;
|
|
121
|
-
const textParts = [];
|
|
122
|
-
const childTags = [];
|
|
123
|
-
let hasElementChild = false;
|
|
124
|
-
while (p.i < p.z) {
|
|
125
|
-
if (p.isNext("</")) {
|
|
126
|
-
break;
|
|
127
|
-
}
|
|
128
|
-
if (p.x[p.i] === "<") {
|
|
129
|
-
if (p.isNext("<!--")) {
|
|
130
|
-
p.readTo("-->");
|
|
131
|
-
}
|
|
132
|
-
else if (p.isNext("<![CDATA[")) {
|
|
133
|
-
p.i += 9;
|
|
134
|
-
textParts.push(p.readTo("]]>"));
|
|
135
|
-
}
|
|
136
|
-
else if (p.isNext("<?")) {
|
|
137
|
-
p.readTo("?>");
|
|
138
|
-
}
|
|
139
|
-
else {
|
|
140
|
-
hasElementChild = true;
|
|
141
|
-
childTags.push(p.parseTag());
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
else {
|
|
145
|
-
let text = "";
|
|
146
|
-
while (p.i < p.z && p.x[p.i] !== "<") {
|
|
147
|
-
text += p.x[p.i++];
|
|
148
|
-
}
|
|
149
|
-
textParts.push(p.decodeEntities(text));
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
if (!p.isNext("</")) {
|
|
153
|
-
throw new Error(`@aws-sdk XML parse error: missing closing tag </${tag}>.`);
|
|
154
|
-
}
|
|
155
|
-
p.i += 2;
|
|
156
|
-
const closeTag = p.readTo(">").trim();
|
|
157
|
-
if (closeTag !== tag) {
|
|
158
|
-
throw new Error(`@aws-sdk XML parse error: mismatched tags <${tag}> and </${closeTag}>.`);
|
|
159
|
-
}
|
|
160
|
-
if (!hasAttrs && textParts.length === 0 && !hasElementChild) {
|
|
161
|
-
return { tag, value: "" };
|
|
162
|
-
}
|
|
163
|
-
if (!hasAttrs && !hasElementChild) {
|
|
164
|
-
const text = textParts.length === 1 ? textParts[0] : textParts.join("");
|
|
165
|
-
if (text.trim() === "" && text.includes("\n")) {
|
|
166
|
-
return { tag, value: "" };
|
|
167
|
-
}
|
|
168
|
-
return { tag, value: text };
|
|
169
|
-
}
|
|
170
|
-
const obj = Object.create(null);
|
|
171
|
-
for (const text of textParts) {
|
|
172
|
-
if (text.trim() === "" && text.includes("\n")) {
|
|
173
|
-
continue;
|
|
174
|
-
}
|
|
175
|
-
obj["#text"] = "#text" in obj ? obj["#text"] + text : text;
|
|
176
|
-
}
|
|
177
|
-
for (const child of childTags) {
|
|
178
|
-
if (child.tag in obj) {
|
|
179
|
-
if (Array.isArray(obj[child.tag])) {
|
|
180
|
-
obj[child.tag].push(child.value);
|
|
181
|
-
}
|
|
182
|
-
else {
|
|
183
|
-
obj[child.tag] = [obj[child.tag], child.value];
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
else {
|
|
187
|
-
obj[child.tag] = child.value;
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
for (const [k, v] of Object.entries(attrs)) {
|
|
191
|
-
obj[k] = v;
|
|
192
|
-
}
|
|
193
|
-
Object.setPrototypeOf(obj, Object.prototype);
|
|
194
|
-
return { tag, value: obj };
|
|
195
|
-
}
|
|
196
|
-
static ENTITIES = {
|
|
197
|
-
amp: "&",
|
|
198
|
-
lt: "<",
|
|
199
|
-
gt: ">",
|
|
200
|
-
quot: '"',
|
|
201
|
-
apos: "'",
|
|
202
|
-
};
|
|
203
|
-
skipDoctype() {
|
|
204
|
-
const p = this;
|
|
205
|
-
p.i += 9;
|
|
206
|
-
let depth = 0;
|
|
207
|
-
while (p.i < p.z) {
|
|
208
|
-
const c = p.x[p.i];
|
|
209
|
-
if (c === "[") {
|
|
210
|
-
++depth;
|
|
211
|
-
}
|
|
212
|
-
else if (c === "]") {
|
|
213
|
-
--depth;
|
|
214
|
-
}
|
|
215
|
-
else if (c === ">" && depth === 0) {
|
|
216
|
-
++p.i;
|
|
217
|
-
return;
|
|
218
|
-
}
|
|
219
|
-
++p.i;
|
|
220
|
-
}
|
|
221
|
-
throw new Error("@aws-sdk XML parse error: unclosed DOCTYPE.");
|
|
222
|
-
}
|
|
223
|
-
decodeEntities(s) {
|
|
224
|
-
return s.replace(/&(?:#x([0-9a-fA-F]{1,6})|#(\d{1,7})|([a-zA-Z][a-zA-Z0-9]{0,30}));/g, (_, hex, dec, named) => {
|
|
225
|
-
if (hex) {
|
|
226
|
-
return String.fromCharCode(parseInt(hex, 16));
|
|
227
|
-
}
|
|
228
|
-
if (dec) {
|
|
229
|
-
return String.fromCharCode(parseInt(dec, 10));
|
|
230
|
-
}
|
|
231
|
-
return AwsXmlParser.ENTITIES[named] ?? "";
|
|
232
|
-
});
|
|
233
|
-
}
|
|
234
|
-
}
|