@aws-sdk/core 3.974.9 → 3.974.11
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/dist-cjs/index.js +4 -6
- package/dist-cjs/submodules/client/index.browser.js +595 -0
- package/dist-cjs/submodules/client/index.js +715 -0
- package/dist-cjs/submodules/client/index.native.js +588 -0
- package/dist-es/index.js +3 -3
- package/dist-es/submodules/client/index.browser.js +36 -0
- package/dist-es/submodules/client/index.js +26 -4
- package/dist-es/submodules/client/index.native.js +37 -0
- package/dist-es/submodules/client/middleware-host-header/hostHeaderMiddleware.js +33 -0
- package/dist-es/submodules/client/middleware-logger/loggerMiddleware.js +42 -0
- package/dist-es/submodules/client/middleware-recursion-detection/configuration.js +7 -0
- package/dist-es/submodules/client/middleware-recursion-detection/getRecursionDetectionPlugin.browser.js +3 -0
- package/dist-es/submodules/client/middleware-recursion-detection/getRecursionDetectionPlugin.js +7 -0
- package/dist-es/submodules/client/middleware-recursion-detection/recursionDetectionMiddleware.browser.js +1 -0
- package/dist-es/submodules/client/middleware-recursion-detection/recursionDetectionMiddleware.js +29 -0
- package/dist-es/submodules/client/middleware-recursion-detection/recursionDetectionMiddleware.native.js +1 -0
- package/dist-es/submodules/client/middleware-user-agent/check-features.js +49 -0
- package/dist-es/submodules/client/middleware-user-agent/configurations.js +28 -0
- package/dist-es/submodules/client/middleware-user-agent/constants.js +7 -0
- package/dist-es/submodules/client/middleware-user-agent/encode-features.js +18 -0
- package/dist-es/submodules/client/middleware-user-agent/user-agent-middleware.js +82 -0
- package/dist-es/submodules/client/region-config-resolver/awsRegionConfig.js +2 -0
- package/dist-es/submodules/client/region-config-resolver/extensions.js +15 -0
- package/dist-es/submodules/client/region-config-resolver/stsRegionDefaultResolver.browser.js +3 -0
- package/dist-es/submodules/client/region-config-resolver/stsRegionDefaultResolver.js +15 -0
- package/dist-es/submodules/client/region-config-resolver/stsRegionDefaultResolver.native.js +3 -0
- package/dist-es/submodules/client/util-endpoints/aws.js +10 -0
- package/dist-es/submodules/client/util-endpoints/lib/aws/isVirtualHostableS3Bucket.js +25 -0
- package/dist-es/submodules/client/util-endpoints/lib/aws/parseArn.js +18 -0
- package/dist-es/submodules/client/util-endpoints/lib/aws/partition.js +41 -0
- package/dist-es/submodules/client/util-endpoints/lib/aws/partitions.js +1 -0
- package/dist-es/submodules/client/util-endpoints/lib/isIpAddress.js +1 -0
- package/dist-es/submodules/client/util-endpoints/resolveDefaultAwsRegionalEndpointsConfig.js +21 -0
- package/dist-es/submodules/client/util-endpoints/resolveEndpoint.js +1 -0
- package/dist-es/submodules/client/util-endpoints/types/EndpointError.js +1 -0
- package/dist-es/submodules/client/util-endpoints/types/EndpointRuleObject.js +1 -0
- package/dist-es/submodules/client/util-endpoints/types/ErrorRuleObject.js +1 -0
- package/dist-es/submodules/client/util-endpoints/types/RuleSetObject.js +1 -0
- package/dist-es/submodules/client/util-endpoints/types/TreeRuleObject.js +1 -0
- package/dist-es/submodules/client/util-endpoints/types/shared.js +1 -0
- package/dist-es/submodules/client/util-user-agent-browser/configurations.js +1 -0
- package/dist-es/submodules/client/util-user-agent-browser/createUserAgentStringParsingProvider.js +20 -0
- package/dist-es/submodules/client/util-user-agent-browser/defaultUserAgent.browser.js +1 -0
- package/dist-es/submodules/client/util-user-agent-browser/defaultUserAgent.js +53 -0
- package/dist-es/submodules/client/util-user-agent-browser/defaultUserAgent.native.js +18 -0
- package/dist-es/submodules/client/util-user-agent-node/crt-availability.js +3 -0
- package/dist-es/submodules/client/util-user-agent-node/defaultUserAgent.js +36 -0
- package/dist-es/submodules/client/util-user-agent-node/getNodeModulesParentDirs.js +15 -0
- package/dist-es/submodules/client/util-user-agent-node/getRuntimeUserAgentPair.js +10 -0
- package/dist-es/submodules/client/util-user-agent-node/getSanitizedDevTypeScriptVersion.js +14 -0
- package/dist-es/submodules/client/util-user-agent-node/getSanitizedTypeScriptVersion.js +9 -0
- package/dist-es/submodules/client/util-user-agent-node/getTypeScriptUserAgentPair.js +75 -0
- package/dist-es/submodules/client/util-user-agent-node/is-crt-available.js +7 -0
- package/dist-es/submodules/client/util-user-agent-node/nodeAppIdConfigOptions.js +9 -0
- package/dist-types/api-extractor-type-index.d.ts +3 -2
- package/dist-types/index.d.ts +12 -14
- package/dist-types/submodules/client/index.browser.d.ts +47 -0
- package/dist-types/submodules/client/index.d.ts +38 -4
- package/dist-types/submodules/client/index.native.d.ts +48 -0
- package/dist-types/submodules/client/middleware-host-header/hostHeaderMiddleware.d.ts +35 -0
- package/dist-types/submodules/client/middleware-logger/loggerMiddleware.d.ts +4 -0
- package/dist-types/submodules/client/middleware-recursion-detection/configuration.d.ts +5 -0
- package/dist-types/submodules/client/middleware-recursion-detection/getRecursionDetectionPlugin.browser.d.ts +5 -0
- package/dist-types/submodules/client/middleware-recursion-detection/getRecursionDetectionPlugin.d.ts +5 -0
- package/dist-types/submodules/client/middleware-recursion-detection/recursionDetectionMiddleware.browser.d.ts +6 -0
- package/dist-types/submodules/client/middleware-recursion-detection/recursionDetectionMiddleware.d.ts +6 -0
- package/dist-types/submodules/client/middleware-recursion-detection/recursionDetectionMiddleware.native.d.ts +6 -0
- package/dist-types/submodules/client/middleware-user-agent/check-features.d.ts +20 -0
- package/dist-types/submodules/client/middleware-user-agent/configurations.d.ts +44 -0
- package/dist-types/submodules/client/middleware-user-agent/constants.d.ts +7 -0
- package/dist-types/submodules/client/middleware-user-agent/encode-features.d.ts +5 -0
- package/dist-types/submodules/client/middleware-user-agent/user-agent-middleware.d.ts +18 -0
- package/dist-types/submodules/client/region-config-resolver/awsRegionConfig.d.ts +15 -0
- package/dist-types/submodules/client/region-config-resolver/extensions.d.ts +16 -0
- package/dist-types/submodules/client/region-config-resolver/stsRegionDefaultResolver.browser.d.ts +4 -0
- package/dist-types/submodules/client/region-config-resolver/stsRegionDefaultResolver.d.ts +14 -0
- package/dist-types/submodules/client/region-config-resolver/stsRegionDefaultResolver.native.d.ts +4 -0
- package/dist-types/submodules/client/util-endpoints/aws.d.ts +2 -0
- package/dist-types/submodules/client/util-endpoints/lib/aws/isVirtualHostableS3Bucket.d.ts +5 -0
- package/dist-types/submodules/client/util-endpoints/lib/aws/parseArn.d.ts +7 -0
- package/dist-types/submodules/client/util-endpoints/lib/aws/partition.d.ts +38 -0
- package/dist-types/submodules/client/util-endpoints/lib/aws/partitions.d.ts +638 -0
- package/dist-types/submodules/client/util-endpoints/lib/isIpAddress.d.ts +1 -0
- package/dist-types/submodules/client/util-endpoints/resolveDefaultAwsRegionalEndpointsConfig.d.ts +56 -0
- package/dist-types/submodules/client/util-endpoints/resolveEndpoint.d.ts +1 -0
- package/dist-types/submodules/client/util-endpoints/types/EndpointError.d.ts +1 -0
- package/dist-types/submodules/client/util-endpoints/types/EndpointRuleObject.d.ts +1 -0
- package/dist-types/submodules/client/util-endpoints/types/ErrorRuleObject.d.ts +1 -0
- package/dist-types/submodules/client/util-endpoints/types/RuleSetObject.d.ts +1 -0
- package/dist-types/submodules/client/util-endpoints/types/TreeRuleObject.d.ts +1 -0
- package/dist-types/submodules/client/util-endpoints/types/shared.d.ts +1 -0
- package/dist-types/submodules/client/util-user-agent-browser/configurations.d.ts +7 -0
- package/dist-types/submodules/client/util-user-agent-browser/createUserAgentStringParsingProvider.d.ts +14 -0
- package/dist-types/submodules/client/util-user-agent-browser/defaultUserAgent.browser.d.ts +1 -0
- package/dist-types/submodules/client/util-user-agent-browser/defaultUserAgent.d.ts +27 -0
- package/dist-types/submodules/client/util-user-agent-browser/defaultUserAgent.native.d.ts +18 -0
- package/dist-types/submodules/client/util-user-agent-node/crt-availability.d.ts +8 -0
- package/dist-types/submodules/client/util-user-agent-node/defaultUserAgent.d.ts +28 -0
- package/dist-types/submodules/client/util-user-agent-node/getNodeModulesParentDirs.d.ts +10 -0
- package/dist-types/submodules/client/util-user-agent-node/getRuntimeUserAgentPair.d.ts +6 -0
- package/dist-types/submodules/client/util-user-agent-node/getSanitizedDevTypeScriptVersion.d.ts +8 -0
- package/dist-types/submodules/client/util-user-agent-node/getSanitizedTypeScriptVersion.d.ts +8 -0
- package/dist-types/submodules/client/util-user-agent-node/getTypeScriptUserAgentPair.d.ts +6 -0
- package/dist-types/submodules/client/util-user-agent-node/is-crt-available.d.ts +5 -0
- package/dist-types/submodules/client/util-user-agent-node/nodeAppIdConfigOptions.d.ts +13 -0
- package/dist-types/ts3.4/api-extractor-type-index.d.ts +0 -2
- package/dist-types/ts3.4/index.d.ts +65 -3
- package/dist-types/ts3.4/submodules/client/index.browser.d.ts +116 -0
- package/dist-types/ts3.4/submodules/client/index.d.ts +123 -4
- package/dist-types/ts3.4/submodules/client/index.native.d.ts +116 -0
- package/dist-types/ts3.4/submodules/client/middleware-host-header/hostHeaderMiddleware.d.ts +29 -0
- package/dist-types/ts3.4/submodules/client/middleware-logger/loggerMiddleware.d.ts +17 -0
- package/dist-types/ts3.4/submodules/client/middleware-recursion-detection/configuration.d.ts +3 -0
- package/dist-types/ts3.4/submodules/client/middleware-recursion-detection/getRecursionDetectionPlugin.browser.d.ts +4 -0
- package/dist-types/ts3.4/submodules/client/middleware-recursion-detection/getRecursionDetectionPlugin.d.ts +4 -0
- package/dist-types/ts3.4/submodules/client/middleware-recursion-detection/recursionDetectionMiddleware.browser.d.ts +5 -0
- package/dist-types/ts3.4/submodules/client/middleware-recursion-detection/recursionDetectionMiddleware.d.ts +5 -0
- package/dist-types/ts3.4/submodules/client/middleware-recursion-detection/recursionDetectionMiddleware.native.d.ts +5 -0
- package/dist-types/ts3.4/submodules/client/middleware-user-agent/check-features.d.ts +20 -0
- package/dist-types/ts3.4/submodules/client/middleware-user-agent/configurations.d.ts +21 -0
- package/dist-types/ts3.4/submodules/client/middleware-user-agent/constants.d.ts +7 -0
- package/dist-types/ts3.4/submodules/client/middleware-user-agent/encode-features.d.ts +2 -0
- package/dist-types/ts3.4/submodules/client/middleware-user-agent/user-agent-middleware.d.ts +21 -0
- package/dist-types/ts3.4/submodules/client/region-config-resolver/awsRegionConfig.d.ts +8 -0
- package/dist-types/ts3.4/submodules/client/region-config-resolver/extensions.d.ts +14 -0
- package/dist-types/ts3.4/submodules/client/region-config-resolver/stsRegionDefaultResolver.browser.d.ts +1 -0
- package/dist-types/ts3.4/submodules/client/region-config-resolver/stsRegionDefaultResolver.d.ts +7 -0
- package/dist-types/ts3.4/submodules/client/region-config-resolver/stsRegionDefaultResolver.native.d.ts +1 -0
- package/dist-types/ts3.4/submodules/client/util-endpoints/aws.d.ts +2 -0
- package/dist-types/ts3.4/submodules/client/util-endpoints/lib/aws/isVirtualHostableS3Bucket.d.ts +4 -0
- package/dist-types/ts3.4/submodules/client/util-endpoints/lib/aws/parseArn.d.ts +2 -0
- package/dist-types/ts3.4/submodules/client/util-endpoints/lib/aws/partition.d.ts +28 -0
- package/dist-types/ts3.4/submodules/client/util-endpoints/lib/aws/partitions.d.ts +647 -0
- package/dist-types/ts3.4/submodules/client/util-endpoints/lib/isIpAddress.d.ts +1 -0
- package/dist-types/ts3.4/submodules/client/util-endpoints/resolveDefaultAwsRegionalEndpointsConfig.d.ts +35 -0
- package/dist-types/ts3.4/submodules/client/util-endpoints/resolveEndpoint.d.ts +1 -0
- package/dist-types/ts3.4/submodules/client/util-endpoints/types/EndpointError.d.ts +1 -0
- package/dist-types/ts3.4/submodules/client/util-endpoints/types/EndpointRuleObject.d.ts +6 -0
- package/dist-types/ts3.4/submodules/client/util-endpoints/types/ErrorRuleObject.d.ts +1 -0
- package/dist-types/ts3.4/submodules/client/util-endpoints/types/RuleSetObject.d.ts +5 -0
- package/dist-types/ts3.4/submodules/client/util-endpoints/types/TreeRuleObject.d.ts +1 -0
- package/dist-types/ts3.4/submodules/client/util-endpoints/types/shared.d.ts +12 -0
- package/dist-types/ts3.4/submodules/client/util-user-agent-browser/configurations.d.ts +4 -0
- package/dist-types/ts3.4/submodules/client/util-user-agent-browser/createUserAgentStringParsingProvider.d.ts +9 -0
- package/dist-types/ts3.4/submodules/client/util-user-agent-browser/defaultUserAgent.browser.d.ts +1 -0
- package/dist-types/ts3.4/submodules/client/util-user-agent-browser/defaultUserAgent.d.ts +22 -0
- package/dist-types/ts3.4/submodules/client/util-user-agent-browser/defaultUserAgent.native.d.ts +17 -0
- package/dist-types/ts3.4/submodules/client/util-user-agent-node/crt-availability.d.ts +3 -0
- package/dist-types/ts3.4/submodules/client/util-user-agent-node/defaultUserAgent.d.ts +21 -0
- package/dist-types/ts3.4/submodules/client/util-user-agent-node/getNodeModulesParentDirs.d.ts +1 -0
- package/dist-types/ts3.4/submodules/client/util-user-agent-node/getRuntimeUserAgentPair.d.ts +2 -0
- package/dist-types/ts3.4/submodules/client/util-user-agent-node/getSanitizedDevTypeScriptVersion.d.ts +3 -0
- package/dist-types/ts3.4/submodules/client/util-user-agent-node/getSanitizedTypeScriptVersion.d.ts +3 -0
- package/dist-types/ts3.4/submodules/client/util-user-agent-node/getTypeScriptUserAgentPair.d.ts +4 -0
- package/dist-types/ts3.4/submodules/client/util-user-agent-node/is-crt-available.d.ts +2 -0
- package/dist-types/ts3.4/submodules/client/util-user-agent-node/nodeAppIdConfigOptions.d.ts +6 -0
- package/package.json +27 -8
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var retry = require('@smithy/core/retry');
|
|
4
|
+
var protocols = require('@smithy/core/protocols');
|
|
5
|
+
var lambdaInvokeStore = require('@aws/lambda-invoke-store');
|
|
6
|
+
var core = require('@smithy/core');
|
|
7
|
+
var node_os = require('node:os');
|
|
8
|
+
var node_process = require('node:process');
|
|
9
|
+
var config = require('@smithy/core/config');
|
|
10
|
+
var promises = require('node:fs/promises');
|
|
11
|
+
var node_path = require('node:path');
|
|
12
|
+
var endpoints = require('@smithy/core/endpoints');
|
|
4
13
|
|
|
5
14
|
const state = {
|
|
6
15
|
warningEmitted: false,
|
|
@@ -72,9 +81,715 @@ function setTokenFeature(token, feature, value) {
|
|
|
72
81
|
return token;
|
|
73
82
|
}
|
|
74
83
|
|
|
84
|
+
function resolveHostHeaderConfig(input) {
|
|
85
|
+
return input;
|
|
86
|
+
}
|
|
87
|
+
const hostHeaderMiddleware = (options) => (next) => async (args) => {
|
|
88
|
+
if (!protocols.HttpRequest.isInstance(args.request))
|
|
89
|
+
return next(args);
|
|
90
|
+
const { request } = args;
|
|
91
|
+
const { handlerProtocol = "" } = options.requestHandler.metadata || {};
|
|
92
|
+
if (handlerProtocol.indexOf("h2") >= 0 && !request.headers[":authority"]) {
|
|
93
|
+
delete request.headers["host"];
|
|
94
|
+
request.headers[":authority"] = request.hostname + (request.port ? ":" + request.port : "");
|
|
95
|
+
}
|
|
96
|
+
else if (!request.headers["host"]) {
|
|
97
|
+
let host = request.hostname;
|
|
98
|
+
if (request.port != null)
|
|
99
|
+
host += `:${request.port}`;
|
|
100
|
+
request.headers["host"] = host;
|
|
101
|
+
}
|
|
102
|
+
return next(args);
|
|
103
|
+
};
|
|
104
|
+
const hostHeaderMiddlewareOptions = {
|
|
105
|
+
name: "hostHeaderMiddleware",
|
|
106
|
+
step: "build",
|
|
107
|
+
priority: "low",
|
|
108
|
+
tags: ["HOST"],
|
|
109
|
+
override: true,
|
|
110
|
+
};
|
|
111
|
+
const getHostHeaderPlugin = (options) => ({
|
|
112
|
+
applyToStack: (clientStack) => {
|
|
113
|
+
clientStack.add(hostHeaderMiddleware(options), hostHeaderMiddlewareOptions);
|
|
114
|
+
},
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
const loggerMiddleware = () => (next, context) => async (args) => {
|
|
118
|
+
try {
|
|
119
|
+
const response = await next(args);
|
|
120
|
+
const { clientName, commandName, logger, dynamoDbDocumentClientOptions = {} } = context;
|
|
121
|
+
const { overrideInputFilterSensitiveLog, overrideOutputFilterSensitiveLog } = dynamoDbDocumentClientOptions;
|
|
122
|
+
const inputFilterSensitiveLog = overrideInputFilterSensitiveLog ?? context.inputFilterSensitiveLog;
|
|
123
|
+
const outputFilterSensitiveLog = overrideOutputFilterSensitiveLog ?? context.outputFilterSensitiveLog;
|
|
124
|
+
const { $metadata, ...outputWithoutMetadata } = response.output;
|
|
125
|
+
logger?.info?.({
|
|
126
|
+
clientName,
|
|
127
|
+
commandName,
|
|
128
|
+
input: inputFilterSensitiveLog(args.input),
|
|
129
|
+
output: outputFilterSensitiveLog(outputWithoutMetadata),
|
|
130
|
+
metadata: $metadata,
|
|
131
|
+
});
|
|
132
|
+
return response;
|
|
133
|
+
}
|
|
134
|
+
catch (error) {
|
|
135
|
+
const { clientName, commandName, logger, dynamoDbDocumentClientOptions = {} } = context;
|
|
136
|
+
const { overrideInputFilterSensitiveLog } = dynamoDbDocumentClientOptions;
|
|
137
|
+
const inputFilterSensitiveLog = overrideInputFilterSensitiveLog ?? context.inputFilterSensitiveLog;
|
|
138
|
+
logger?.error?.({
|
|
139
|
+
clientName,
|
|
140
|
+
commandName,
|
|
141
|
+
input: inputFilterSensitiveLog(args.input),
|
|
142
|
+
error,
|
|
143
|
+
metadata: error.$metadata,
|
|
144
|
+
});
|
|
145
|
+
throw error;
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
const loggerMiddlewareOptions = {
|
|
149
|
+
name: "loggerMiddleware",
|
|
150
|
+
tags: ["LOGGER"],
|
|
151
|
+
step: "initialize",
|
|
152
|
+
override: true,
|
|
153
|
+
};
|
|
154
|
+
const getLoggerPlugin = (options) => ({
|
|
155
|
+
applyToStack: (clientStack) => {
|
|
156
|
+
clientStack.add(loggerMiddleware(), loggerMiddlewareOptions);
|
|
157
|
+
},
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
const recursionDetectionMiddlewareOptions = {
|
|
161
|
+
step: "build",
|
|
162
|
+
tags: ["RECURSION_DETECTION"],
|
|
163
|
+
name: "recursionDetectionMiddleware",
|
|
164
|
+
override: true,
|
|
165
|
+
priority: "low",
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
const TRACE_ID_HEADER_NAME = "X-Amzn-Trace-Id";
|
|
169
|
+
const ENV_LAMBDA_FUNCTION_NAME = "AWS_LAMBDA_FUNCTION_NAME";
|
|
170
|
+
const ENV_TRACE_ID = "_X_AMZN_TRACE_ID";
|
|
171
|
+
const recursionDetectionMiddleware = () => (next) => async (args) => {
|
|
172
|
+
const { request } = args;
|
|
173
|
+
if (!protocols.HttpRequest.isInstance(request)) {
|
|
174
|
+
return next(args);
|
|
175
|
+
}
|
|
176
|
+
const traceIdHeader = Object.keys(request.headers ?? {}).find((h) => h.toLowerCase() === TRACE_ID_HEADER_NAME.toLowerCase()) ??
|
|
177
|
+
TRACE_ID_HEADER_NAME;
|
|
178
|
+
if (request.headers.hasOwnProperty(traceIdHeader)) {
|
|
179
|
+
return next(args);
|
|
180
|
+
}
|
|
181
|
+
const functionName = process.env[ENV_LAMBDA_FUNCTION_NAME];
|
|
182
|
+
const traceIdFromEnv = process.env[ENV_TRACE_ID];
|
|
183
|
+
const invokeStore = await lambdaInvokeStore.InvokeStore.getInstanceAsync();
|
|
184
|
+
const traceIdFromInvokeStore = invokeStore?.getXRayTraceId();
|
|
185
|
+
const traceId = traceIdFromInvokeStore ?? traceIdFromEnv;
|
|
186
|
+
const nonEmptyString = (str) => typeof str === "string" && str.length > 0;
|
|
187
|
+
if (nonEmptyString(functionName) && nonEmptyString(traceId)) {
|
|
188
|
+
request.headers[TRACE_ID_HEADER_NAME] = traceId;
|
|
189
|
+
}
|
|
190
|
+
return next({
|
|
191
|
+
...args,
|
|
192
|
+
request,
|
|
193
|
+
});
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
const getRecursionDetectionPlugin = (options) => ({
|
|
197
|
+
applyToStack: (clientStack) => {
|
|
198
|
+
clientStack.add(recursionDetectionMiddleware(), recursionDetectionMiddlewareOptions);
|
|
199
|
+
},
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
const DEFAULT_UA_APP_ID = undefined;
|
|
203
|
+
function isValidUserAgentAppId(appId) {
|
|
204
|
+
if (appId === undefined) {
|
|
205
|
+
return true;
|
|
206
|
+
}
|
|
207
|
+
return typeof appId === "string" && appId.length <= 50;
|
|
208
|
+
}
|
|
209
|
+
function resolveUserAgentConfig(input) {
|
|
210
|
+
const normalizedAppIdProvider = core.normalizeProvider(input.userAgentAppId ?? DEFAULT_UA_APP_ID);
|
|
211
|
+
const { customUserAgent } = input;
|
|
212
|
+
return Object.assign(input, {
|
|
213
|
+
customUserAgent: typeof customUserAgent === "string" ? [[customUserAgent]] : customUserAgent,
|
|
214
|
+
userAgentAppId: async () => {
|
|
215
|
+
const appId = await normalizedAppIdProvider();
|
|
216
|
+
if (!isValidUserAgentAppId(appId)) {
|
|
217
|
+
const logger = input.logger?.constructor?.name === "NoOpLogger" || !input.logger ? console : input.logger;
|
|
218
|
+
if (typeof appId !== "string") {
|
|
219
|
+
logger?.warn("userAgentAppId must be a string or undefined.");
|
|
220
|
+
}
|
|
221
|
+
else if (appId.length > 50) {
|
|
222
|
+
logger?.warn("The provided userAgentAppId exceeds the maximum length of 50 characters.");
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
return appId;
|
|
226
|
+
},
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
const partitionsInfo = { "partitions": [{ "id": "aws", "outputs": { "dnsSuffix": "amazonaws.com", "dualStackDnsSuffix": "api.aws", "implicitGlobalRegion": "us-east-1", "name": "aws", "supportsDualStack": true, "supportsFIPS": true }, "regionRegex": "^(us|eu|ap|sa|ca|me|af|il|mx)\\-\\w+\\-\\d+$", "regions": { "af-south-1": { "description": "Africa (Cape Town)" }, "ap-east-1": { "description": "Asia Pacific (Hong Kong)" }, "ap-east-2": { "description": "Asia Pacific (Taipei)" }, "ap-northeast-1": { "description": "Asia Pacific (Tokyo)" }, "ap-northeast-2": { "description": "Asia Pacific (Seoul)" }, "ap-northeast-3": { "description": "Asia Pacific (Osaka)" }, "ap-south-1": { "description": "Asia Pacific (Mumbai)" }, "ap-south-2": { "description": "Asia Pacific (Hyderabad)" }, "ap-southeast-1": { "description": "Asia Pacific (Singapore)" }, "ap-southeast-2": { "description": "Asia Pacific (Sydney)" }, "ap-southeast-3": { "description": "Asia Pacific (Jakarta)" }, "ap-southeast-4": { "description": "Asia Pacific (Melbourne)" }, "ap-southeast-5": { "description": "Asia Pacific (Malaysia)" }, "ap-southeast-6": { "description": "Asia Pacific (New Zealand)" }, "ap-southeast-7": { "description": "Asia Pacific (Thailand)" }, "aws-global": { "description": "aws global region" }, "ca-central-1": { "description": "Canada (Central)" }, "ca-west-1": { "description": "Canada West (Calgary)" }, "eu-central-1": { "description": "Europe (Frankfurt)" }, "eu-central-2": { "description": "Europe (Zurich)" }, "eu-north-1": { "description": "Europe (Stockholm)" }, "eu-south-1": { "description": "Europe (Milan)" }, "eu-south-2": { "description": "Europe (Spain)" }, "eu-west-1": { "description": "Europe (Ireland)" }, "eu-west-2": { "description": "Europe (London)" }, "eu-west-3": { "description": "Europe (Paris)" }, "il-central-1": { "description": "Israel (Tel Aviv)" }, "me-central-1": { "description": "Middle East (UAE)" }, "me-south-1": { "description": "Middle East (Bahrain)" }, "mx-central-1": { "description": "Mexico (Central)" }, "sa-east-1": { "description": "South America (Sao Paulo)" }, "us-east-1": { "description": "US East (N. Virginia)" }, "us-east-2": { "description": "US East (Ohio)" }, "us-west-1": { "description": "US West (N. California)" }, "us-west-2": { "description": "US West (Oregon)" } } }, { "id": "aws-cn", "outputs": { "dnsSuffix": "amazonaws.com.cn", "dualStackDnsSuffix": "api.amazonwebservices.com.cn", "implicitGlobalRegion": "cn-northwest-1", "name": "aws-cn", "supportsDualStack": true, "supportsFIPS": true }, "regionRegex": "^cn\\-\\w+\\-\\d+$", "regions": { "aws-cn-global": { "description": "aws-cn global region" }, "cn-north-1": { "description": "China (Beijing)" }, "cn-northwest-1": { "description": "China (Ningxia)" } } }, { "id": "aws-eusc", "outputs": { "dnsSuffix": "amazonaws.eu", "dualStackDnsSuffix": "api.amazonwebservices.eu", "implicitGlobalRegion": "eusc-de-east-1", "name": "aws-eusc", "supportsDualStack": true, "supportsFIPS": true }, "regionRegex": "^eusc\\-(de)\\-\\w+\\-\\d+$", "regions": { "eusc-de-east-1": { "description": "AWS European Sovereign Cloud (Germany)" } } }, { "id": "aws-iso", "outputs": { "dnsSuffix": "c2s.ic.gov", "dualStackDnsSuffix": "api.aws.ic.gov", "implicitGlobalRegion": "us-iso-east-1", "name": "aws-iso", "supportsDualStack": true, "supportsFIPS": true }, "regionRegex": "^us\\-iso\\-\\w+\\-\\d+$", "regions": { "aws-iso-global": { "description": "aws-iso global region" }, "us-iso-east-1": { "description": "US ISO East" }, "us-iso-west-1": { "description": "US ISO WEST" } } }, { "id": "aws-iso-b", "outputs": { "dnsSuffix": "sc2s.sgov.gov", "dualStackDnsSuffix": "api.aws.scloud", "implicitGlobalRegion": "us-isob-east-1", "name": "aws-iso-b", "supportsDualStack": true, "supportsFIPS": true }, "regionRegex": "^us\\-isob\\-\\w+\\-\\d+$", "regions": { "aws-iso-b-global": { "description": "aws-iso-b global region" }, "us-isob-east-1": { "description": "US ISOB East (Ohio)" }, "us-isob-west-1": { "description": "US ISOB West" } } }, { "id": "aws-iso-e", "outputs": { "dnsSuffix": "cloud.adc-e.uk", "dualStackDnsSuffix": "api.cloud-aws.adc-e.uk", "implicitGlobalRegion": "eu-isoe-west-1", "name": "aws-iso-e", "supportsDualStack": true, "supportsFIPS": true }, "regionRegex": "^eu\\-isoe\\-\\w+\\-\\d+$", "regions": { "aws-iso-e-global": { "description": "aws-iso-e global region" }, "eu-isoe-west-1": { "description": "EU ISOE West" } } }, { "id": "aws-iso-f", "outputs": { "dnsSuffix": "csp.hci.ic.gov", "dualStackDnsSuffix": "api.aws.hci.ic.gov", "implicitGlobalRegion": "us-isof-south-1", "name": "aws-iso-f", "supportsDualStack": true, "supportsFIPS": true }, "regionRegex": "^us\\-isof\\-\\w+\\-\\d+$", "regions": { "aws-iso-f-global": { "description": "aws-iso-f global region" }, "us-isof-east-1": { "description": "US ISOF EAST" }, "us-isof-south-1": { "description": "US ISOF SOUTH" } } }, { "id": "aws-us-gov", "outputs": { "dnsSuffix": "amazonaws.com", "dualStackDnsSuffix": "api.aws", "implicitGlobalRegion": "us-gov-west-1", "name": "aws-us-gov", "supportsDualStack": true, "supportsFIPS": true }, "regionRegex": "^us\\-gov\\-\\w+\\-\\d+$", "regions": { "aws-us-gov-global": { "description": "aws-us-gov global region" }, "us-gov-east-1": { "description": "AWS GovCloud (US-East)" }, "us-gov-west-1": { "description": "AWS GovCloud (US-West)" } } }], "version": "1.1" };
|
|
231
|
+
|
|
232
|
+
let selectedPartitionsInfo = partitionsInfo;
|
|
233
|
+
let selectedUserAgentPrefix = "";
|
|
234
|
+
const partition = (value) => {
|
|
235
|
+
const { partitions } = selectedPartitionsInfo;
|
|
236
|
+
for (const partition of partitions) {
|
|
237
|
+
const { regions, outputs } = partition;
|
|
238
|
+
for (const [region, regionData] of Object.entries(regions)) {
|
|
239
|
+
if (region === value) {
|
|
240
|
+
return {
|
|
241
|
+
...outputs,
|
|
242
|
+
...regionData,
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
for (const partition of partitions) {
|
|
248
|
+
const { regionRegex, outputs } = partition;
|
|
249
|
+
if (new RegExp(regionRegex).test(value)) {
|
|
250
|
+
return {
|
|
251
|
+
...outputs,
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
const DEFAULT_PARTITION = partitions.find((partition) => partition.id === "aws");
|
|
256
|
+
if (!DEFAULT_PARTITION) {
|
|
257
|
+
throw new Error("Provided region was not found in the partition array or regex," +
|
|
258
|
+
" and default partition with id 'aws' doesn't exist.");
|
|
259
|
+
}
|
|
260
|
+
return {
|
|
261
|
+
...DEFAULT_PARTITION.outputs,
|
|
262
|
+
};
|
|
263
|
+
};
|
|
264
|
+
const setPartitionInfo = (partitionsInfo, userAgentPrefix = "") => {
|
|
265
|
+
selectedPartitionsInfo = partitionsInfo;
|
|
266
|
+
selectedUserAgentPrefix = userAgentPrefix;
|
|
267
|
+
};
|
|
268
|
+
const useDefaultPartitionInfo = () => {
|
|
269
|
+
setPartitionInfo(partitionsInfo, "");
|
|
270
|
+
};
|
|
271
|
+
const getUserAgentPrefix = () => selectedUserAgentPrefix;
|
|
272
|
+
|
|
273
|
+
const ACCOUNT_ID_ENDPOINT_REGEX = /\d{12}\.ddb/;
|
|
274
|
+
async function checkFeatures(context, config, args) {
|
|
275
|
+
const request = args.request;
|
|
276
|
+
if (request?.headers?.["smithy-protocol"] === "rpc-v2-cbor") {
|
|
277
|
+
setFeature(context, "PROTOCOL_RPC_V2_CBOR", "M");
|
|
278
|
+
}
|
|
279
|
+
if (typeof config.retryStrategy === "function") {
|
|
280
|
+
const retryStrategy = await config.retryStrategy();
|
|
281
|
+
if (typeof retryStrategy.mode === "string") {
|
|
282
|
+
switch (retryStrategy.mode) {
|
|
283
|
+
case retry.RETRY_MODES.ADAPTIVE:
|
|
284
|
+
setFeature(context, "RETRY_MODE_ADAPTIVE", "F");
|
|
285
|
+
break;
|
|
286
|
+
case retry.RETRY_MODES.STANDARD:
|
|
287
|
+
setFeature(context, "RETRY_MODE_STANDARD", "E");
|
|
288
|
+
break;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
if (typeof config.accountIdEndpointMode === "function") {
|
|
293
|
+
const endpointV2 = context.endpointV2;
|
|
294
|
+
if (String(endpointV2?.url?.hostname).match(ACCOUNT_ID_ENDPOINT_REGEX)) {
|
|
295
|
+
setFeature(context, "ACCOUNT_ID_ENDPOINT", "O");
|
|
296
|
+
}
|
|
297
|
+
switch (await config.accountIdEndpointMode?.()) {
|
|
298
|
+
case "disabled":
|
|
299
|
+
setFeature(context, "ACCOUNT_ID_MODE_DISABLED", "Q");
|
|
300
|
+
break;
|
|
301
|
+
case "preferred":
|
|
302
|
+
setFeature(context, "ACCOUNT_ID_MODE_PREFERRED", "P");
|
|
303
|
+
break;
|
|
304
|
+
case "required":
|
|
305
|
+
setFeature(context, "ACCOUNT_ID_MODE_REQUIRED", "R");
|
|
306
|
+
break;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
const identity = context.__smithy_context?.selectedHttpAuthScheme?.identity;
|
|
310
|
+
if (identity?.$source) {
|
|
311
|
+
const credentials = identity;
|
|
312
|
+
if (credentials.accountId) {
|
|
313
|
+
setFeature(context, "RESOLVED_ACCOUNT_ID", "T");
|
|
314
|
+
}
|
|
315
|
+
for (const [key, value] of Object.entries(credentials.$source ?? {})) {
|
|
316
|
+
setFeature(context, key, value);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
const USER_AGENT = "user-agent";
|
|
322
|
+
const X_AMZ_USER_AGENT = "x-amz-user-agent";
|
|
323
|
+
const SPACE = " ";
|
|
324
|
+
const UA_NAME_SEPARATOR = "/";
|
|
325
|
+
const UA_NAME_ESCAPE_REGEX = /[^!$%&'*+\-.^_`|~\w]/g;
|
|
326
|
+
const UA_VALUE_ESCAPE_REGEX = /[^!$%&'*+\-.^_`|~\w#]/g;
|
|
327
|
+
const UA_ESCAPE_CHAR = "-";
|
|
328
|
+
|
|
329
|
+
const BYTE_LIMIT = 1024;
|
|
330
|
+
function encodeFeatures(features) {
|
|
331
|
+
let buffer = "";
|
|
332
|
+
for (const key in features) {
|
|
333
|
+
const val = features[key];
|
|
334
|
+
if (buffer.length + val.length + 1 <= BYTE_LIMIT) {
|
|
335
|
+
if (buffer.length) {
|
|
336
|
+
buffer += "," + val;
|
|
337
|
+
}
|
|
338
|
+
else {
|
|
339
|
+
buffer += val;
|
|
340
|
+
}
|
|
341
|
+
continue;
|
|
342
|
+
}
|
|
343
|
+
break;
|
|
344
|
+
}
|
|
345
|
+
return buffer;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
const userAgentMiddleware = (options) => (next, context) => async (args) => {
|
|
349
|
+
const { request } = args;
|
|
350
|
+
if (!protocols.HttpRequest.isInstance(request)) {
|
|
351
|
+
return next(args);
|
|
352
|
+
}
|
|
353
|
+
const { headers } = request;
|
|
354
|
+
const userAgent = context?.userAgent?.map(escapeUserAgent) || [];
|
|
355
|
+
const defaultUserAgent = (await options.defaultUserAgentProvider()).map(escapeUserAgent);
|
|
356
|
+
await checkFeatures(context, options, args);
|
|
357
|
+
const awsContext = context;
|
|
358
|
+
defaultUserAgent.push(`m/${encodeFeatures(Object.assign({}, context.__smithy_context?.features, awsContext.__aws_sdk_context?.features))}`);
|
|
359
|
+
const customUserAgent = options?.customUserAgent?.map(escapeUserAgent) || [];
|
|
360
|
+
const appId = await options.userAgentAppId();
|
|
361
|
+
if (appId) {
|
|
362
|
+
defaultUserAgent.push(escapeUserAgent([`app`, `${appId}`]));
|
|
363
|
+
}
|
|
364
|
+
const prefix = getUserAgentPrefix();
|
|
365
|
+
const sdkUserAgentValue = (prefix ? [prefix] : [])
|
|
366
|
+
.concat([...defaultUserAgent, ...userAgent, ...customUserAgent])
|
|
367
|
+
.join(SPACE);
|
|
368
|
+
const normalUAValue = [
|
|
369
|
+
...defaultUserAgent.filter((section) => section.startsWith("aws-sdk-")),
|
|
370
|
+
...customUserAgent,
|
|
371
|
+
].join(SPACE);
|
|
372
|
+
if (options.runtime !== "browser") {
|
|
373
|
+
if (normalUAValue) {
|
|
374
|
+
headers[X_AMZ_USER_AGENT] = headers[X_AMZ_USER_AGENT]
|
|
375
|
+
? `${headers[USER_AGENT]} ${normalUAValue}`
|
|
376
|
+
: normalUAValue;
|
|
377
|
+
}
|
|
378
|
+
headers[USER_AGENT] = sdkUserAgentValue;
|
|
379
|
+
}
|
|
380
|
+
else {
|
|
381
|
+
headers[X_AMZ_USER_AGENT] = sdkUserAgentValue;
|
|
382
|
+
}
|
|
383
|
+
return next({
|
|
384
|
+
...args,
|
|
385
|
+
request,
|
|
386
|
+
});
|
|
387
|
+
};
|
|
388
|
+
const escapeUserAgent = (userAgentPair) => {
|
|
389
|
+
const name = userAgentPair[0]
|
|
390
|
+
.split(UA_NAME_SEPARATOR)
|
|
391
|
+
.map((part) => part.replace(UA_NAME_ESCAPE_REGEX, UA_ESCAPE_CHAR))
|
|
392
|
+
.join(UA_NAME_SEPARATOR);
|
|
393
|
+
const version = userAgentPair[1]?.replace(UA_VALUE_ESCAPE_REGEX, UA_ESCAPE_CHAR);
|
|
394
|
+
const prefixSeparatorIndex = name.indexOf(UA_NAME_SEPARATOR);
|
|
395
|
+
const prefix = name.substring(0, prefixSeparatorIndex);
|
|
396
|
+
let uaName = name.substring(prefixSeparatorIndex + 1);
|
|
397
|
+
if (prefix === "api") {
|
|
398
|
+
uaName = uaName.toLowerCase();
|
|
399
|
+
}
|
|
400
|
+
return [prefix, uaName, version]
|
|
401
|
+
.filter((item) => item && item.length > 0)
|
|
402
|
+
.reduce((acc, item, index) => {
|
|
403
|
+
switch (index) {
|
|
404
|
+
case 0:
|
|
405
|
+
return item;
|
|
406
|
+
case 1:
|
|
407
|
+
return `${acc}/${item}`;
|
|
408
|
+
default:
|
|
409
|
+
return `${acc}#${item}`;
|
|
410
|
+
}
|
|
411
|
+
}, "");
|
|
412
|
+
};
|
|
413
|
+
const getUserAgentMiddlewareOptions = {
|
|
414
|
+
name: "getUserAgentMiddleware",
|
|
415
|
+
step: "build",
|
|
416
|
+
priority: "low",
|
|
417
|
+
tags: ["SET_USER_AGENT", "USER_AGENT"],
|
|
418
|
+
override: true,
|
|
419
|
+
};
|
|
420
|
+
const getUserAgentPlugin = (config) => ({
|
|
421
|
+
applyToStack: (clientStack) => {
|
|
422
|
+
clientStack.add(userAgentMiddleware(config), getUserAgentMiddlewareOptions);
|
|
423
|
+
},
|
|
424
|
+
});
|
|
425
|
+
|
|
426
|
+
const getRuntimeUserAgentPair = () => {
|
|
427
|
+
const runtimesToCheck = ["deno", "bun", "llrt"];
|
|
428
|
+
for (const runtime of runtimesToCheck) {
|
|
429
|
+
if (node_process.versions[runtime]) {
|
|
430
|
+
return [`md/${runtime}`, node_process.versions[runtime]];
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
return ["md/nodejs", node_process.versions.node];
|
|
434
|
+
};
|
|
435
|
+
|
|
436
|
+
const getNodeModulesParentDirs = (dirname) => {
|
|
437
|
+
const cwd = process.cwd();
|
|
438
|
+
if (!dirname) {
|
|
439
|
+
return [cwd];
|
|
440
|
+
}
|
|
441
|
+
const normalizedPath = node_path.normalize(dirname);
|
|
442
|
+
const parts = normalizedPath.split(node_path.sep);
|
|
443
|
+
const nodeModulesIndex = parts.indexOf("node_modules");
|
|
444
|
+
const parentDir = nodeModulesIndex !== -1 ? parts.slice(0, nodeModulesIndex).join(node_path.sep) : normalizedPath;
|
|
445
|
+
if (cwd === parentDir) {
|
|
446
|
+
return [cwd];
|
|
447
|
+
}
|
|
448
|
+
return [parentDir, cwd];
|
|
449
|
+
};
|
|
450
|
+
|
|
451
|
+
const SEMVER_REGEX = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*)?$/;
|
|
452
|
+
const getSanitizedTypeScriptVersion = (version = "") => {
|
|
453
|
+
const match = version.match(SEMVER_REGEX);
|
|
454
|
+
if (!match) {
|
|
455
|
+
return undefined;
|
|
456
|
+
}
|
|
457
|
+
const [major, minor, patch, prerelease] = [match[1], match[2], match[3], match[4]];
|
|
458
|
+
return prerelease ? `${major}.${minor}.${patch}-${prerelease}` : `${major}.${minor}.${patch}`;
|
|
459
|
+
};
|
|
460
|
+
|
|
461
|
+
const ALLOWED_PREFIXES = ["^", "~", ">=", "<=", ">", "<"];
|
|
462
|
+
const ALLOWED_DIST_TAGS = ["latest", "beta", "dev", "rc", "insiders", "next"];
|
|
463
|
+
const getSanitizedDevTypeScriptVersion = (version = "") => {
|
|
464
|
+
if (ALLOWED_DIST_TAGS.includes(version)) {
|
|
465
|
+
return version;
|
|
466
|
+
}
|
|
467
|
+
const prefix = ALLOWED_PREFIXES.find((p) => version.startsWith(p)) ?? "";
|
|
468
|
+
const sanitizedTypeScriptVersion = getSanitizedTypeScriptVersion(version.slice(prefix.length));
|
|
469
|
+
if (!sanitizedTypeScriptVersion) {
|
|
470
|
+
return undefined;
|
|
471
|
+
}
|
|
472
|
+
return `${prefix}${sanitizedTypeScriptVersion}`;
|
|
473
|
+
};
|
|
474
|
+
|
|
475
|
+
let tscVersion;
|
|
476
|
+
const TS_PACKAGE_JSON = node_path.join("node_modules", "typescript", "package.json");
|
|
477
|
+
const getTypeScriptUserAgentPair = async () => {
|
|
478
|
+
if (tscVersion === null) {
|
|
479
|
+
return undefined;
|
|
480
|
+
}
|
|
481
|
+
else if (typeof tscVersion === "string") {
|
|
482
|
+
return ["md/tsc", tscVersion];
|
|
483
|
+
}
|
|
484
|
+
let isTypeScriptDetectionDisabled = false;
|
|
485
|
+
try {
|
|
486
|
+
isTypeScriptDetectionDisabled =
|
|
487
|
+
config.booleanSelector(process.env, "AWS_SDK_JS_TYPESCRIPT_DETECTION_DISABLED", config.SelectorType.ENV) || false;
|
|
488
|
+
}
|
|
489
|
+
catch { }
|
|
490
|
+
if (isTypeScriptDetectionDisabled) {
|
|
491
|
+
tscVersion = null;
|
|
492
|
+
return undefined;
|
|
493
|
+
}
|
|
494
|
+
const dirname = typeof __dirname !== "undefined" ? __dirname : undefined;
|
|
495
|
+
const nodeModulesParentDirs = getNodeModulesParentDirs(dirname);
|
|
496
|
+
let versionFromApp;
|
|
497
|
+
for (const nodeModulesParentDir of nodeModulesParentDirs) {
|
|
498
|
+
try {
|
|
499
|
+
const appPackageJsonPath = node_path.join(nodeModulesParentDir, "package.json");
|
|
500
|
+
const packageJson = await promises.readFile(appPackageJsonPath, "utf-8");
|
|
501
|
+
const { dependencies, devDependencies } = JSON.parse(packageJson);
|
|
502
|
+
const version = devDependencies?.typescript ?? dependencies?.typescript;
|
|
503
|
+
if (typeof version !== "string") {
|
|
504
|
+
continue;
|
|
505
|
+
}
|
|
506
|
+
versionFromApp = version;
|
|
507
|
+
break;
|
|
508
|
+
}
|
|
509
|
+
catch {
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
if (!versionFromApp) {
|
|
513
|
+
tscVersion = null;
|
|
514
|
+
return undefined;
|
|
515
|
+
}
|
|
516
|
+
let versionFromNodeModules;
|
|
517
|
+
for (const nodeModulesParentDir of nodeModulesParentDirs) {
|
|
518
|
+
try {
|
|
519
|
+
const tsPackageJsonPath = node_path.join(nodeModulesParentDir, TS_PACKAGE_JSON);
|
|
520
|
+
const packageJson = await promises.readFile(tsPackageJsonPath, "utf-8");
|
|
521
|
+
const { version } = JSON.parse(packageJson);
|
|
522
|
+
const sanitizedVersion = getSanitizedTypeScriptVersion(version);
|
|
523
|
+
if (typeof sanitizedVersion !== "string") {
|
|
524
|
+
continue;
|
|
525
|
+
}
|
|
526
|
+
versionFromNodeModules = sanitizedVersion;
|
|
527
|
+
break;
|
|
528
|
+
}
|
|
529
|
+
catch {
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
if (versionFromNodeModules) {
|
|
533
|
+
tscVersion = versionFromNodeModules;
|
|
534
|
+
return ["md/tsc", tscVersion];
|
|
535
|
+
}
|
|
536
|
+
const sanitizedVersion = getSanitizedDevTypeScriptVersion(versionFromApp);
|
|
537
|
+
if (typeof sanitizedVersion !== "string") {
|
|
538
|
+
tscVersion = null;
|
|
539
|
+
return undefined;
|
|
540
|
+
}
|
|
541
|
+
tscVersion = `dev_${sanitizedVersion}`;
|
|
542
|
+
return ["md/tsc", tscVersion];
|
|
543
|
+
};
|
|
544
|
+
|
|
545
|
+
const crtAvailability = {
|
|
546
|
+
isCrtAvailable: false,
|
|
547
|
+
};
|
|
548
|
+
|
|
549
|
+
const isCrtAvailable = () => {
|
|
550
|
+
if (crtAvailability.isCrtAvailable) {
|
|
551
|
+
return ["md/crt-avail"];
|
|
552
|
+
}
|
|
553
|
+
return null;
|
|
554
|
+
};
|
|
555
|
+
|
|
556
|
+
const createDefaultUserAgentProvider = ({ serviceId, clientVersion }) => {
|
|
557
|
+
const runtimeUserAgentPair = getRuntimeUserAgentPair();
|
|
558
|
+
return async (config) => {
|
|
559
|
+
const sections = [
|
|
560
|
+
["aws-sdk-js", clientVersion],
|
|
561
|
+
["ua", "2.1"],
|
|
562
|
+
[`os/${node_os.platform()}`, node_os.release()],
|
|
563
|
+
["lang/js"],
|
|
564
|
+
runtimeUserAgentPair,
|
|
565
|
+
];
|
|
566
|
+
const typescriptUserAgentPair = await getTypeScriptUserAgentPair();
|
|
567
|
+
if (typescriptUserAgentPair) {
|
|
568
|
+
sections.push(typescriptUserAgentPair);
|
|
569
|
+
}
|
|
570
|
+
const crtAvailable = isCrtAvailable();
|
|
571
|
+
if (crtAvailable) {
|
|
572
|
+
sections.push(crtAvailable);
|
|
573
|
+
}
|
|
574
|
+
if (serviceId) {
|
|
575
|
+
sections.push([`api/${serviceId}`, clientVersion]);
|
|
576
|
+
}
|
|
577
|
+
if (node_process.env.AWS_EXECUTION_ENV) {
|
|
578
|
+
sections.push([`exec-env/${node_process.env.AWS_EXECUTION_ENV}`]);
|
|
579
|
+
}
|
|
580
|
+
const appId = await config?.userAgentAppId?.();
|
|
581
|
+
const resolvedUserAgent = appId ? [...sections, [`app/${appId}`]] : [...sections];
|
|
582
|
+
return resolvedUserAgent;
|
|
583
|
+
};
|
|
584
|
+
};
|
|
585
|
+
const defaultUserAgent = createDefaultUserAgentProvider;
|
|
586
|
+
|
|
587
|
+
const UA_APP_ID_ENV_NAME = "AWS_SDK_UA_APP_ID";
|
|
588
|
+
const UA_APP_ID_INI_NAME = "sdk_ua_app_id";
|
|
589
|
+
const UA_APP_ID_INI_NAME_DEPRECATED = "sdk-ua-app-id";
|
|
590
|
+
const NODE_APP_ID_CONFIG_OPTIONS = {
|
|
591
|
+
environmentVariableSelector: (env) => env[UA_APP_ID_ENV_NAME],
|
|
592
|
+
configFileSelector: (profile) => profile[UA_APP_ID_INI_NAME] ?? profile[UA_APP_ID_INI_NAME_DEPRECATED],
|
|
593
|
+
default: DEFAULT_UA_APP_ID,
|
|
594
|
+
};
|
|
595
|
+
|
|
596
|
+
const createUserAgentStringParsingProvider = ({ serviceId, clientVersion }) => async (config) => {
|
|
597
|
+
const module = await import('bowser');
|
|
598
|
+
const parse = module.parse ?? module.default.parse ?? (() => "");
|
|
599
|
+
const parsedUA = typeof window !== "undefined" && window?.navigator?.userAgent ? parse(window.navigator.userAgent) : undefined;
|
|
600
|
+
const sections = [
|
|
601
|
+
["aws-sdk-js", clientVersion],
|
|
602
|
+
["ua", "2.1"],
|
|
603
|
+
[`os/${parsedUA?.os?.name || "other"}`, parsedUA?.os?.version],
|
|
604
|
+
["lang/js"],
|
|
605
|
+
["md/browser", `${parsedUA?.browser?.name ?? "unknown"}_${parsedUA?.browser?.version ?? "unknown"}`],
|
|
606
|
+
];
|
|
607
|
+
if (serviceId) {
|
|
608
|
+
sections.push([`api/${serviceId}`, clientVersion]);
|
|
609
|
+
}
|
|
610
|
+
const appId = await config?.userAgentAppId?.();
|
|
611
|
+
if (appId) {
|
|
612
|
+
sections.push([`app/${appId}`]);
|
|
613
|
+
}
|
|
614
|
+
return sections;
|
|
615
|
+
};
|
|
616
|
+
|
|
617
|
+
const fallback = {
|
|
618
|
+
os(ua) {
|
|
619
|
+
if (/iPhone|iPad|iPod/.test(ua))
|
|
620
|
+
return "iOS";
|
|
621
|
+
if (/Macintosh|Mac OS X/.test(ua))
|
|
622
|
+
return "macOS";
|
|
623
|
+
if (/Windows NT/.test(ua))
|
|
624
|
+
return "Windows";
|
|
625
|
+
if (/Android/.test(ua))
|
|
626
|
+
return "Android";
|
|
627
|
+
if (/Linux/.test(ua))
|
|
628
|
+
return "Linux";
|
|
629
|
+
return undefined;
|
|
630
|
+
},
|
|
631
|
+
browser(ua) {
|
|
632
|
+
if (/EdgiOS|EdgA|Edg\//.test(ua))
|
|
633
|
+
return "Microsoft Edge";
|
|
634
|
+
if (/Firefox\//.test(ua))
|
|
635
|
+
return "Firefox";
|
|
636
|
+
if (/Chrome\//.test(ua))
|
|
637
|
+
return "Chrome";
|
|
638
|
+
if (/Safari\//.test(ua))
|
|
639
|
+
return "Safari";
|
|
640
|
+
return undefined;
|
|
641
|
+
},
|
|
642
|
+
};
|
|
643
|
+
|
|
644
|
+
const isVirtualHostableS3Bucket = (value, allowSubDomains = false) => {
|
|
645
|
+
if (allowSubDomains) {
|
|
646
|
+
for (const label of value.split(".")) {
|
|
647
|
+
if (!isVirtualHostableS3Bucket(label)) {
|
|
648
|
+
return false;
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
return true;
|
|
652
|
+
}
|
|
653
|
+
if (!endpoints.isValidHostLabel(value)) {
|
|
654
|
+
return false;
|
|
655
|
+
}
|
|
656
|
+
if (value.length < 3 || value.length > 63) {
|
|
657
|
+
return false;
|
|
658
|
+
}
|
|
659
|
+
if (value !== value.toLowerCase()) {
|
|
660
|
+
return false;
|
|
661
|
+
}
|
|
662
|
+
if (endpoints.isIpAddress(value)) {
|
|
663
|
+
return false;
|
|
664
|
+
}
|
|
665
|
+
return true;
|
|
666
|
+
};
|
|
667
|
+
|
|
668
|
+
const ARN_DELIMITER = ":";
|
|
669
|
+
const RESOURCE_DELIMITER = "/";
|
|
670
|
+
const parseArn = (value) => {
|
|
671
|
+
const segments = value.split(ARN_DELIMITER);
|
|
672
|
+
if (segments.length < 6)
|
|
673
|
+
return null;
|
|
674
|
+
const [arn, partition, service, region, accountId, ...resourcePath] = segments;
|
|
675
|
+
if (arn !== "arn" || partition === "" || service === "" || resourcePath.join(ARN_DELIMITER) === "")
|
|
676
|
+
return null;
|
|
677
|
+
const resourceId = resourcePath.map((resource) => resource.split(RESOURCE_DELIMITER)).flat();
|
|
678
|
+
return {
|
|
679
|
+
partition,
|
|
680
|
+
service,
|
|
681
|
+
region,
|
|
682
|
+
accountId,
|
|
683
|
+
resourceId,
|
|
684
|
+
};
|
|
685
|
+
};
|
|
686
|
+
|
|
687
|
+
const awsEndpointFunctions = {
|
|
688
|
+
isVirtualHostableS3Bucket: isVirtualHostableS3Bucket,
|
|
689
|
+
parseArn: parseArn,
|
|
690
|
+
partition: partition,
|
|
691
|
+
};
|
|
692
|
+
endpoints.customEndpointFunctions.aws = awsEndpointFunctions;
|
|
693
|
+
|
|
694
|
+
const resolveDefaultAwsRegionalEndpointsConfig = (input) => {
|
|
695
|
+
if (typeof input.endpointProvider !== "function") {
|
|
696
|
+
throw new Error("@aws-sdk/util-endpoint - endpointProvider and endpoint missing in config for this client.");
|
|
697
|
+
}
|
|
698
|
+
const { endpoint } = input;
|
|
699
|
+
if (endpoint === undefined) {
|
|
700
|
+
input.endpoint = async () => {
|
|
701
|
+
return toEndpointV1(input.endpointProvider({
|
|
702
|
+
Region: typeof input.region === "function" ? await input.region() : input.region,
|
|
703
|
+
UseDualStack: typeof input.useDualstackEndpoint === "function"
|
|
704
|
+
? await input.useDualstackEndpoint()
|
|
705
|
+
: input.useDualstackEndpoint,
|
|
706
|
+
UseFIPS: typeof input.useFipsEndpoint === "function" ? await input.useFipsEndpoint() : input.useFipsEndpoint,
|
|
707
|
+
Endpoint: undefined,
|
|
708
|
+
}, { logger: input.logger }));
|
|
709
|
+
};
|
|
710
|
+
}
|
|
711
|
+
return input;
|
|
712
|
+
};
|
|
713
|
+
const toEndpointV1 = (endpoint) => protocols.parseUrl(endpoint.url);
|
|
714
|
+
|
|
715
|
+
function stsRegionDefaultResolver(loaderConfig = {}) {
|
|
716
|
+
return config.loadConfig({
|
|
717
|
+
...config.NODE_REGION_CONFIG_OPTIONS,
|
|
718
|
+
async default() {
|
|
719
|
+
if (!warning.silence) {
|
|
720
|
+
console.warn("@aws-sdk - WARN - default STS region of us-east-1 used. See @aws-sdk/credential-providers README and set a region explicitly.");
|
|
721
|
+
}
|
|
722
|
+
return "us-east-1";
|
|
723
|
+
},
|
|
724
|
+
}, { ...config.NODE_REGION_CONFIG_FILE_OPTIONS, ...loaderConfig });
|
|
725
|
+
}
|
|
726
|
+
const warning = {
|
|
727
|
+
silence: false,
|
|
728
|
+
};
|
|
729
|
+
|
|
730
|
+
const getAwsRegionExtensionConfiguration = (runtimeConfig) => {
|
|
731
|
+
return {
|
|
732
|
+
setRegion(region) {
|
|
733
|
+
runtimeConfig.region = region;
|
|
734
|
+
},
|
|
735
|
+
region() {
|
|
736
|
+
return runtimeConfig.region;
|
|
737
|
+
},
|
|
738
|
+
};
|
|
739
|
+
};
|
|
740
|
+
const resolveAwsRegionExtensionConfiguration = (awsRegionExtensionConfiguration) => {
|
|
741
|
+
return {
|
|
742
|
+
region: awsRegionExtensionConfiguration.region(),
|
|
743
|
+
};
|
|
744
|
+
};
|
|
745
|
+
|
|
746
|
+
exports.NODE_REGION_CONFIG_FILE_OPTIONS = config.NODE_REGION_CONFIG_FILE_OPTIONS;
|
|
747
|
+
exports.NODE_REGION_CONFIG_OPTIONS = config.NODE_REGION_CONFIG_OPTIONS;
|
|
748
|
+
exports.REGION_ENV_NAME = config.REGION_ENV_NAME;
|
|
749
|
+
exports.REGION_INI_NAME = config.REGION_INI_NAME;
|
|
750
|
+
exports.resolveRegionConfig = config.resolveRegionConfig;
|
|
751
|
+
exports.EndpointError = endpoints.EndpointError;
|
|
752
|
+
exports.isIpAddress = endpoints.isIpAddress;
|
|
753
|
+
exports.resolveEndpoint = endpoints.resolveEndpoint;
|
|
754
|
+
exports.DEFAULT_UA_APP_ID = DEFAULT_UA_APP_ID;
|
|
755
|
+
exports.NODE_APP_ID_CONFIG_OPTIONS = NODE_APP_ID_CONFIG_OPTIONS;
|
|
756
|
+
exports.UA_APP_ID_ENV_NAME = UA_APP_ID_ENV_NAME;
|
|
757
|
+
exports.UA_APP_ID_INI_NAME = UA_APP_ID_INI_NAME;
|
|
758
|
+
exports.awsEndpointFunctions = awsEndpointFunctions;
|
|
759
|
+
exports.createDefaultUserAgentProvider = createDefaultUserAgentProvider;
|
|
760
|
+
exports.createUserAgentStringParsingProvider = createUserAgentStringParsingProvider;
|
|
761
|
+
exports.crtAvailability = crtAvailability;
|
|
762
|
+
exports.defaultUserAgent = defaultUserAgent;
|
|
75
763
|
exports.emitWarningIfUnsupportedVersion = emitWarningIfUnsupportedVersion;
|
|
764
|
+
exports.fallback = fallback;
|
|
765
|
+
exports.getAwsRegionExtensionConfiguration = getAwsRegionExtensionConfiguration;
|
|
766
|
+
exports.getHostHeaderPlugin = getHostHeaderPlugin;
|
|
767
|
+
exports.getLoggerPlugin = getLoggerPlugin;
|
|
76
768
|
exports.getLongPollPlugin = getLongPollPlugin;
|
|
769
|
+
exports.getRecursionDetectionPlugin = getRecursionDetectionPlugin;
|
|
770
|
+
exports.getUserAgentMiddlewareOptions = getUserAgentMiddlewareOptions;
|
|
771
|
+
exports.getUserAgentPlugin = getUserAgentPlugin;
|
|
772
|
+
exports.getUserAgentPrefix = getUserAgentPrefix;
|
|
773
|
+
exports.hostHeaderMiddleware = hostHeaderMiddleware;
|
|
774
|
+
exports.hostHeaderMiddlewareOptions = hostHeaderMiddlewareOptions;
|
|
775
|
+
exports.isVirtualHostableS3Bucket = isVirtualHostableS3Bucket;
|
|
776
|
+
exports.loggerMiddleware = loggerMiddleware;
|
|
777
|
+
exports.loggerMiddlewareOptions = loggerMiddlewareOptions;
|
|
778
|
+
exports.parseArn = parseArn;
|
|
779
|
+
exports.partition = partition;
|
|
780
|
+
exports.recursionDetectionMiddleware = recursionDetectionMiddleware;
|
|
781
|
+
exports.recursionDetectionMiddlewareOptions = recursionDetectionMiddlewareOptions;
|
|
782
|
+
exports.resolveAwsRegionExtensionConfiguration = resolveAwsRegionExtensionConfiguration;
|
|
783
|
+
exports.resolveDefaultAwsRegionalEndpointsConfig = resolveDefaultAwsRegionalEndpointsConfig;
|
|
784
|
+
exports.resolveHostHeaderConfig = resolveHostHeaderConfig;
|
|
785
|
+
exports.resolveUserAgentConfig = resolveUserAgentConfig;
|
|
77
786
|
exports.setCredentialFeature = setCredentialFeature;
|
|
78
787
|
exports.setFeature = setFeature;
|
|
788
|
+
exports.setPartitionInfo = setPartitionInfo;
|
|
79
789
|
exports.setTokenFeature = setTokenFeature;
|
|
80
790
|
exports.state = state;
|
|
791
|
+
exports.stsRegionDefaultResolver = stsRegionDefaultResolver;
|
|
792
|
+
exports.stsRegionWarning = warning;
|
|
793
|
+
exports.toEndpointV1 = toEndpointV1;
|
|
794
|
+
exports.useDefaultPartitionInfo = useDefaultPartitionInfo;
|
|
795
|
+
exports.userAgentMiddleware = userAgentMiddleware;
|