-
-
Notifications
You must be signed in to change notification settings - Fork 273
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(suite-native): add DeviceCompromisedModal for FW revision check
- Loading branch information
Showing
14 changed files
with
224 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"name": "@suite-native/module-authenticity-checks", | ||
"version": "1.0.0", | ||
"private": true, | ||
"license": "See LICENSE.md in repo root", | ||
"sideEffects": false, | ||
"main": "src/index", | ||
"scripts": { | ||
"depcheck": "yarn g:depcheck", | ||
"lint:js": "yarn g:eslint '**/*.{ts,tsx,js}'", | ||
"type-check": "yarn g:tsc --build" | ||
}, | ||
"dependencies": { | ||
"@react-navigation/native": "6.1.18", | ||
"@react-navigation/native-stack": "6.11.0", | ||
"@suite-common/wallet-core": "workspace:*", | ||
"@suite-native/atoms": "workspace:*", | ||
"@suite-native/intl": "workspace:*", | ||
"@suite-native/link": "workspace:*", | ||
"@suite-native/navigation": "workspace:*", | ||
"react-redux": "8.0.7" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './navigation/AuthenticityChecksStackNavigator'; | ||
export * from './screens/DeviceCompromisedModalScreen'; |
23 changes: 23 additions & 0 deletions
23
suite-native/module-authenticity-checks/src/navigation/AuthenticityChecksStackNavigator.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { createNativeStackNavigator } from '@react-navigation/native-stack'; | ||
|
||
import { | ||
AuthenticityChecksStackParamList, | ||
AuthenticityChecksStackRoutes, | ||
stackNavigationOptionsConfig, | ||
} from '@suite-native/navigation'; | ||
|
||
import { DeviceCompromisedModalScreen } from '../screens/DeviceCompromisedModalScreen'; | ||
|
||
const AuthenticityChecksStack = createNativeStackNavigator<AuthenticityChecksStackParamList>(); | ||
|
||
export const AuthenticityChecksStackNavigator = () => ( | ||
<AuthenticityChecksStack.Navigator | ||
initialRouteName={AuthenticityChecksStackRoutes.DeviceCompromisedModal} | ||
screenOptions={stackNavigationOptionsConfig} | ||
> | ||
<AuthenticityChecksStack.Screen | ||
name={AuthenticityChecksStackRoutes.DeviceCompromisedModal} | ||
component={DeviceCompromisedModalScreen} | ||
/> | ||
</AuthenticityChecksStack.Navigator> | ||
); |
92 changes: 92 additions & 0 deletions
92
suite-native/module-authenticity-checks/src/screens/DeviceCompromisedModalScreen.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import { useDispatch, useSelector } from 'react-redux'; | ||
|
||
import { useNavigation } from '@react-navigation/native'; | ||
|
||
import { deviceActions, selectSelectedDevice } from '@suite-common/wallet-core'; | ||
import { Button, IconListTextItem, TitleHeader, VStack } from '@suite-native/atoms'; | ||
import { Translation } from '@suite-native/intl'; | ||
import { useOpenLink } from '@suite-native/link'; | ||
import { | ||
AppTabsRoutes, | ||
HomeStackRoutes, | ||
RootStackParamList, | ||
RootStackRoutes, | ||
Screen, | ||
ScreenHeader, | ||
StackToStackCompositeNavigationProps, | ||
} from '@suite-native/navigation'; | ||
|
||
// TODO this page is for desktop; await creation of new page tailored to the suite-native UX | ||
const TREZOR_SUPPORT_FW_REVISION_CHECK_FAILED_URL = | ||
'https://trezor.io/support/a/trezor-fw-revision-check-failed'; | ||
|
||
const InformativeList = () => ( | ||
<VStack spacing="sp24"> | ||
<IconListTextItem icon="handPalm" variant="red"> | ||
<Translation id="moduleAuthenticityChecks.deviceCompromised.steps.avoidUsingDevice" /> | ||
</IconListTextItem> | ||
|
||
<IconListTextItem icon="chatCircle" variant="red"> | ||
<Translation id="moduleAuthenticityChecks.deviceCompromised.steps.contactSupport" /> | ||
</IconListTextItem> | ||
</VStack> | ||
); | ||
|
||
type NavigationProp = StackToStackCompositeNavigationProps< | ||
RootStackParamList, | ||
RootStackRoutes.AppTabs, | ||
RootStackParamList | ||
>; | ||
|
||
export const DeviceCompromisedModalScreen = () => { | ||
const device = useSelector(selectSelectedDevice); | ||
const dispatch = useDispatch(); | ||
|
||
const navigation = useNavigation<NavigationProp>(); | ||
|
||
const dismissCheck = () => { | ||
if (device?.id) { | ||
dispatch(deviceActions.dismissFirmwareAuthenticityCheck(device.id)); | ||
} | ||
}; | ||
|
||
const handleClose = () => { | ||
if (navigation.canGoBack()) { | ||
navigation.goBack(); | ||
} else { | ||
navigation.navigate(RootStackRoutes.AppTabs, { | ||
screen: AppTabsRoutes.HomeStack, | ||
params: { screen: HomeStackRoutes.Home }, | ||
}); | ||
} | ||
dismissCheck(); | ||
}; | ||
|
||
const chatUrl = `${TREZOR_SUPPORT_FW_REVISION_CHECK_FAILED_URL}#open-chat`; | ||
const openLink = useOpenLink(); | ||
const handleContactSupportClick = () => openLink(chatUrl); | ||
|
||
return ( | ||
<Screen header={<ScreenHeader closeActionType="close" closeAction={dismissCheck} />}> | ||
<VStack spacing="sp32" flex={1}> | ||
<TitleHeader | ||
titleVariant="titleMedium" | ||
titleSpacing="sp12" | ||
title={<Translation id="moduleAuthenticityChecks.deviceCompromised.title" />} | ||
subtitle={ | ||
<Translation id="moduleAuthenticityChecks.deviceCompromised.subtitle" /> | ||
} | ||
/> | ||
<InformativeList /> | ||
</VStack> | ||
<VStack spacing="sp12"> | ||
<Button colorScheme="redBold" onPress={handleContactSupportClick}> | ||
<Translation id="moduleAuthenticityChecks.deviceCompromised.buttonContactSupport" /> | ||
</Button> | ||
<Button colorScheme="redElevation0" onPress={handleClose}> | ||
<Translation id="moduleAuthenticityChecks.deviceCompromised.buttonClose" /> | ||
</Button> | ||
</VStack> | ||
</Screen> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"extends": "../../tsconfig.base.json", | ||
"compilerOptions": { "outDir": "libDev" }, | ||
"references": [ | ||
{ | ||
"path": "../../suite-common/wallet-core" | ||
}, | ||
{ "path": "../atoms" }, | ||
{ "path": "../intl" }, | ||
{ "path": "../link" }, | ||
{ "path": "../navigation" } | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters