-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdevice_passcode_user_verifier_impl.dart
52 lines (46 loc) · 2.08 KB
/
device_passcode_user_verifier_impl.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Copyright © 2023 Nevis Security AG. All rights reserved.
import 'package:flutter/foundation.dart';
import 'package:injectable/injectable.dart';
import 'package:nevis_mobile_authentication_sdk/nevis_mobile_authentication_sdk.dart';
import 'package:nevis_mobile_authentication_sdk_example_app_flutter/domain/blocs/domain_state/domain_bloc.dart';
import 'package:nevis_mobile_authentication_sdk_example_app_flutter/domain/blocs/domain_state/domain_event.dart';
import 'package:nevis_mobile_authentication_sdk_example_app_flutter/domain/error/error_handler.dart';
import 'package:nevis_mobile_authentication_sdk_example_app_flutter/domain/model/error/error.dart';
import 'package:nevis_mobile_authentication_sdk_example_app_flutter/domain/model/operation/user_interaction_operation_state.dart';
import 'package:nevis_mobile_authentication_sdk_example_app_flutter/domain/repository/state_repository.dart';
@Injectable(as: DevicePasscodeUserVerifier)
class DevicePasscodeUserVerifierImpl implements DevicePasscodeUserVerifier {
final DomainBloc _domainBloc;
final ErrorHandler _errorHandler;
final StateRepository<UserInteractionOperationState>
_userInteractionOperationStateRepository;
DevicePasscodeUserVerifierImpl(
this._domainBloc,
this._errorHandler,
this._userInteractionOperationStateRepository,
);
@override
void verifyDevicePasscode(
DevicePasscodeUserVerificationContext context,
DevicePasscodeUserVerificationHandler handler,
) {
debugPrint('Please start device passcode user verification.');
final state = _userInteractionOperationStateRepository.state;
if (state == null) {
_errorHandler.handle(BusinessException.invalidState());
return;
}
_userInteractionOperationStateRepository.save(
state.copyWith(
accountSelectionHandler: null,
authenticatorSelectionHandler: null,
userVerificationHandler: handler,
),
);
_domainBloc.add(DevicePasscodeUserVerificationEvent());
}
@override
void onValidCredentialsProvided() {
debugPrint('Valid device passcode credentials provided.');
}
}