Skip to content

feat(gotrue): Add phone mfa enrollment #1188

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

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

Conversation

dshukertjr
Copy link
Member

@dshukertjr dshukertjr commented Jun 6, 2025

What kind of change does this PR introduce?

feature of adding phone support for MFA enrollment

JS PR here: supabase/auth-js#932

What is the current behavior?

Enrolling in MFA via SMS is supported .

What is the new behavior?

SMS MFA is not supported.

@coveralls
Copy link

coveralls commented Jun 6, 2025

Pull Request Test Coverage Report for Build 15482416459

Details

  • 25 of 32 (78.13%) changed or added relevant lines in 2 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage decreased (-0.06%) to 75.345%

Changes Missing Coverage Covered Lines Changed/Added Lines %
packages/gotrue/lib/src/types/mfa.dart 10 17 58.82%
Files with Coverage Reduction New Missed Lines %
packages/gotrue/lib/src/fetch.dart 1 91.36%
Totals Coverage Status
Change from base Build 15425969446: -0.06%
Covered Lines: 2894
Relevant Lines: 3841

💛 - Coveralls

@dshukertjr dshukertjr changed the title feat: Phone mfa enrollment feat(gotrue): Add phone mfa enrollment Jun 6, 2025
/// TOTP enrollment information.
final TOTPEnrollment totp;
/// TOTP enrollment information (only present when type is totp).
final TOTPEnrollment? totp;
Copy link
Member Author

Choose a reason for hiding this comment

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

I know this isn't great, but I think we can call it that it's a fix. Open to suggestions to avoid this though.

Copy link
Contributor

Choose a reason for hiding this comment

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

Comment on lines +59 to +66
if (factorType == FactorType.totp) {
body['issuer'] = issuer;
} else if (factorType == FactorType.phone) {
if (phone == null) {
throw ArgumentError('Phone number is required for phone factor type');
}
body['phone'] = phone;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Lets validate that an issuer needs to be provided for the totp factor type also.

Suggested change
if (factorType == FactorType.totp) {
body['issuer'] = issuer;
} else if (factorType == FactorType.phone) {
if (phone == null) {
throw ArgumentError('Phone number is required for phone factor type');
}
body['phone'] = phone;
}
if (factorType == FactorType.totp && issuer != null) {
body['issuer'] = issuer;
} else if (factorType == FactorType.phone && phone != null) {
body['phone'] = phone;
} else {
throw ArgumentError('Invalid arguments, expected an issuer for totp factor type or phone for phone factor. type');
}

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