@@ -9,16 +9,8 @@ import {
9
9
RequestSigningArguments ,
10
10
} from "@smithy/types" ;
11
11
12
- /**
13
- * @internal
14
- */
15
- export interface SigV4aSigner extends RequestPresigner , RequestSigner {
16
- signWithCredentials (
17
- requestToSign : HttpRequest ,
18
- credentials : AwsCredentialIdentity ,
19
- options : RequestSigningArguments
20
- ) : Promise < HttpRequest > ;
21
- }
12
+ import { OptionalSigV4aSigner , signatureV4aContainer } from "./signature-v4a-container" ;
13
+ import { OptionalCrtSignerV4 , signatureV4CrtContainer } from "./signature-v4-crt-container" ;
22
14
23
15
/**
24
16
* @internal
@@ -36,7 +28,7 @@ export type SignatureV4MultiRegionInit = SignatureV4Init &
36
28
* @internal
37
29
*/
38
30
export class SignatureV4MultiRegion implements RequestPresigner , RequestSigner {
39
- private sigv4aSigner ?: SigV4aSigner ;
31
+ private sigv4aSigner ?: InstanceType < OptionalCrtSignerV4 > | InstanceType < OptionalSigV4aSigner > ;
40
32
private readonly sigv4Signer : SignatureV4S3Express ;
41
33
private readonly signerOptions : SignatureV4MultiRegionInit ;
42
34
@@ -87,12 +79,25 @@ export class SignatureV4MultiRegion implements RequestPresigner, RequestSigner {
87
79
return this . sigv4Signer . presignWithCredentials ( originalRequest , credentials , options ) ;
88
80
}
89
81
90
- private async getSigv4aSigner ( ) : Promise < SigV4aSigner > {
82
+ private async getSigv4aSigner ( ) : Promise < InstanceType < OptionalCrtSignerV4 > | InstanceType < OptionalSigV4aSigner > > {
91
83
if ( ! this . sigv4aSigner ) {
92
- const { SignatureV4a } = await import ( "@smithy/signature-v4a" ) ;
93
- this . sigv4aSigner = new SignatureV4a ( {
94
- ...this . signerOptions ,
95
- } ) as SigV4aSigner ;
84
+ if ( signatureV4CrtContainer . CrtSignerV4 ) {
85
+ // CRT implementation
86
+ this . sigv4aSigner = new signatureV4CrtContainer . CrtSignerV4 ( {
87
+ ...this . signerOptions ,
88
+ signingAlgorithm : 1 ,
89
+ } ) ;
90
+ } else if ( signatureV4aContainer . SignatureV4a ) {
91
+ // SigV4a JS implementation
92
+ this . sigv4aSigner = new signatureV4aContainer . SignatureV4a ( {
93
+ ...this . signerOptions ,
94
+ } ) ;
95
+ } else {
96
+ throw new Error (
97
+ "Neither CRT nor JS SigV4a implementation is available. " +
98
+ "Please load either @aws-sdk/signature-v4-crt or @smithy/signature-v4a."
99
+ ) ;
100
+ }
96
101
}
97
102
return this . sigv4aSigner ;
98
103
}
0 commit comments