@@ -45,6 +45,9 @@ interface AwsSdkSigV4AuthSigningProperties {
45
45
*/
46
46
interface AwsSdkSigV4Exception extends ServiceException {
47
47
ServerTime ?: string ;
48
+ $metadata : ServiceException [ "$metadata" ] & {
49
+ clockSkewCorrected ?: boolean ;
50
+ } ;
48
51
}
49
52
50
53
/**
@@ -103,12 +106,15 @@ export class AwsSdkSigV4Signer implements HttpSigner {
103
106
return ( error : Error ) => {
104
107
const serverTime : string | undefined =
105
108
( error as AwsSdkSigV4Exception ) . ServerTime ?? getDateHeader ( ( error as AwsSdkSigV4Exception ) . $response ) ;
109
+
106
110
if ( serverTime ) {
107
- const config = throwSigningPropertyError (
108
- "config" ,
109
- signingProperties . config as AwsSdkSigV4Config | undefined
110
- ) ;
111
+ const config = throwSigningPropertyError ( "config" , signingProperties . config as AwsSdkSigV4Config | undefined ) ;
112
+ const initialSystemClockOffset = config . systemClockOffset ;
111
113
config . systemClockOffset = getUpdatedSystemClockOffset ( serverTime , config . systemClockOffset ) ;
114
+ const clockSkewCorrected = config . systemClockOffset !== initialSystemClockOffset ;
115
+ if ( clockSkewCorrected ) {
116
+ ( error as AwsSdkSigV4Exception ) . $metadata . clockSkewCorrected = true ;
117
+ }
112
118
}
113
119
throw error ;
114
120
} ;
@@ -117,10 +123,7 @@ export class AwsSdkSigV4Signer implements HttpSigner {
117
123
successHandler ( httpResponse : HttpResponse | unknown , signingProperties : Record < string , unknown > ) : void {
118
124
const dateHeader = getDateHeader ( httpResponse ) ;
119
125
if ( dateHeader ) {
120
- const config = throwSigningPropertyError (
121
- "config" ,
122
- signingProperties . config as AwsSdkSigV4Config | undefined
123
- ) ;
126
+ const config = throwSigningPropertyError ( "config" , signingProperties . config as AwsSdkSigV4Config | undefined ) ;
124
127
config . systemClockOffset = getUpdatedSystemClockOffset ( dateHeader , config . systemClockOffset ) ;
125
128
}
126
129
}
0 commit comments