isRequired static method

bool isRequired(
  1. DVHttpResponse response
)

Whether response is the server asking for a second factor (DV-SESSION-001) rather than any other refusal.

Implementation

static bool isRequired(DVHttpResponse response) {
  if (response.statusCode != 401) return false;
  try {
    final Object? decoded = jsonDecode(response.body);
    return decoded is Map && decoded['error'] == 'mfa_required';
  } on FormatException {
    return false;
  }
}