@aws-sdk/middleware-user-agent 3.721.0 → 3.726.0
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 +13 -17
- package/package.json +9 -9
package/dist-cjs/index.js
CHANGED
|
@@ -45,14 +45,13 @@ function resolveUserAgentConfig(input) {
|
|
|
45
45
|
...input,
|
|
46
46
|
customUserAgent: typeof input.customUserAgent === "string" ? [[input.customUserAgent]] : input.customUserAgent,
|
|
47
47
|
userAgentAppId: async () => {
|
|
48
|
-
var _a, _b;
|
|
49
48
|
const appId = await normalizedAppIdProvider();
|
|
50
49
|
if (!isValidUserAgentAppId(appId)) {
|
|
51
|
-
const logger =
|
|
50
|
+
const logger = input.logger?.constructor?.name === "NoOpLogger" || !input.logger ? console : input.logger;
|
|
52
51
|
if (typeof appId !== "string") {
|
|
53
|
-
logger
|
|
52
|
+
logger?.warn("userAgentAppId must be a string or undefined.");
|
|
54
53
|
} else if (appId.length > 50) {
|
|
55
|
-
logger
|
|
54
|
+
logger?.warn("The provided userAgentAppId exceeds the maximum length of 50 characters.");
|
|
56
55
|
}
|
|
57
56
|
}
|
|
58
57
|
return appId;
|
|
@@ -69,15 +68,14 @@ var import_protocol_http = require("@smithy/protocol-http");
|
|
|
69
68
|
var import_core2 = require("@aws-sdk/core");
|
|
70
69
|
var ACCOUNT_ID_ENDPOINT_REGEX = /\d{12}\.ddb/;
|
|
71
70
|
async function checkFeatures(context, config, args) {
|
|
72
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
73
71
|
const request = args.request;
|
|
74
|
-
if (
|
|
72
|
+
if (request?.headers?.["smithy-protocol"] === "rpc-v2-cbor") {
|
|
75
73
|
(0, import_core2.setFeature)(context, "PROTOCOL_RPC_V2_CBOR", "M");
|
|
76
74
|
}
|
|
77
75
|
if (typeof config.retryStrategy === "function") {
|
|
78
76
|
const retryStrategy = await config.retryStrategy();
|
|
79
77
|
if (typeof retryStrategy.acquireInitialRetryToken === "function") {
|
|
80
|
-
if (
|
|
78
|
+
if (retryStrategy.constructor?.name?.includes("Adaptive")) {
|
|
81
79
|
(0, import_core2.setFeature)(context, "RETRY_MODE_ADAPTIVE", "F");
|
|
82
80
|
} else {
|
|
83
81
|
(0, import_core2.setFeature)(context, "RETRY_MODE_STANDARD", "E");
|
|
@@ -88,10 +86,10 @@ async function checkFeatures(context, config, args) {
|
|
|
88
86
|
}
|
|
89
87
|
if (typeof config.accountIdEndpointMode === "function") {
|
|
90
88
|
const endpointV2 = context.endpointV2;
|
|
91
|
-
if (String(
|
|
89
|
+
if (String(endpointV2?.url?.hostname).match(ACCOUNT_ID_ENDPOINT_REGEX)) {
|
|
92
90
|
(0, import_core2.setFeature)(context, "ACCOUNT_ID_ENDPOINT", "O");
|
|
93
91
|
}
|
|
94
|
-
switch (await
|
|
92
|
+
switch (await config.accountIdEndpointMode?.()) {
|
|
95
93
|
case "disabled":
|
|
96
94
|
(0, import_core2.setFeature)(context, "ACCOUNT_ID_MODE_DISABLED", "Q");
|
|
97
95
|
break;
|
|
@@ -103,8 +101,8 @@ async function checkFeatures(context, config, args) {
|
|
|
103
101
|
break;
|
|
104
102
|
}
|
|
105
103
|
}
|
|
106
|
-
const identity =
|
|
107
|
-
if (identity
|
|
104
|
+
const identity = context.__smithy_context?.selectedHttpAuthScheme?.identity;
|
|
105
|
+
if (identity?.$source) {
|
|
108
106
|
const credentials = identity;
|
|
109
107
|
if (credentials.accountId) {
|
|
110
108
|
(0, import_core2.setFeature)(context, "RESOLVED_ACCOUNT_ID", "T");
|
|
@@ -147,22 +145,21 @@ __name(encodeFeatures, "encodeFeatures");
|
|
|
147
145
|
|
|
148
146
|
// src/user-agent-middleware.ts
|
|
149
147
|
var userAgentMiddleware = /* @__PURE__ */ __name((options) => (next, context) => async (args) => {
|
|
150
|
-
var _a, _b, _c, _d;
|
|
151
148
|
const { request } = args;
|
|
152
149
|
if (!import_protocol_http.HttpRequest.isInstance(request)) {
|
|
153
150
|
return next(args);
|
|
154
151
|
}
|
|
155
152
|
const { headers } = request;
|
|
156
|
-
const userAgent =
|
|
153
|
+
const userAgent = context?.userAgent?.map(escapeUserAgent) || [];
|
|
157
154
|
const defaultUserAgent = (await options.defaultUserAgentProvider()).map(escapeUserAgent);
|
|
158
155
|
await checkFeatures(context, options, args);
|
|
159
156
|
const awsContext = context;
|
|
160
157
|
defaultUserAgent.push(
|
|
161
158
|
`m/${encodeFeatures(
|
|
162
|
-
Object.assign({},
|
|
159
|
+
Object.assign({}, context.__smithy_context?.features, awsContext.__aws_sdk_context?.features)
|
|
163
160
|
)}`
|
|
164
161
|
);
|
|
165
|
-
const customUserAgent =
|
|
162
|
+
const customUserAgent = options?.customUserAgent?.map(escapeUserAgent) || [];
|
|
166
163
|
const appId = await options.userAgentAppId();
|
|
167
164
|
if (appId) {
|
|
168
165
|
defaultUserAgent.push(escapeUserAgent([`app/${appId}`]));
|
|
@@ -187,9 +184,8 @@ var userAgentMiddleware = /* @__PURE__ */ __name((options) => (next, context) =>
|
|
|
187
184
|
});
|
|
188
185
|
}, "userAgentMiddleware");
|
|
189
186
|
var escapeUserAgent = /* @__PURE__ */ __name((userAgentPair) => {
|
|
190
|
-
var _a;
|
|
191
187
|
const name = userAgentPair[0].split(UA_NAME_SEPARATOR).map((part) => part.replace(UA_NAME_ESCAPE_REGEX, UA_ESCAPE_CHAR)).join(UA_NAME_SEPARATOR);
|
|
192
|
-
const version =
|
|
188
|
+
const version = userAgentPair[1]?.replace(UA_VALUE_ESCAPE_REGEX, UA_ESCAPE_CHAR);
|
|
193
189
|
const prefixSeparatorIndex = name.indexOf(UA_NAME_SEPARATOR);
|
|
194
190
|
const prefix = name.substring(0, prefixSeparatorIndex);
|
|
195
191
|
let uaName = name.substring(prefixSeparatorIndex + 1);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-sdk/middleware-user-agent",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.726.0",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'",
|
|
6
6
|
"build:cjs": "node ../../scripts/compilation/inline middleware-user-agent",
|
|
@@ -24,12 +24,12 @@
|
|
|
24
24
|
},
|
|
25
25
|
"license": "Apache-2.0",
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@aws-sdk/core": "3.
|
|
28
|
-
"@aws-sdk/types": "3.
|
|
29
|
-
"@aws-sdk/util-endpoints": "3.
|
|
30
|
-
"@smithy/core": "^
|
|
31
|
-
"@smithy/protocol-http": "^
|
|
32
|
-
"@smithy/types": "^
|
|
27
|
+
"@aws-sdk/core": "3.723.0",
|
|
28
|
+
"@aws-sdk/types": "3.723.0",
|
|
29
|
+
"@aws-sdk/util-endpoints": "3.726.0",
|
|
30
|
+
"@smithy/core": "^3.0.0",
|
|
31
|
+
"@smithy/protocol-http": "^5.0.0",
|
|
32
|
+
"@smithy/types": "^4.0.0",
|
|
33
33
|
"tslib": "^2.6.2"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
@@ -37,10 +37,10 @@
|
|
|
37
37
|
"concurrently": "7.0.0",
|
|
38
38
|
"downlevel-dts": "0.10.1",
|
|
39
39
|
"rimraf": "3.0.2",
|
|
40
|
-
"typescript": "~
|
|
40
|
+
"typescript": "~5.2.2"
|
|
41
41
|
},
|
|
42
42
|
"engines": {
|
|
43
|
-
"node": ">=
|
|
43
|
+
"node": ">=18.0.0"
|
|
44
44
|
},
|
|
45
45
|
"typesVersions": {
|
|
46
46
|
"<4.0": {
|