@@ -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
/**
@@ -104,11 +107,13 @@ export class AwsSdkSigV4Signer implements HttpSigner {
104
107
const serverTime : string | undefined =
105
108
( error as AwsSdkSigV4Exception ) . ServerTime ?? getDateHeader ( ( error as AwsSdkSigV4Exception ) . $response ) ;
106
109
if ( serverTime ) {
107
- const config = throwSigningPropertyError (
108
- "config" ,
109
- signingProperties . config as AwsSdkSigV4Config | undefined
110
- ) ;
110
+ const config = throwSigningPropertyError ( "config" , signingProperties . config as AwsSdkSigV4Config | undefined ) ;
111
+ const initialSystemClockOffset = config . systemClockOffset ;
111
112
config . systemClockOffset = getUpdatedSystemClockOffset ( serverTime , config . systemClockOffset ) ;
113
+ const clockSkewCorrected = config . systemClockOffset !== initialSystemClockOffset ;
114
+ if ( clockSkewCorrected && ( error as AwsSdkSigV4Exception ) . $metadata ) {
115
+ ( error as AwsSdkSigV4Exception ) . $metadata . clockSkewCorrected = true ;
116
+ }
112
117
}
113
118
throw error ;
114
119
} ;
@@ -117,10 +122,7 @@ export class AwsSdkSigV4Signer implements HttpSigner {
117
122
successHandler ( httpResponse : HttpResponse | unknown , signingProperties : Record < string , unknown > ) : void {
118
123
const dateHeader = getDateHeader ( httpResponse ) ;
119
124
if ( dateHeader ) {
120
- const config = throwSigningPropertyError (
121
- "config" ,
122
- signingProperties . config as AwsSdkSigV4Config | undefined
123
- ) ;
125
+ const config = throwSigningPropertyError ( "config" , signingProperties . config as AwsSdkSigV4Config | undefined ) ;
124
126
config . systemClockOffset = getUpdatedSystemClockOffset ( dateHeader , config . systemClockOffset ) ;
125
127
}
126
128
}
0 commit comments