diff --git a/packages/rx_bloc_cli/mason_templates/bricks/lib_mfa/__brick__/lib/lib_mfa/methods/pin_biometric/services/mfa_pincode_service.dart b/packages/rx_bloc_cli/mason_templates/bricks/lib_mfa/__brick__/lib/lib_mfa/methods/pin_biometric/services/mfa_pincode_service.dart index 32888cef4..b09949495 100644 --- a/packages/rx_bloc_cli/mason_templates/bricks/lib_mfa/__brick__/lib/lib_mfa/methods/pin_biometric/services/mfa_pincode_service.dart +++ b/packages/rx_bloc_cli/mason_templates/bricks/lib_mfa/__brick__/lib/lib_mfa/methods/pin_biometric/services/mfa_pincode_service.dart @@ -33,9 +33,7 @@ class MfaPinCodeService extends PinCodeService { Future getPinLength() => _pinCodeRepository.getPinLength(); @override - Future isPinCodeInSecureStorage() async { - return await _pinCodeRepository.readPinFromStorage(key: storedPin) != null; - } + Future savePinCodeInSecureStorage(String pinCode) async => false; @override Future encryptPinCode(String pinCode) async => diff --git a/packages/rx_bloc_cli/mason_templates/bricks/lib_mfa/__brick__/lib/lib_mfa/methods/pin_biometric/views/mfa_pin_biometrics_page.dart b/packages/rx_bloc_cli/mason_templates/bricks/lib_mfa/__brick__/lib/lib_mfa/methods/pin_biometric/views/mfa_pin_biometrics_page.dart index b67af0ea5..db2f342af 100644 --- a/packages/rx_bloc_cli/mason_templates/bricks/lib_mfa/__brick__/lib/lib_mfa/methods/pin_biometric/views/mfa_pin_biometrics_page.dart +++ b/packages/rx_bloc_cli/mason_templates/bricks/lib_mfa/__brick__/lib/lib_mfa/methods/pin_biometric/views/mfa_pin_biometrics_page.dart @@ -51,7 +51,7 @@ class MfaPinBiometricsPage extends StatelessWidget { .pop(Result.success(response)); } }, // Handle error states - autoBiometricAuth: true, + autoPromptBiometric: true, biometricsLocalDataSource: context.read(), pinCodeService: context.read(), diff --git a/packages/rx_bloc_cli/mason_templates/bricks/lib_pin_code/__brick__/lib/lib_pin_code/services/create_pin_code_service.dart b/packages/rx_bloc_cli/mason_templates/bricks/lib_pin_code/__brick__/lib/lib_pin_code/services/create_pin_code_service.dart index eaef3fe13..f0b725cb6 100644 --- a/packages/rx_bloc_cli/mason_templates/bricks/lib_pin_code/__brick__/lib/lib_pin_code/services/create_pin_code_service.dart +++ b/packages/rx_bloc_cli/mason_templates/bricks/lib_pin_code/__brick__/lib/lib_pin_code/services/create_pin_code_service.dart @@ -23,11 +23,9 @@ class CreatePinCodeService implements PinCodeService { } @override - Future isPinCodeInSecureStorage() async { - if (firstPin != null) { - return true; - } - return null != await _pinCodeRepository.readPinFromStorage(key: _storedPin); + Future savePinCodeInSecureStorage(String pinCode) async { + await _pinCodeRepository.writePinToStorage(_storedPin, pinCode); + return true; } Future checkIsPinCreated() async => diff --git a/packages/rx_bloc_cli/mason_templates/bricks/lib_pin_code/__brick__/lib/lib_pin_code/services/verify_pin_code_service.dart b/packages/rx_bloc_cli/mason_templates/bricks/lib_pin_code/__brick__/lib/lib_pin_code/services/verify_pin_code_service.dart index b659e3405..c653f6875 100644 --- a/packages/rx_bloc_cli/mason_templates/bricks/lib_pin_code/__brick__/lib/lib_pin_code/services/verify_pin_code_service.dart +++ b/packages/rx_bloc_cli/mason_templates/bricks/lib_pin_code/__brick__/lib/lib_pin_code/services/verify_pin_code_service.dart @@ -25,8 +25,9 @@ class VerifyPinCodeService implements PinCodeService { } @override - Future isPinCodeInSecureStorage() async => - await pinCodeRepository.readPinFromStorage(key: storedPin) != null; + Future savePinCodeInSecureStorage(String pinCode) async { + return false; + } Future checkIsPinCreated() async => await pinCodeRepository.getPinCode() != null; diff --git a/packages/rx_bloc_cli/mason_templates/bricks/lib_pin_code/__brick__/lib/lib_pin_code/views/verify_pin_code_page.dart b/packages/rx_bloc_cli/mason_templates/bricks/lib_pin_code/__brick__/lib/lib_pin_code/views/verify_pin_code_page.dart index 403629bb9..c0e2c0289 100644 --- a/packages/rx_bloc_cli/mason_templates/bricks/lib_pin_code/__brick__/lib/lib_pin_code/views/verify_pin_code_page.dart +++ b/packages/rx_bloc_cli/mason_templates/bricks/lib_pin_code/__brick__/lib/lib_pin_code/views/verify_pin_code_page.dart @@ -46,7 +46,7 @@ class VerifyPinCodePage extends StatelessWidget { children: [ Expanded( child: PinCodeKeyboard( - autoBiometricAuth: true, + autoPromptBiometric: true, mapBiometricMessageToString: (message) => _exampleMapMessageToString(message, context), pinCodeService: context.read(), diff --git a/packages/rx_bloc_cli/mason_templates/bricks/lib_pin_code/__brick__/test/lib_pin_code/blocs/create_pin_bloc_test.dart b/packages/rx_bloc_cli/mason_templates/bricks/lib_pin_code/__brick__/test/lib_pin_code/blocs/create_pin_bloc_test.dart index 248c69022..2d95786b9 100644 --- a/packages/rx_bloc_cli/mason_templates/bricks/lib_pin_code/__brick__/test/lib_pin_code/blocs/create_pin_bloc_test.dart +++ b/packages/rx_bloc_cli/mason_templates/bricks/lib_pin_code/__brick__/test/lib_pin_code/blocs/create_pin_bloc_test.dart @@ -19,7 +19,7 @@ void main() { String? encryptedPinCode, bool isPinCorrect = false, bool isPinCreated = false, - bool isPinCodeInSecureStorage = false, + bool savePinCodeInSecureStorage = false, bool isPinDeleted = false, }) { when(coordinatorStates.userLoggedIn) @@ -33,8 +33,8 @@ void main() { when(createPinCodeService.checkIsPinCreated()) .thenAnswer((_) => Future.value(isPinCreated)); - when(createPinCodeService.isPinCodeInSecureStorage()) - .thenAnswer((_) => Future.value(isPinCodeInSecureStorage)); + when(createPinCodeService.savePinCodeInSecureStorage(pinCode ?? '')) + .thenAnswer((_) => Future.value(savePinCodeInSecureStorage)); if (pinCode != null) { if (encryptedPinCode != null) { diff --git a/packages/rx_bloc_cli/mason_templates/bricks/lib_pin_code/__brick__/test/lib_pin_code/blocs/update_and_verify_pin_bloc_test.dart b/packages/rx_bloc_cli/mason_templates/bricks/lib_pin_code/__brick__/test/lib_pin_code/blocs/update_and_verify_pin_bloc_test.dart index 79f7f21f5..b93ea6269 100644 --- a/packages/rx_bloc_cli/mason_templates/bricks/lib_pin_code/__brick__/test/lib_pin_code/blocs/update_and_verify_pin_bloc_test.dart +++ b/packages/rx_bloc_cli/mason_templates/bricks/lib_pin_code/__brick__/test/lib_pin_code/blocs/update_and_verify_pin_bloc_test.dart @@ -24,7 +24,7 @@ void main() { String? encryptedPinCode, bool isPinCorrect = false, bool isPinCreated = false, - bool isPinCodeInSecureStorage = false, + bool savePinCodeInSecureStorage = false, bool isPinDeleted = false, }) { when(coordinatorStates.userLoggedIn) @@ -47,8 +47,8 @@ void main() { when(verifyPinCodeService.checkIsPinCreated()) .thenAnswer((_) => Future.value(isPinCreated)); - when(verifyPinCodeService.isPinCodeInSecureStorage()) - .thenAnswer((_) => Future.value(isPinCodeInSecureStorage)); + when(verifyPinCodeService.savePinCodeInSecureStorage(pinCode ?? '')) + .thenAnswer((_) => Future.value(false)); if (pinCode != null) { if (encryptedPinCode != null) { diff --git a/packages/rx_bloc_cli/mason_templates/bricks/lib_pin_code/__brick__/test/lib_pin_code/mock/update_pin_code_service_mock.dart b/packages/rx_bloc_cli/mason_templates/bricks/lib_pin_code/__brick__/test/lib_pin_code/mock/update_pin_code_service_mock.dart index ed216263b..a2784207d 100644 --- a/packages/rx_bloc_cli/mason_templates/bricks/lib_pin_code/__brick__/test/lib_pin_code/mock/update_pin_code_service_mock.dart +++ b/packages/rx_bloc_cli/mason_templates/bricks/lib_pin_code/__brick__/test/lib_pin_code/mock/update_pin_code_service_mock.dart @@ -10,7 +10,7 @@ UpdatePinCodeService updatePinCodeServiceMockFactory({ }) { final mockUpdatePinCodeService = MockUpdatePinCodeService(); - when(mockUpdatePinCodeService.isPinCodeInSecureStorage()) + when(mockUpdatePinCodeService.savePinCodeInSecureStorage('1234')) .thenAnswer((_) async => showBiometricsButton); when(mockUpdatePinCodeService.getPinLength()).thenAnswer((_) async => 4); diff --git a/packages/rx_bloc_cli/mason_templates/bricks/lib_pin_code/__brick__/test/lib_pin_code/mock/verify_pin_code_service_mock.dart b/packages/rx_bloc_cli/mason_templates/bricks/lib_pin_code/__brick__/test/lib_pin_code/mock/verify_pin_code_service_mock.dart index 2bf8a522d..a0f0ee77c 100644 --- a/packages/rx_bloc_cli/mason_templates/bricks/lib_pin_code/__brick__/test/lib_pin_code/mock/verify_pin_code_service_mock.dart +++ b/packages/rx_bloc_cli/mason_templates/bricks/lib_pin_code/__brick__/test/lib_pin_code/mock/verify_pin_code_service_mock.dart @@ -10,7 +10,7 @@ VerifyPinCodeService verifyPinCodeServiceMockFactory({ }) { final mockVerifyPinCodeService = MockVerifyPinCodeService(); - when(mockVerifyPinCodeService.isPinCodeInSecureStorage()) + when(mockVerifyPinCodeService.savePinCodeInSecureStorage('1234')) .thenAnswer((_) async => showBiometricsButton); when(mockVerifyPinCodeService.getPinLength()).thenAnswer((_) async => 4); diff --git a/packages/rx_bloc_cli/mason_templates/bricks/lib_pin_code/__brick__/test/lib_pin_code/services/create_pin_code_service_test.dart b/packages/rx_bloc_cli/mason_templates/bricks/lib_pin_code/__brick__/test/lib_pin_code/services/create_pin_code_service_test.dart index 44939ee32..1eec8b888 100644 --- a/packages/rx_bloc_cli/mason_templates/bricks/lib_pin_code/__brick__/test/lib_pin_code/services/create_pin_code_service_test.dart +++ b/packages/rx_bloc_cli/mason_templates/bricks/lib_pin_code/__brick__/test/lib_pin_code/services/create_pin_code_service_test.dart @@ -35,25 +35,27 @@ void main() { verify(repository.getPinCode()).called(1); }); - test('isPinCodeInSecureStorage should return true', () async { + test('savePinCodeInSecureStorage should return true', () async { const pinKey = VerifyPinCodeService.storedPin; - when(repository.readPinFromStorage(key: pinKey)) + when(repository.writePinToStorage(pinKey, Stubs.pin)) .thenAnswer((_) async => Stubs.pin); - final result = await permissionsService.isPinCodeInSecureStorage(); + final result = + await permissionsService.savePinCodeInSecureStorage(Stubs.pin); expect(result, true); - verify(repository.readPinFromStorage(key: pinKey)).called(1); + verify(repository.writePinToStorage(pinKey, Stubs.pin)).called(1); }); - test('isPinCodeInSecureStorage should return false', () async { + test('savePinCodeInSecureStorage should return false', () async { const pinKey = VerifyPinCodeService.storedPin; when(repository.readPinFromStorage(key: pinKey)) .thenAnswer((_) async => null); - final result = await permissionsService.isPinCodeInSecureStorage(); + final result = + await permissionsService.savePinCodeInSecureStorage(pinKey); expect(result, false); verify(repository.readPinFromStorage(key: pinKey)).called(1); diff --git a/packages/rx_bloc_cli/mason_templates/bricks/lib_pin_code/__brick__/test/lib_pin_code/services/verify_pin_code_service_test.dart b/packages/rx_bloc_cli/mason_templates/bricks/lib_pin_code/__brick__/test/lib_pin_code/services/verify_pin_code_service_test.dart index b2e3f48a9..f294bcff0 100644 --- a/packages/rx_bloc_cli/mason_templates/bricks/lib_pin_code/__brick__/test/lib_pin_code/services/verify_pin_code_service_test.dart +++ b/packages/rx_bloc_cli/mason_templates/bricks/lib_pin_code/__brick__/test/lib_pin_code/services/verify_pin_code_service_test.dart @@ -40,29 +40,17 @@ void main() { .called(1); }); - test('isPinCodeInSecureStorage should return true', () async { + test('savePinCodeInSecureStorage should return false', () async { const pinKey = VerifyPinCodeService.storedPin; const pin = Stubs.pin; - when(repository.readPinFromStorage(key: pinKey)) + when(repository.writePinToStorage(pinKey, pin)) .thenAnswer((_) async => pin); - final result = await service.isPinCodeInSecureStorage(); - - expect(result, true); - verify(repository.readPinFromStorage(key: pinKey)).called(1); - }); - - test('isPinCodeInSecureStorage should return false', () async { - const pinKey = VerifyPinCodeService.storedPin; - - when(repository.readPinFromStorage(key: pinKey)) - .thenAnswer((_) async => null); - - final result = await service.isPinCodeInSecureStorage(); + final result = await service.savePinCodeInSecureStorage(pin); expect(result, false); - verify(repository.readPinFromStorage(key: pinKey)).called(1); + verifyNever(repository.writePinToStorage(pinKey, pin)); }); test('checkIsPinCreated should return true', () async { diff --git a/packages/rx_bloc_cli/mason_templates/bricks/lib_router/__brick__/lib/lib_router/blocs/router_bloc.dart b/packages/rx_bloc_cli/mason_templates/bricks/lib_router/__brick__/lib/lib_router/blocs/router_bloc.dart index c218cf433..da87fe9f1 100644 --- a/packages/rx_bloc_cli/mason_templates/bricks/lib_router/__brick__/lib/lib_router/blocs/router_bloc.dart +++ b/packages/rx_bloc_cli/mason_templates/bricks/lib_router/__brick__/lib/lib_router/blocs/router_bloc.dart @@ -82,16 +82,10 @@ class RouterBloc extends $RouterBloc { @override ConnectableStream _mapToNavigationPathState() => Rx.merge([ - _$goEvent - .throttleTime(const Duration(seconds: 1)) - .switchMap((routeData) => _go(routeData).asResultStream()), - _$pushEvent - .throttleTime(const Duration(seconds: 1)) - .switchMap((routeData) => _push(routeData).asResultStream()), + _$goEvent.switchMap((routeData) => _go(routeData).asResultStream()), + _$pushEvent.switchMap((routeData) => _push(routeData).asResultStream()), _$goToLocationEvent.doOnData(_router.go).asResultStream(), - _$pushReplaceEvent - .throttleTime(const Duration(seconds: 1)) - .switchMap((routeData) => _pushReplace(routeData).asResultStream()), + _$pushReplaceEvent.switchMap((routeData) => _pushReplace(routeData).asResultStream()), _$popEvent.doOnData(_pop).asResultStream(), ]).setErrorStateHandler(this).whereSuccess().publish(); diff --git a/packages/rx_bloc_cli/mason_templates/bricks/rx_bloc_base/__brick__/lib/feature_splash/blocs/splash_bloc.dart b/packages/rx_bloc_cli/mason_templates/bricks/rx_bloc_base/__brick__/lib/feature_splash/blocs/splash_bloc.dart index 85aaf12d5..29bb81b7f 100644 --- a/packages/rx_bloc_cli/mason_templates/bricks/rx_bloc_base/__brick__/lib/feature_splash/blocs/splash_bloc.dart +++ b/packages/rx_bloc_cli/mason_templates/bricks/rx_bloc_base/__brick__/lib/feature_splash/blocs/splash_bloc.dart @@ -78,7 +78,7 @@ class SplashBloc extends $SplashBloc { {{#enable_pin_code}} if (await _authService.isAuthenticated()) { - if(await _pinCodeService.isPinCodeInSecureStorage()) { + if (await _pinCodeService.getPinCode() == null) { return _navigationBloc.events.go(const VerifyPinCodeRoute(), extra: const PinCodeArguments(title: 'Enter Pin Code')); } diff --git a/packages/rx_bloc_cli/mason_templates/bricks/rx_bloc_base/__brick__/pubspec.yaml b/packages/rx_bloc_cli/mason_templates/bricks/rx_bloc_base/__brick__/pubspec.yaml index 29ea625e4..c5703b35d 100644 --- a/packages/rx_bloc_cli/mason_templates/bricks/rx_bloc_base/__brick__/pubspec.yaml +++ b/packages/rx_bloc_cli/mason_templates/bricks/rx_bloc_base/__brick__/pubspec.yaml @@ -50,7 +50,7 @@ dependencies: {{#enable_dev_menu}} widget_toolkit: ^0.2.0 {{#enable_pin_code}} widget_toolkit_biometrics: ^0.1.0 {{/enable_pin_code}} {{#enable_feature_otp}} widget_toolkit_otp: ^0.1.0{{/enable_feature_otp}}{{#enable_pin_code}} - widget_toolkit_pin: ^0.2.1{{/enable_pin_code}}{{#enable_feature_qr_scanner}} + widget_toolkit_pin: ^0.3.0{{/enable_pin_code}}{{#enable_feature_qr_scanner}} widget_toolkit_qr: ^0.2.0{{/enable_feature_qr_scanner}} @@ -73,13 +73,6 @@ dev_dependencies: rx_bloc_generator: ^8.0.0 rx_bloc_test: ^5.0.0 test: any {{#enable_patrol}} - -dependency_overrides: - widget_toolkit_pin: - git: - url: https://github.com/Prime-Holding/widget_toolkit.git - path: packages/widget_toolkit_pin - ref: feature/auto-biometrics-option patrol: app_name: {{project_name}}