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: using enum instead of strings for auth step types #1251

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

jcaleb4
Copy link
Collaborator

@jcaleb4 jcaleb4 commented Dec 20, 2024

Pull Request Checklist


PR-Codex overview

This PR primarily focuses on refactoring the authStep handling in the authentication components by replacing string literals with an AuthStepType enum for improved type safety and maintainability.

Detailed summary

  • Introduced AuthStepType enum to replace string literals in setAuthStep calls.
  • Updated multiple components to use AuthStepType for various authentication steps.
  • Ensured consistent handling of authStep types across the application.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Copy link

vercel bot commented Dec 20, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
aa-sdk-site ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 13, 2025 5:28pm
aa-sdk-ui-demo ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 13, 2025 5:28pm

Copy link

graphite-app bot commented Dec 20, 2024

How to use the Graphite Merge Queue

Add the label graphite-merge-queue to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

Copy link
Collaborator

@moldy530 moldy530 left a comment

Choose a reason for hiding this comment

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

What's the motivation for this change? we use string consts in other places of the code base and actually use enums fairly sparingly

Comment on lines 8 to 19
email_verify = "email_verify",
otp_verify = "otp_verify",
passkey_verify = "passkey_verify",
passkey_create = "passkey_create",
passkey_create_success = "passkey_create_success",
email_completing = "email_completing",
oauth_completing = "oauth_completing",
initial = "initial",
complete = "complete",
eoa_connect = "eoa_connect",
wallet_connect = "wallet_connect",
pick_eoa = "pick_eoa",
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: for the enum name, can we do capital case? ie EmailVerify

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

change is done

@jcaleb4
Copy link
Collaborator Author

jcaleb4 commented Jan 13, 2025

@moldy530 my motivation for this PR is just that while working around the auth flow I felt the need to unify the source of the auth steps, I know it may be an opinionated change, but one of the advantages of using TS is that we can centralize these kind of things.

In my personal experience, using strings (specially in big teams) gets to be really messy at some point and takes out several advantages of using TS with enums:

  • Type safety
  • readability and self-documentation
  • maintainability
  • intelisense support
  • consistency

I know there are several other places where you're using strings instead of enums, I just wanted to propose making this change because it makes sense to me; this is not required or anything, it is just me thinking that enums in this particular case would be a better use

Base automatically changed from caleb/otp-styles to main January 21, 2025 19:17
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.

2 participants