@aws-sdk/middleware-user-agent 3.721.0 → 3.723.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.
Files changed (2) hide show
  1. package/dist-cjs/index.js +13 -17
  2. 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 = ((_b = (_a = input.logger) == null ? void 0 : _a.constructor) == null ? void 0 : _b.name) === "NoOpLogger" || !input.logger ? console : input.logger;
50
+ const logger = input.logger?.constructor?.name === "NoOpLogger" || !input.logger ? console : input.logger;
52
51
  if (typeof appId !== "string") {
53
- logger == null ? void 0 : logger.warn("userAgentAppId must be a string or undefined.");
52
+ logger?.warn("userAgentAppId must be a string or undefined.");
54
53
  } else if (appId.length > 50) {
55
- logger == null ? void 0 : logger.warn("The provided userAgentAppId exceeds the maximum length of 50 characters.");
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 (((_a = request == null ? void 0 : request.headers) == null ? void 0 : _a["smithy-protocol"]) === "rpc-v2-cbor") {
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 ((_c = (_b = retryStrategy.constructor) == null ? void 0 : _b.name) == null ? void 0 : _c.includes("Adaptive")) {
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((_d = endpointV2 == null ? void 0 : endpointV2.url) == null ? void 0 : _d.hostname).match(ACCOUNT_ID_ENDPOINT_REGEX)) {
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 ((_e = config.accountIdEndpointMode) == null ? void 0 : _e.call(config))) {
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 = (_g = (_f = context.__smithy_context) == null ? void 0 : _f.selectedHttpAuthScheme) == null ? void 0 : _g.identity;
107
- if (identity == null ? void 0 : identity.$source) {
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 = ((_a = context == null ? void 0 : context.userAgent) == null ? void 0 : _a.map(escapeUserAgent)) || [];
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({}, (_b = context.__smithy_context) == null ? void 0 : _b.features, (_c = awsContext.__aws_sdk_context) == null ? void 0 : _c.features)
159
+ Object.assign({}, context.__smithy_context?.features, awsContext.__aws_sdk_context?.features)
163
160
  )}`
164
161
  );
165
- const customUserAgent = ((_d = options == null ? void 0 : options.customUserAgent) == null ? void 0 : _d.map(escapeUserAgent)) || [];
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 = (_a = userAgentPair[1]) == null ? void 0 : _a.replace(UA_VALUE_ESCAPE_REGEX, UA_ESCAPE_CHAR);
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.721.0",
3
+ "version": "3.723.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.716.0",
28
- "@aws-sdk/types": "3.714.0",
29
- "@aws-sdk/util-endpoints": "3.714.0",
30
- "@smithy/core": "^2.5.5",
31
- "@smithy/protocol-http": "^4.1.8",
32
- "@smithy/types": "^3.7.2",
27
+ "@aws-sdk/core": "3.723.0",
28
+ "@aws-sdk/types": "3.723.0",
29
+ "@aws-sdk/util-endpoints": "3.723.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": "~4.9.5"
40
+ "typescript": "~5.2.2"
41
41
  },
42
42
  "engines": {
43
- "node": ">=16.0.0"
43
+ "node": ">=18.0.0"
44
44
  },
45
45
  "typesVersions": {
46
46
  "<4.0": {