Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(predictions): add web socket retry for clock skew #3816

Merged
merged 2 commits into from
Aug 19, 2024

Conversation

thisisabhash
Copy link
Member

Issue #

Some liveness customers are setting up date on the device manually. This causes a clock skew when AWS Rekognition server time is different than device time and the signature calculated is incorrect. AWS Rekognition supports a maximum skew of 5 minutes. This leads to customer receiving IncorrectSignatureException.

Description

This change adds a one-time retry for web socket connection when an InvalidSignatureException is received.
This is in line with Android implementation here : aws-amplify/amplify-android#2634

Testing

Happy path - I performed manual testing by setting the device date manually for +1hr and -1hr of actual time. I tested for both cases when preview screen is enabled or not enabled in the FaceLivenessDetectorView component.

Error path - I uncommented the line

websocket.onServerDateReceived { [weak self] serverDate in
    self?.serverDate = serverDate
}

to mimic the case when we don't receive Date header in

urlSession(
    _ session: URLSession,
    task: URLSessionTask,
    didFinishCollecting metrics: URLSessionTaskMetrics
)

delegate callback. I tested for both cases when preview screen is enabled or not enabled in the FaceLivenessDetectorView component.

General Checklist

  • Added new tests to cover change, if needed
  • Build succeeds with all target using Swift Package Manager
  • All unit tests pass
  • All integration tests pass
  • Security oriented best practices and standards are followed (e.g. using input sanitization, principle of least privilege, etc)
  • Documentation update for the change if required
  • PR title conforms to conventional commit style
  • New or updated tests include Given When Then inline code documentation and are named accordingly testThing_condition_expectation()
  • If breaking change, documentation/changelog update with migration instructions

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Copy link
Contributor

API Breakage Report

✅ No Public API Breaking Change detected

Copy link

codecov bot commented Aug 15, 2024

Codecov Report

Attention: Patch coverage is 0% with 69 lines in your changes missing coverage. Please review.

Project coverage is 68.63%. Comparing base (acb7dee) to head (3dc15b0).
Report is 10 commits behind head on main.

Files Patch % Lines
...sPlugin/Liveness/Service/FaceLivenessSession.swift 0.00% 35 Missing ⚠️
...ionsPlugin/Liveness/Service/WebSocketSession.swift 0.00% 29 Missing ⚠️
...gin/Dependency/AWSTranscribeStreamingAdapter.swift 0.00% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3816      +/-   ##
==========================================
+ Coverage   68.54%   68.63%   +0.09%     
==========================================
  Files        1080     1080              
  Lines       37608    37647      +39     
==========================================
+ Hits        25778    25840      +62     
+ Misses      11830    11807      -23     
Flag Coverage Δ
API_plugin_unit_test 68.96% <ø> (ø)
AWSPluginsCore 68.56% <ø> (ø)
Amplify 47.56% <ø> (ø)
Analytics_plugin_unit_test 84.52% <ø> (ø)
Auth_plugin_unit_test 79.73% <ø> (-0.02%) ⬇️
DataStore_plugin_unit_test 82.22% <ø> (+0.94%) ⬆️
Geo_plugin_unit_test 72.00% <ø> (ø)
Logging_plugin_unit_test 62.95% <ø> (ø)
Predictions_plugin_unit_test 36.86% <0.00%> (-0.46%) ⬇️
PushNotifications_plugin_unit_test 86.21% <ø> (ø)
Storage_plugin_unit_test 76.81% <ø> (ø)
unit_tests 68.63% <0.00%> (+0.09%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

API Breakage Report

✅ No Public API Breaking Change detected

@thisisabhash thisisabhash merged commit 5d54b5d into main Aug 19, 2024
80 checks passed
@thisisabhash thisisabhash deleted the feat/clock-skew-websocket-retry branch August 19, 2024 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants