amplify-swift icon indicating copy to clipboard operation
amplify-swift copied to clipboard

Allow Devs to Adjust for Large Clock Skew Errors

Open Odoyle-Rules opened this issue 4 months ago • 2 comments

Is your feature request related to a problem? Please describe.

I am currently migrating an iOS app from the AWS SDK for iOS to Amplify for Swift. The conversion was really easy and smooth, and I'm loving the new API. Before the final push, I was going through my standard tests when I noticed a failure. There is a test case I run that manually sets the iPhone time beyond 5 minutes from the current time and the AWSAPIPlugin requests get rejected due to excessive clock skew (I get a 403 with InvalidSignatureException) on the initial request and the retry. When we were using the old SDK, I was able to calculate the offset from the error message from the server and manually set an offset that would get used and negate whatever weird time change the user felt like imposing. I am not seeing an equivalent work around in Amplify for Swift. I was using NSDate.aws_setRuntimeClockSkew to manage this issue in the old SDK. I am able to grab the server time from the error response and calculate the offset, but I have no way to apply it to the API calls, I need a way to apply this offset to the API calls.

Describe the solution you'd like

I'd like to see a way to manually (or automatically) adjust for larger time differences between the server and the user's device in Amplify for Swift. Whether that is in the RESTRequest body or headers, or a function call within Amplify I do not have a preference.

Describe alternatives you've considered

I've tried experimenting with timestamp fields in headers and request bodies, but nothing I tried fixed the issue.

Is the feature request related to any of the existing Amplify categories?

API

Additional context

No response

Odoyle-Rules avatar Aug 12 '25 20:08 Odoyle-Rules

Hi @Odoyle-Rules,

The conversion was really easy and smooth, and I'm loving the new API

Glad to hear this!

As far as setting a clock skew, this appears to still be an open ticket on the AWS Swift SDK, which is the underlying SDK that Amplify Swift uses. The issue is tracked here: https://github.com/awslabs/aws-sdk-swift/issues/654

I'll try and reach out to the team to see if they have looked any more into it. It appears that Amplify Android does not have this concern as the AWS Kotlin SDK team implemented skew detection with automatic resolutions: https://github.com/awslabs/aws-sdk-kotlin/issues/213

tylerjroach avatar Aug 12 '25 20:08 tylerjroach

This has been identified as a feature request. If this feature is important to you, we strongly encourage you to give a 👍 reaction on the request. This helps us prioritize new features most important to you. Thank you!

github-actions[bot] avatar Aug 12 '25 20:08 github-actions[bot]