2022-03-15 19:16:14 +03:00
|
|
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
|
|
|
|
|
|
|
part 'models.freezed.dart';
|
|
|
|
part 'models.g.dart';
|
|
|
|
|
2022-03-17 22:10:10 +03:00
|
|
|
enum InteractionEvent { remove, insert, touch }
|
|
|
|
|
2022-03-22 16:23:12 +03:00
|
|
|
enum SubPage { main, fingerprints, credentials }
|
|
|
|
|
2022-03-15 19:16:14 +03:00
|
|
|
@freezed
|
|
|
|
class FidoState with _$FidoState {
|
|
|
|
const FidoState._();
|
|
|
|
|
2022-03-23 19:50:49 +03:00
|
|
|
factory FidoState({required Map<String, dynamic> info}) = _FidoState;
|
2022-03-15 19:16:14 +03:00
|
|
|
|
|
|
|
factory FidoState.fromJson(Map<String, dynamic> json) =>
|
|
|
|
_$FidoStateFromJson(json);
|
|
|
|
|
|
|
|
bool get hasPin => info['options']['clientPin'] == true;
|
2022-03-17 15:06:48 +03:00
|
|
|
|
|
|
|
int get minPinLength => info['min_pin_length'] as int;
|
|
|
|
|
|
|
|
bool get credMgmt =>
|
|
|
|
info['options']['credMgmt'] == true ||
|
|
|
|
info['options']['credentialMgmtPreview'] == true;
|
|
|
|
|
|
|
|
bool? get bioEnroll => info['options']['bioEnroll'];
|
|
|
|
}
|
|
|
|
|
|
|
|
@freezed
|
|
|
|
class PinResult with _$PinResult {
|
2022-03-22 16:23:12 +03:00
|
|
|
factory PinResult.success() = _PinSuccess;
|
|
|
|
factory PinResult.failed(int retries, bool authBlocked) = _PinFailure;
|
|
|
|
}
|
|
|
|
|
|
|
|
@freezed
|
|
|
|
class Fingerprint with _$Fingerprint {
|
2022-03-23 11:49:20 +03:00
|
|
|
const Fingerprint._();
|
|
|
|
factory Fingerprint(String templateId, String? name) = _Fingerprint;
|
|
|
|
|
|
|
|
factory Fingerprint.fromJson(Map<String, dynamic> json) =>
|
|
|
|
_$FingerprintFromJson(json);
|
|
|
|
|
|
|
|
String get label => name ?? 'Unnamed (ID: $templateId)';
|
2022-03-22 16:23:12 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
@freezed
|
|
|
|
class FingerprintEvent with _$FingerprintEvent {
|
|
|
|
factory FingerprintEvent.capture(int remaining) = _EventCapture;
|
2022-03-23 11:49:20 +03:00
|
|
|
factory FingerprintEvent.complete(Fingerprint fingerprint) = _EventComplete;
|
2022-03-22 16:23:12 +03:00
|
|
|
factory FingerprintEvent.error(int code) = _EventError;
|
|
|
|
}
|
|
|
|
|
|
|
|
@freezed
|
|
|
|
class FidoCredential with _$FidoCredential {
|
2022-03-23 19:50:49 +03:00
|
|
|
factory FidoCredential({
|
|
|
|
required String rpId,
|
|
|
|
required String credentialId,
|
|
|
|
required String userId,
|
|
|
|
required String userName,
|
|
|
|
}) = _FidoCredential;
|
|
|
|
|
|
|
|
factory FidoCredential.fromJson(Map<String, dynamic> json) =>
|
|
|
|
_$FidoCredentialFromJson(json);
|
2022-03-15 19:16:14 +03:00
|
|
|
}
|