-
Notifications
You must be signed in to change notification settings - Fork 13
feat: EWM-617 check root #1120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
feat: EWM-617 check root #1120
Changes from all commits
64a1974
fd96f03
cb8ec24
0484a34
91e044e
7c404b3
0551c10
c0772d8
d978523
9511104
cef57d0
e2df018
2abce2f
0254ad8
8390f58
04340eb
117cbbb
71c5f15
0b2d8f0
2e16a69
682f027
d1d6b9e
892ce3e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -791,5 +791,16 @@ | |||
| "passwordLockedUntil": "Password locked until {}", | ||||
| "invalidPayloadError": "Payload is invalid", | ||||
| "invalidStateInitError": "StateInit is invalid", | ||||
| "unsupportedWalletTypeError": "Unsupported wallet type" | ||||
| "unsupportedWalletTypeError": "Unsupported wallet type", | ||||
| "rootDetectedTitle": "Root / Jailbreak detected", | ||||
| "rootDetectedDescription": "This device has a modified security environment. Wallet security cannot be guaranteed.", | ||||
| "rootDetectedRisk": "By continuing, you acknowledge\nand accept the associated risks", | ||||
| "rootDetectedAccept": "I understand and accept the risks", | ||||
| "rootInfoTitle": "Why this matters", | ||||
| "rootInfoDescription": "Root/Jailbreak weakens system security restrictions, allowing other apps or system modifications to interfere with the wallet’s operation", | ||||
| "whatYouCanDo": "What you can do:", | ||||
|
||||
| "whatYouCanDo": "What you can do:", |
knightsforce marked this conversation as resolved.
Show resolved
Hide resolved
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| import 'package:app/app/router/compass/guard.dart'; | ||
| import 'package:app/app/router/router.dart'; | ||
| import 'package:app/app/service/navigation_service.dart'; | ||
| import 'package:app/feature/onboarding/route.dart'; | ||
| import 'package:app/feature/wallet/route.dart'; | ||
| import 'package:injectable/injectable.dart'; | ||
| import 'package:logging/logging.dart'; | ||
| import 'package:nekoton_repository/nekoton_repository.dart'; | ||
|
|
||
| @injectable | ||
| class BootstrapNavigationDelegate { | ||
| BootstrapNavigationDelegate( | ||
| this._nekotonRepository, | ||
| this._navigationService, | ||
| this._router, | ||
| ); | ||
|
|
||
| final NekotonRepository _nekotonRepository; | ||
| final NavigationService _navigationService; | ||
| final CompassRouter _router; | ||
|
|
||
| bool? get hasSeeds => _nekotonRepository.hasSeeds.valueOrNull; | ||
|
|
||
| final _logger = Logger('BootstrapNavigationDelegate'); | ||
|
|
||
| Future<void> goToResultBootstrap() async { | ||
| if (hasSeeds == false) { | ||
| _logger.info('Initial navigation. Navigate to onboarding'); | ||
| _router.compassPoint(const OnBoardingRouteData()); | ||
| return; | ||
| } | ||
|
|
||
| final savedNavigation = await _navigationService.getSavedState(); | ||
|
|
||
| if (savedNavigation != null) { | ||
| _logger.info('Initial navigation. Navigate to $savedNavigation'); | ||
| // Use CompassRouter methods for all navigation to maintain consistency | ||
| _router.compassPoint( | ||
| UnsafeRedirectCompassRouteData(route: savedNavigation), | ||
| ); | ||
| } else { | ||
| _logger.info('Initial navigation. Navigate to wallet'); | ||
| _router.compassPoint(const WalletRouteData()); | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,26 +1,21 @@ | ||
| import 'dart:async'; | ||
|
|
||
| import 'package:app/app/router/compass/compass.dart'; | ||
| import 'package:app/app/service/bootstrap/bootstrap_steps.dart'; | ||
| import 'package:app/app/view/app.dart'; | ||
| import 'package:app/app/view/app_model.dart'; | ||
| import 'package:app/app/view/message_viewer.dart'; | ||
| import 'package:app/core/wm/custom_wm.dart'; | ||
| import 'package:app/feature/onboarding/route.dart'; | ||
| import 'package:app/feature/wallet/route.dart'; | ||
| import 'package:app/feature/root_device_alert/route.dart'; | ||
| import 'package:easy_localization/easy_localization.dart'; | ||
| import 'package:elementary/elementary.dart'; | ||
| import 'package:flutter/widgets.dart'; | ||
| import 'package:injectable/injectable.dart'; | ||
| import 'package:logging/logging.dart'; | ||
|
|
||
| /// [WidgetModel] для [App] | ||
| @injectable | ||
| class AppWidgetModel extends CustomWidgetModel<App, AppModel> { | ||
| AppWidgetModel(super.model); | ||
|
|
||
| final _logger = Logger('AppWidgetModel'); | ||
|
|
||
| late final _messageViewer = MessageViewer( | ||
| messagesExistStream: model.messagesExistStream, | ||
| getRootContext: () => model.navContext, | ||
|
|
@@ -62,23 +57,10 @@ class AppWidgetModel extends CustomWidgetModel<App, AppModel> { | |
| await _bootstrapStepsSubs?.cancel(); | ||
| _bootstrapStepsSubs = null; | ||
|
|
||
| if (model.hasSeeds == false) { | ||
| _logger.info('Initial navigation. Navigate to onboarding'); | ||
| router.compassPoint(const OnBoardingRouteData()); | ||
| return; | ||
| } | ||
|
|
||
| final savedNavigation = await model.getSavedNavigation(); | ||
|
|
||
| if (savedNavigation != null) { | ||
| _logger.info('Initial navigation. Navigate to $savedNavigation'); | ||
| // Use CompassRouter methods for all navigation to maintain consistency | ||
| router.compassPoint( | ||
| UnsafeRedirectCompassRouteData(route: savedNavigation), | ||
| ); | ||
| if (await model.isShowRootScreen) { | ||
| router.compassPoint(const RootDeviceAlertRouteData()); | ||
| } else { | ||
| _logger.info('Initial navigation. Navigate to wallet'); | ||
| router.compassPoint(const WalletRouteData()); | ||
| model.next(); | ||
| } | ||
| } | ||
|
Comment on lines
57
to
65
|
||
| } | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| import 'dart:io'; | ||
|
|
||
| import 'package:injectable/injectable.dart'; | ||
| import 'package:root_checker_plus/root_checker_plus.dart'; | ||
| import 'package:shared_preferences/shared_preferences.dart'; | ||
|
|
||
| @injectable | ||
| class RootDeviceDelegate { | ||
knightsforce marked this conversation as resolved.
Show resolved
Hide resolved
knightsforce marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| static const userKnowsRootKey = 'user_know_root'; | ||
|
|
||
| Future<bool> get isShowRootScreen async { | ||
| return await _isRootDevice && !(await _isUserKnowRoot); | ||
| } | ||
|
|
||
| Future<bool> get _isRootDevice async { | ||
| if (Platform.isAndroid) { | ||
| return (await RootCheckerPlus.isRootChecker()) ?? false; | ||
| } else if (Platform.isIOS) { | ||
| return (await RootCheckerPlus.isJailbreak()) ?? false; | ||
| } | ||
|
|
||
| return true; | ||
knightsforce marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| Future<bool> get _isUserKnowRoot async { | ||
| final prefs = await SharedPreferences.getInstance(); | ||
|
|
||
| return prefs.getBool(userKnowsRootKey) ?? false; | ||
| } | ||
|
|
||
| Future<bool> setUserKnowRoot() async { | ||
| final prefs = await SharedPreferences.getInstance(); | ||
|
|
||
| return prefs.setBool(userKnowsRootKey, true); | ||
| } | ||
knightsforce marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
knightsforce marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Uh oh!
There was an error while loading. Please reload this page.