2022-10-04 13:12:54 +03:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2022 Yubico.
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
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-15 19:16:14 +03:00
|
|
|
@freezed
|
|
|
|
class FidoState with _$FidoState {
|
|
|
|
const FidoState._();
|
|
|
|
|
2022-04-03 12:05:37 +03:00
|
|
|
factory FidoState(
|
|
|
|
{required Map<String, dynamic> info,
|
|
|
|
required bool unlocked}) = _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'];
|
2023-05-03 22:20:48 +03:00
|
|
|
|
|
|
|
bool get alwaysUv => info['options']['alwaysUv'] == true;
|
2022-03-17 15:06:48 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
@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
|
|
|
}
|