@@ -45,6 +45,9 @@ interface AwsSdkSigV4AuthSigningProperties {
4545 */
4646interface AwsSdkSigV4Exception extends ServiceException {
4747 ServerTime ?: string ;
48+ $metadata : ServiceException [ "$metadata" ] & {
49+ clockSkewCorrected ?: boolean ;
50+ } ;
4851}
4952
5053/**
@@ -104,11 +107,13 @@ export class AwsSdkSigV4Signer implements HttpSigner {
104107 const serverTime : string | undefined =
105108 ( error as AwsSdkSigV4Exception ) . ServerTime ?? getDateHeader ( ( error as AwsSdkSigV4Exception ) . $response ) ;
106109 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 ;
111112 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+ }
112117 }
113118 throw error ;
114119 } ;
@@ -117,10 +122,7 @@ export class AwsSdkSigV4Signer implements HttpSigner {
117122 successHandler ( httpResponse : HttpResponse | unknown , signingProperties : Record < string , unknown > ) : void {
118123 const dateHeader = getDateHeader ( httpResponse ) ;
119124 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 ) ;
124126 config . systemClockOffset = getUpdatedSystemClockOffset ( dateHeader , config . systemClockOffset ) ;
125127 }
126128 }
0 commit comments