@aws-sdk/middleware-user-agent 3.668.0 → 3.669.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 CHANGED
@@ -67,11 +67,31 @@ var import_protocol_http = require("@smithy/protocol-http");
67
67
 
68
68
  // src/check-features.ts
69
69
  var import_core2 = require("@aws-sdk/core");
70
+ var ACCOUNT_ID_ENDPOINT_REGEX = /\d{12}\.ddb/;
70
71
  async function checkFeatures(context, config, args) {
71
- var _a, _b, _c;
72
+ var _a, _b, _c, _d, _e, _f, _g;
72
73
  const request = args.request;
74
+ if (((_a = request == null ? void 0 : request.headers) == null ? void 0 : _a["smithy-protocol"]) === "rpc-v2-cbor") {
75
+ (0, import_core2.setFeature)(context, "PROTOCOL_RPC_V2_CBOR", "M");
76
+ }
77
+ if (typeof config.retryStrategy === "function") {
78
+ const retryStrategy = await config.retryStrategy();
79
+ if (typeof retryStrategy.acquireInitialRetryToken === "function") {
80
+ if ((_c = (_b = retryStrategy.constructor) == null ? void 0 : _b.name) == null ? void 0 : _c.includes("Adaptive")) {
81
+ (0, import_core2.setFeature)(context, "RETRY_MODE_ADAPTIVE", "F");
82
+ } else {
83
+ (0, import_core2.setFeature)(context, "RETRY_MODE_STANDARD", "E");
84
+ }
85
+ } else {
86
+ (0, import_core2.setFeature)(context, "RETRY_MODE_LEGACY", "D");
87
+ }
88
+ }
73
89
  if (typeof config.accountIdEndpointMode === "function") {
74
- switch (await ((_a = config.accountIdEndpointMode) == null ? void 0 : _a.call(config))) {
90
+ const endpointV2 = context.endpointV2;
91
+ if (String((_d = endpointV2 == null ? void 0 : endpointV2.url) == null ? void 0 : _d.hostname).match(ACCOUNT_ID_ENDPOINT_REGEX)) {
92
+ (0, import_core2.setFeature)(context, "ACCOUNT_ID_ENDPOINT", "O");
93
+ }
94
+ switch (await ((_e = config.accountIdEndpointMode) == null ? void 0 : _e.call(config))) {
75
95
  case "disabled":
76
96
  (0, import_core2.setFeature)(context, "ACCOUNT_ID_MODE_DISABLED", "Q");
77
97
  break;
@@ -83,7 +103,7 @@ async function checkFeatures(context, config, args) {
83
103
  break;
84
104
  }
85
105
  }
86
- const identity = (_c = (_b = context.__smithy_context) == null ? void 0 : _b.selectedHttpAuthScheme) == null ? void 0 : _c.identity;
106
+ const identity = (_g = (_f = context.__smithy_context) == null ? void 0 : _f.selectedHttpAuthScheme) == null ? void 0 : _g.identity;
87
107
  if (identity == null ? void 0 : identity.$source) {
88
108
  const credentials = identity;
89
109
  if (credentials.accountId) {
@@ -1,7 +1,29 @@
1
1
  import { setFeature } from "@aws-sdk/core";
2
+ const ACCOUNT_ID_ENDPOINT_REGEX = /\d{12}\.ddb/;
2
3
  export async function checkFeatures(context, config, args) {
3
4
  const request = args.request;
5
+ if (request?.headers?.["smithy-protocol"] === "rpc-v2-cbor") {
6
+ setFeature(context, "PROTOCOL_RPC_V2_CBOR", "M");
7
+ }
8
+ if (typeof config.retryStrategy === "function") {
9
+ const retryStrategy = await config.retryStrategy();
10
+ if (typeof retryStrategy.acquireInitialRetryToken === "function") {
11
+ if (retryStrategy.constructor?.name?.includes("Adaptive")) {
12
+ setFeature(context, "RETRY_MODE_ADAPTIVE", "F");
13
+ }
14
+ else {
15
+ setFeature(context, "RETRY_MODE_STANDARD", "E");
16
+ }
17
+ }
18
+ else {
19
+ setFeature(context, "RETRY_MODE_LEGACY", "D");
20
+ }
21
+ }
4
22
  if (typeof config.accountIdEndpointMode === "function") {
23
+ const endpointV2 = context.endpointV2;
24
+ if (String(endpointV2?.url?.hostname).match(ACCOUNT_ID_ENDPOINT_REGEX)) {
25
+ setFeature(context, "ACCOUNT_ID_ENDPOINT", "O");
26
+ }
5
27
  switch (await config.accountIdEndpointMode?.()) {
6
28
  case "disabled":
7
29
  setFeature(context, "ACCOUNT_ID_MODE_DISABLED", "Q");
@@ -1,12 +1,13 @@
1
1
  import type { AccountIdEndpointMode } from "@aws-sdk/core/account-id-endpoint";
2
2
  import type { AwsHandlerExecutionContext } from "@aws-sdk/types";
3
- import type { AwsCredentialIdentityProvider, BuildHandlerArguments, Provider } from "@smithy/types";
3
+ import type { AwsCredentialIdentityProvider, BuildHandlerArguments, Provider, RetryStrategy, RetryStrategyV2 } from "@smithy/types";
4
4
  /**
5
5
  * @internal
6
6
  */
7
7
  type PreviouslyResolved = Partial<{
8
8
  credentials?: AwsCredentialIdentityProvider;
9
9
  accountIdEndpointMode?: Provider<AccountIdEndpointMode>;
10
+ retryStrategy?: Provider<RetryStrategy | RetryStrategyV2>;
10
11
  }>;
11
12
  /**
12
13
  * @internal
@@ -4,10 +4,13 @@ import {
4
4
  AwsCredentialIdentityProvider,
5
5
  BuildHandlerArguments,
6
6
  Provider,
7
+ RetryStrategy,
8
+ RetryStrategyV2,
7
9
  } from "@smithy/types";
8
10
  type PreviouslyResolved = Partial<{
9
11
  credentials?: AwsCredentialIdentityProvider;
10
12
  accountIdEndpointMode?: Provider<AccountIdEndpointMode>;
13
+ retryStrategy?: Provider<RetryStrategy | RetryStrategyV2>;
11
14
  }>;
12
15
  export declare function checkFeatures(
13
16
  context: AwsHandlerExecutionContext,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-sdk/middleware-user-agent",
3
- "version": "3.668.0",
3
+ "version": "3.669.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",