diff --git a/packages/gotrue/lib/src/types/mfa.dart b/packages/gotrue/lib/src/types/mfa.dart index cfdd2f05..148f3b1f 100644 --- a/packages/gotrue/lib/src/types/mfa.dart +++ b/packages/gotrue/lib/src/types/mfa.dart @@ -257,7 +257,25 @@ class AuthMFAGetAuthenticatorAssuranceLevelResponse { }); } -enum AMRMethod { password, otp, oauth, totp, magiclink } +enum AMRMethod { + password('password'), + otp('otp'), + oauth('oauth'), + totp('totp'), + magiclink('magiclink'), + recovery('recovery'), + invite('invite'), + ssoSaml('sso/saml'), + emailSignUp('email/signup'), + emailChange('email_change'), + tokenRefresh('token_refresh'), + anonymous('anonymous'), + mfaPhone('mfa/phone'), + unknown('unknown'); + + final String code; + const AMRMethod(this.code); +} /// An authentication method reference (AMR) entry. /// @@ -278,7 +296,8 @@ class AMREntry { factory AMREntry.fromJson(Map json) { return AMREntry( method: AMRMethod.values.firstWhere( - (e) => e.name == json['method'], + (e) => e.code == json['method'], + orElse: () => AMRMethod.unknown, ), timestamp: DateTime.fromMillisecondsSinceEpoch(json['timestamp'] * 1000), );