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 'cancelled':
        throw PasskeyAuthCancelledException();
      case 'android-no-credential':
        throw MissingGoogleSignInException();
      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;
        }
    }
  }
}