Skip to content

Commit a05c7c8

Browse files
Handle passkey authenticator and unknown authenticator added in future
ref DEV-3027
2 parents cfde737 + d84dbf1 commit a05c7c8

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

lib/src/authenticator.dart

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ enum AuthenticatorType {
1616
oobOtpEmail,
1717
oobOtpSms,
1818
totp,
19+
passkey,
20+
unknown,
1921
}
2022

2123
extension AuthenticatorTypeExtension on AuthenticatorType {
@@ -29,6 +31,10 @@ extension AuthenticatorTypeExtension on AuthenticatorType {
2931
return "oob_otp_sms";
3032
case AuthenticatorType.totp:
3133
return "totp";
34+
case AuthenticatorType.passkey:
35+
return "passkey";
36+
case AuthenticatorType.unknown:
37+
return "unknown";
3238
}
3339
}
3440

@@ -42,15 +48,18 @@ extension AuthenticatorTypeExtension on AuthenticatorType {
4248
return AuthenticatorType.oobOtpSms;
4349
case "totp":
4450
return AuthenticatorType.totp;
51+
case "passkey":
52+
return AuthenticatorType.passkey;
4553
default:
46-
throw Exception("unknown authenticator type: $value");
54+
return AuthenticatorType.unknown;
4755
}
4856
}
4957
}
5058

5159
enum AuthenticatorKind {
5260
primary,
5361
secondary,
62+
unknown,
5463
}
5564

5665
extension AuthenticatorKindExtension on AuthenticatorKind {
@@ -60,6 +69,8 @@ extension AuthenticatorKindExtension on AuthenticatorKind {
6069
return "primary";
6170
case AuthenticatorKind.secondary:
6271
return "secondary";
72+
case AuthenticatorKind.unknown:
73+
return "unknown";
6374
}
6475
}
6576

@@ -70,7 +81,7 @@ extension AuthenticatorKindExtension on AuthenticatorKind {
7081
case "secondary":
7182
return AuthenticatorKind.secondary;
7283
default:
73-
throw Exception("unknown authenticator kind: $value");
84+
return AuthenticatorKind.unknown;
7485
}
7586
}
7687
}

0 commit comments

Comments
 (0)