AuthenticateRequestType.fromJson constructor

AuthenticateRequestType.fromJson(
  1. Map<String, dynamic> json, {
  2. MediationType mediation = MediationType.Optional,
  3. bool preferImmediatelyAvailableCredentials = true,
})

Constructs a new instance from a JSON map.

Implementation

factory AuthenticateRequestType.fromJson(
  Map<String, dynamic> json, {
  MediationType mediation = MediationType.Optional,
  bool preferImmediatelyAvailableCredentials = true,
}) {
  final allowCredentials = json['allowCredentials'] as List<dynamic>?;

  return AuthenticateRequestType(
    challenge: json['challenge'] as String? ?? '',
    relyingPartyId: json['rpId'] as String? ?? '',
    timeout: json['timeout'] as int?,
    userVerification: json['userVerification'] as String?,
    allowCredentials: allowCredentials != null && allowCredentials.isNotEmpty
        ? allowCredentials
            .whereType<Map<String, dynamic>>()
            .map((e) => CredentialType.fromJson(e))
            .toList()
        : null,
    mediation: mediation,
    preferImmediatelyAvailableCredentials:
        preferImmediatelyAvailableCredentials,
  );
}