@@ -6,16 +6,28 @@ import type {
6
6
AwsSdkCredentialsFeatures ,
7
7
} from "@aws-sdk/types" ;
8
8
import type { IHttpRequest } from "@smithy/protocol-http" ;
9
- import type { AwsCredentialIdentityProvider , BuildHandlerArguments , Provider } from "@smithy/types" ;
9
+ import type {
10
+ AwsCredentialIdentityProvider ,
11
+ BuildHandlerArguments ,
12
+ Provider ,
13
+ RetryStrategy ,
14
+ RetryStrategyV2 ,
15
+ } from "@smithy/types" ;
10
16
11
17
/**
12
18
* @internal
13
19
*/
14
20
type PreviouslyResolved = Partial < {
15
21
credentials ?: AwsCredentialIdentityProvider ;
16
22
accountIdEndpointMode ?: Provider < AccountIdEndpointMode > ;
23
+ retryStrategy ?: Provider < RetryStrategy | RetryStrategyV2 > ;
17
24
} > ;
18
25
26
+ /**
27
+ * @internal
28
+ */
29
+ const ACCOUNT_ID_ENDPOINT_REGEX = / \d { 12 } \. d d b / ;
30
+
19
31
/**
20
32
* @internal
21
33
* Check for features that don't have a middleware activation site but
@@ -26,9 +38,30 @@ export async function checkFeatures(
26
38
config : PreviouslyResolved ,
27
39
args : BuildHandlerArguments < any >
28
40
) : Promise < void > {
29
- // eslint-disable-next-line
30
41
const request = args . request as IHttpRequest ;
42
+
43
+ if ( request ?. headers ?. [ "smithy-protocol" ] === "rpc-v2-cbor" ) {
44
+ setFeature ( context , "PROTOCOL_RPC_V2_CBOR" , "M" ) ;
45
+ }
46
+
47
+ if ( typeof config . retryStrategy === "function" ) {
48
+ const retryStrategy = await config . retryStrategy ( ) ;
49
+ if ( typeof ( retryStrategy as RetryStrategyV2 ) . acquireInitialRetryToken === "function" ) {
50
+ if ( retryStrategy . constructor ?. name ?. includes ( "Adaptive" ) ) {
51
+ setFeature ( context , "RETRY_MODE_ADAPTIVE" , "F" ) ;
52
+ } else {
53
+ setFeature ( context , "RETRY_MODE_STANDARD" , "E" ) ;
54
+ }
55
+ } else {
56
+ setFeature ( context , "RETRY_MODE_LEGACY" , "D" ) ;
57
+ }
58
+ }
59
+
31
60
if ( typeof config . accountIdEndpointMode === "function" ) {
61
+ const endpointV2 = context . endpointV2 ;
62
+ if ( String ( endpointV2 ?. url ?. hostname ) . match ( ACCOUNT_ID_ENDPOINT_REGEX ) ) {
63
+ setFeature ( context , "ACCOUNT_ID_ENDPOINT" , "O" ) ;
64
+ }
32
65
switch ( await config . accountIdEndpointMode ?.( ) ) {
33
66
case "disabled" :
34
67
setFeature ( context , "ACCOUNT_ID_MODE_DISABLED" , "Q" ) ;
0 commit comments