verifyRegistration method

Future<Result<PasskeyRecord>> verifyRegistration(
  1. Map<String, dynamic> body
)

POST /passkey/verify-registration

Body must contain response (RegistrationResponseJSON from @simplewebauthn) and optional name.

Implementation

Future<Result<PasskeyRecord>> verifyRegistration(
  Map<String, dynamic> body,
) async {
  try {
    final response = await _dio.post<Map<String, dynamic>?>(
      '$_root/passkey/verify-registration',
      data: body,
      options: _jsonOptions(_dio),
    );
    final data = response.data;
    if (data == null) {
      return Result.err(
        BetterError(message: 'Empty verify-registration response', stack: ''),
      );
    }
    return Result.ok(PasskeyRecord.fromJson(data));
  } on DioException catch (e, s) {
    return _passkeyErr(e, s, e);
  } catch (e, s) {
    return Result.err(
      BetterError(message: e.toString(), stack: s.toString()),
    );
  }
}