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();
    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();
      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;
        }
    }
  }
}