aws-amplify / amplify-js

A declarative JavaScript library for application development using cloud services.
https://docs.amplify.aws/lib/q/platform/js
Apache License 2.0
9.36k stars 2.1k forks source link

fix(auth): impossibility to sign-in when RandomKeyPassword is missing #13288

Closed israx closed 3 weeks ago

israx commented 3 weeks ago

Description of changes

Authenticating with device management will store device keys in the storage mechanism. If some of those keys are removed the authentication flow will fail and not let the user to authenticate.

This change checks if all the keys are available in storage, otherwise it will return null. When null is returned then no device keys are added to the RespondToAuthChallenge request, which allows to continue the authentication flow.

Test cases:

  1. it checks if a device key was included in the ResponseToAuthChallenge request.
  2. it checks that a device key was not included in the ResponseToAuthChallenge request when any device key is deleted from storage.

Issue #, if available

https://github.com/aws-amplify/amplify-js/issues/9366

Description of how you validated changes

smoke testing

Checklist

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