authenticate method
Authenticates a user with a passkey. Returns AuthenticateResponseType which must be sent to the relying party server.
Implementation
Future<AuthenticateResponseType> authenticate(
AuthenticateRequestType request,
) async {
try {
await _platform.cancelCurrentAuthenticatorOperation();
_isValidChallenge(request.challenge);
if (request.allowCredentials != null) {
for (final credential in request.allowCredentials!) {
_isValidCredentialID(credential.id);
}
}
final r = await _platform.authenticate(request);
return r;
} on PlatformException catch (e) {
switch (e.code) {
case 'domain-not-associated':
throw DomainNotAssociatedException(e.message);
case 'no-credentials-available':
throw NoCredentialsAvailableException();
case 'cancelled':
throw PasskeyAuthCancelledException();
case 'android-no-credential':
throw NoCredentialsAvailableException();
case 'deviceNotSupported':
throw DeviceNotSupportedException();
case 'android-no-create-option':
throw NoCreateOptionException(e.message);
case 'android-timeout':
throw TimeoutException(e.message);
case 'ios-security-key-timeout':
throw TimeoutException(e.message);
default:
if (e.code.startsWith('android-unhandled')) {
throw UnhandledAuthenticatorException(e.code, e.message, e.details);
} else if (e.code.startsWith('ios-unhandled')) {
throw UnhandledAuthenticatorException(e.code, e.message, e.details);
} else {
rethrow;
}
}
}
}