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

fix(auth): add deprecated signInDetails type to AuthTokens type #12981

Merged
merged 5 commits into from
Feb 20, 2024

Conversation

ashwinkumar6
Copy link
Contributor

@ashwinkumar6 ashwinkumar6 commented Feb 8, 2024

Description of changes

fetchAuthSession API returns "signInDetails", example

const session = await fetchAuthSession();
session.tokens?.signInDetails

However the return type of this API (AuthSession) does not have this type resulting a signInDetails does not exist on type error

Solution:

  • Encourage the use of getCurrentUser API to obtain signInDetails
  • Add deprecated type to fetchAuthSession to avoid type error

Issue #, if available

#12868

Description of how you validated changes

Before
Screenshot 2024-02-07 at 5 01 14 PM
After
Screenshot 2024-02-07 at 4 45 25 PM

Checklist

  • PR description included
  • yarn test passes
  • Tests are changed or added
  • Relevant documentation is changed or added (and PR referenced)

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

@ashwinkumar6 ashwinkumar6 requested review from a team as code owners February 8, 2024 01:26
Copy link
Contributor

@israx israx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The introduction of signInDetails into the getCurrentUser API ended up affecting the output of fetchAuthSession, both APIs consume the same underlying functionality from the Amplify singleton, and it was a miss to detect that in our tests.

The solution to the fix is actually introducing a deprecation warning, which seems totally fine to me. However we are modifying a public interface, which means that we might need to have a follow up with a BR and product.

Other than fixing this issue, ideally we might want to prevent this from happening again. So as an action item, we could add tests to detect the right number of keys expected by a given output.

@josefaidt
Copy link
Contributor

This change looks good to me!

@palpatim
Copy link
Member

palpatim commented Feb 9, 2024

Seems reasonable to me, as long as we document it on our API spec. Please ping @haverchuck as well.

@haverchuck
Copy link
Contributor

Looks good to me as well. API doc will be updated.

Copy link
Contributor

@israx israx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ashwinkumar6 ashwinkumar6 merged commit b758843 into aws-amplify:main Feb 20, 2024
30 checks passed
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.

None yet

8 participants