auth method
Implementation
Future<Map<String, dynamic>> auth(List<dynamic> args) async {
debugPrint("----args--------$args");
final params = processArgs(args);
final data = params['params'];
final missingFields = validateRequiredFields(data['publicKey'], [
"challenge",
"rpId",
]);
if (missingFields.isNotEmpty) {
return FieldErrorModel(
device: await getDeviceInfo(),
).toMap();
}
final List<dynamic> allowCreds = data["publicKey"]["allowCredentials"];
final List<AllowedCredentials> mappedAllowedCreds = allowCreds.map(
(e) {
final Map<String, dynamic> id = e["id"];
return AllowedCredentials(
id: base64UrlEncode(convertAlgToUInt(id)),
type: e["type"],
rawId: convertAlgToUInt(id),
);
},
).toList();
final request = FidoVerifyRequest(
challenge: convertAlgToUInt(data['publicKey']['challenge']),
rpID: data['publicKey']['rpId'],
allowCredentials: mappedAllowedCreds,
);
final result = (await _eztoVerifyFido.verifyFido(request));
final json = result.toJson();
json["device"] = await getDeviceInfo();
json["errorCodes"] = mapErrors(result.errorCode);
debugPrint("Final Result -> $json");
return json;
}