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

chore(auth): Refactor to eliminate circular dependencies #14173

Merged

Conversation

cshfang
Copy link
Member

@cshfang cshfang commented Jan 29, 2025

Description of changes

Prior to [email protected], analyzing the Auth package for circular dependencies yields no issues:

$ git checkout [email protected]
$ npx dpdm -T --no-tree --no-warning packages/auth/src/index.ts

✅ Congratulations, no circular dependency was found in your project.

With the introduction of [email protected], the same analysis shows circular dependencies were introduced:

$ git checkout [email protected]
$ npx dpdm -T --no-tree --no-warning packages/auth/src/index.ts

1) packages/auth/src/providers/cognito/utils/signInHelpers.ts -> packages/auth/src/client/flows/userAuth/handleWebAuthnSignInResult.ts
2) packages/auth/src/providers/cognito/utils/signInHelpers.ts -> packages/auth/src/client/flows/shared/handlePasswordSRP.ts
3) packages/auth/src/providers/cognito/utils/signInHelpers.ts -> packages/auth/src/client/flows/userAuth/handleSelectChallengeWithPassword.ts
4) packages/auth/src/providers/cognito/utils/signInHelpers.ts -> packages/auth/src/client/flows/userAuth/handleSelectChallengeWithPasswordSRP.ts

This PR extracts functions from the monolithic signInHelpers to eliminate the circular dependencies

$ git checkout chore/eliminate-circular-dependencies
$ npx dpdm -T --no-tree --no-warning packages/auth/src/index.ts

✅ Congratulations, no circular dependency was found in your project.

Issue #, if available

#14150

Description of how you validated changes

  • Ran the dpdm analyzer to ensure the Auth entry point no longer resulted in circular dependencies.
  • Published changes locally to Verdaccio and ran the Webauthn E2E tests
  • yarn test

Checklist

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

Checklist for repo maintainers

  • Verify E2E tests for existing workflows are working as expected or add E2E tests for newly added workflows
  • New source file paths included in this PR have been added to CODEOWNERS, if appropriate

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

ashika112
ashika112 previously approved these changes Jan 29, 2025
jjarvisp
jjarvisp previously approved these changes Jan 30, 2025
Copy link
Member

@jjarvisp jjarvisp left a comment

Choose a reason for hiding this comment

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

Looks good to me. Is it worth adding a test to check for circular dependencies in the future?

@cshfang cshfang dismissed stale reviews from ashika112 and jjarvisp via 255949f January 30, 2025 18:07
@cshfang cshfang requested a review from a team as a code owner January 30, 2025 18:07
@cshfang cshfang merged commit 25dbd61 into aws-amplify:main Jan 30, 2025
31 of 40 checks passed
@cshfang cshfang deleted the chore/eliminate-circular-dependencies branch February 4, 2025 00:42
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.

4 participants