Skip to content

Commit

Permalink
feat(suite-native): onboarding security check
Browse files Browse the repository at this point in the history
  • Loading branch information
PeKne committed Feb 6, 2025
1 parent 4e69e04 commit 5594e18
Show file tree
Hide file tree
Showing 18 changed files with 511 additions and 81 deletions.
3 changes: 3 additions & 0 deletions suite-common/icons/generateIconFont.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ const usedIcons = [
'link',
'lock',
'magnifyingGlass',
'package',
'palette',
'password',
'pencil',
Expand All @@ -88,6 +89,8 @@ const usedIcons = [
'prohibit',
'qrCode',
'question',
'seal',
'selectionSlash',
'shareNetwork',
'shieldCheck',
'shieldWarning',
Expand Down
153 changes: 78 additions & 75 deletions suite-common/icons/iconFontsMobile/TrezorSuiteIcons.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,79 +25,82 @@
"shieldWarning": 61720,
"shieldCheck": 61721,
"shareNetwork": 61722,
"question": 61723,
"qrCode": 61724,
"prohibit": 61725,
"plusCircle": 61726,
"plus": 61727,
"plugs": 61728,
"piggyBankFilled": 61729,
"piggyBank": 61730,
"pictureFrame": 61731,
"pencilSimpleLine": 61732,
"pencilSimple": 61733,
"pencil": 61734,
"password": 61735,
"palette": 61736,
"magnifyingGlass": 61737,
"lock": 61738,
"link": 61739,
"lightbulb": 61740,
"lifebuoy": 61741,
"info": 61742,
"image": 61743,
"houseFilled": 61744,
"house": 61745,
"handPalm": 61746,
"githubLogo": 61747,
"gearFilled": 61748,
"gear": 61749,
"flagCheckered": 61750,
"flag": 61751,
"fingerprintSimple": 61752,
"fingerprint": 61753,
"filePdf": 61754,
"facebookLogo": 61755,
"eyeSlash": 61756,
"eye": 61757,
"discoverFilled": 61758,
"discover": 61759,
"detective": 61760,
"database": 61761,
"cpu": 61762,
"copy": 61763,
"coins": 61764,
"coinVerticalCheck": 61765,
"code": 61766,
"clockClockwise": 61767,
"circleDashed": 61768,
"checks": 61769,
"checkCircleFilled": 61770,
"checkCircle": 61771,
"check": 61772,
"chatCircle": 61773,
"change": 61774,
"caretUpFilled": 61775,
"caretUpDown": 61776,
"caretUp": 61777,
"caretRight": 61778,
"caretLeft": 61779,
"caretDownFilled": 61780,
"caretDown": 61781,
"caretCircleRight": 61782,
"calendar": 61783,
"bugBeetle": 61784,
"bookmarkSimple": 61785,
"backspace": 61786,
"arrowsLeftRight": 61787,
"arrowsCounterClockwise": 61788,
"arrowUpRight": 61789,
"arrowUp": 61790,
"arrowURightDown": 61791,
"arrowSquareOut": 61792,
"arrowRight": 61793,
"arrowLineUpRight": 61794,
"arrowLineUp": 61795,
"arrowLineDown": 61796,
"arrowDown": 61797
"selectionSlash": 61723,
"seal": 61724,
"question": 61725,
"qrCode": 61726,
"prohibit": 61727,
"plusCircle": 61728,
"plus": 61729,
"plugs": 61730,
"piggyBankFilled": 61731,
"piggyBank": 61732,
"pictureFrame": 61733,
"pencilSimpleLine": 61734,
"pencilSimple": 61735,
"pencil": 61736,
"password": 61737,
"palette": 61738,
"package": 61739,
"magnifyingGlass": 61740,
"lock": 61741,
"link": 61742,
"lightbulb": 61743,
"lifebuoy": 61744,
"info": 61745,
"image": 61746,
"houseFilled": 61747,
"house": 61748,
"handPalm": 61749,
"githubLogo": 61750,
"gearFilled": 61751,
"gear": 61752,
"flagCheckered": 61753,
"flag": 61754,
"fingerprintSimple": 61755,
"fingerprint": 61756,
"filePdf": 61757,
"facebookLogo": 61758,
"eyeSlash": 61759,
"eye": 61760,
"discoverFilled": 61761,
"discover": 61762,
"detective": 61763,
"database": 61764,
"cpu": 61765,
"copy": 61766,
"coins": 61767,
"coinVerticalCheck": 61768,
"code": 61769,
"clockClockwise": 61770,
"circleDashed": 61771,
"checks": 61772,
"checkCircleFilled": 61773,
"checkCircle": 61774,
"check": 61775,
"chatCircle": 61776,
"change": 61777,
"caretUpFilled": 61778,
"caretUpDown": 61779,
"caretUp": 61780,
"caretRight": 61781,
"caretLeft": 61782,
"caretDownFilled": 61783,
"caretDown": 61784,
"caretCircleRight": 61785,
"calendar": 61786,
"bugBeetle": 61787,
"bookmarkSimple": 61788,
"backspace": 61789,
"arrowsLeftRight": 61790,
"arrowsCounterClockwise": 61791,
"arrowUpRight": 61792,
"arrowUp": 61793,
"arrowURightDown": 61794,
"arrowSquareOut": 61795,
"arrowRight": 61796,
"arrowLineUpRight": 61797,
"arrowLineUp": 61798,
"arrowLineDown": 61799,
"arrowDown": 61800
}
Binary file modified suite-common/icons/iconFontsMobile/TrezorSuiteIcons.ttf
Binary file not shown.
10 changes: 6 additions & 4 deletions suite-native/atoms/src/AlertBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ActivityIndicator } from 'react-native';

import { Icon, IconName } from '@suite-native/icons';
import { prepareNativeStyle, useNativeStyles } from '@trezor/styles';
import { Color, NativeRadius } from '@trezor/theme';
import { Color, NativeRadius, TypographyStyle } from '@trezor/theme';

import { Box } from './Box';
import { Text } from './Text';
Expand Down Expand Up @@ -84,6 +84,7 @@ export type AlertBoxProps = {
borderRadius?: NativeRadius | number;
contentColor?: Color;
rightButton?: ReactNode;
textVariant?: TypographyStyle;
};

const AlertSpinner = ({ color }: { color: Color }) => {
Expand All @@ -96,10 +97,11 @@ const AlertSpinner = ({ color }: { color: Color }) => {

export const AlertBox = ({
title,
variant = 'info',
borderRadius = 'r16',
contentColor,
rightButton,
variant = 'info',
borderRadius = 'r16',
textVariant = 'label',
}: AlertBoxProps) => {
const { applyStyle } = useNativeStyles();
const {
Expand All @@ -123,7 +125,7 @@ export const AlertBox = ({
) : (
<Icon name={variantToIconName[variant]} color={color} size="mediumLarge" />
)}
<Text color={color} variant="label" style={applyStyle(textStyle)}>
<Text color={color} variant={textVariant} style={applyStyle(textStyle)}>
{title}
</Text>
{rightButton}
Expand Down
30 changes: 30 additions & 0 deletions suite-native/intl/src/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ export const en = {
next: 'Next',
tryAgain: 'Try again',
edit: 'Edit',
yes: 'Yes',
learnMore: 'Learn more',
},
unknownError: 'Something went wrong',
default: 'Default',
Expand Down Expand Up @@ -852,6 +854,34 @@ export const en = {
bullet3: 'Go to the support page linked below and use the Chat option on the website.',
contactSupportButton: 'Contact Trezor Support',
},
securityCheckScreen: {
title: 'Security check',
subtitle: 'We need to make sure your device is safe to work with.',
step1: {
header: 'Trusted source',
description:
'My device was bought from the official Trezor Shop or a <link>trusted reseller</link>.',
},
step2: {
header: 'Holographic seal',
description:
'The <link>holographic seal</link> was complete and undamaged when I unboxed my device.',
modal: {
alertBox:
'We sold this Trezor model with two different holographic seals. Both of them are valid.',
title: 'Verify the holographic seal',
paragraph1:
'Ensure the holographic seal on your device was intact when unboxed, with no peeling, scratches, or damage.',
paragraph2: 'Proceed only if the seal was intact and undamaged.',
},
},
step3: {
header: 'Packaging',
description:
'The package was factory sealed and intact, with no signs of tampering before unboxing.',
},
declineButton: 'I’m not sure',
},
},
moduleAccountManagement: {
accountSettingsScreen: {
Expand Down
1 change: 1 addition & 0 deletions suite-native/module-onboarding/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"expo-linear-gradient": "^14.0.1",
"react": "18.2.0",
"react-native": "0.76.1",
"react-native-reanimated": "^3.16.7",
"react-native-svg": "^15.9.0",
"react-redux": "8.0.7"
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
import { ReactNode } from 'react';
import { FadeIn, FadeOutUp, LinearTransition } from 'react-native-reanimated';

import { useNavigation } from '@react-navigation/core';

import {
AnimatedCard,
AnimatedVStack,
Button,
Divider,
HStack,
Text,
VStack,
} from '@suite-native/atoms';
import { Icon, IconName } from '@suite-native/icons';
import { Translation } from '@suite-native/intl';
import {
DeviceSuspicionCause,
OnboardingStackParamList,
OnboardingStackRoutes,
StackNavigationProps,
} from '@suite-native/navigation';
import { prepareNativeStyle, useNativeStyles } from '@trezor/styles';
import { Color } from '@trezor/theme';

type SecurityCheckStepCardProps = {
header: ReactNode;
description: ReactNode;
isChecked: boolean;
isOpened: boolean;
icon: IconName;
onPressConfirmButton: () => void;
suspicionCause: DeviceSuspicionCause;
};

type NavigationProps = StackNavigationProps<
OnboardingStackParamList,
OnboardingStackRoutes.SecurityCheck
>;

const cardStyle = prepareNativeStyle<{ wasOpened: boolean }>((utils, { wasOpened }) => ({
backgroundColor: wasOpened
? utils.colors.backgroundSurfaceElevationNegative
: utils.colors.backgroundSurfaceElevation1,
}));

const buttonStyle = prepareNativeStyle(() => ({
flex: 1,
}));

export const SecurityCheckStepCard = ({
header,
description,
icon,
isChecked,
isOpened,
onPressConfirmButton,
suspicionCause,
}: SecurityCheckStepCardProps) => {
const { applyStyle } = useNativeStyles();
const navigation = useNavigation<NavigationProps>();
const iconName = isChecked ? 'check' : icon;
const headerColor: Color = isChecked ? 'textPrimaryDefault' : 'textSubdued';

const navigateToSuspiciousDeviceScreen = () => {
navigation.navigate(OnboardingStackRoutes.SuspiciousDevice, {
suspicionCause,
});
};

const isFirstStepCard = suspicionCause === 'untrustedReseller';

return (
<AnimatedCard
layout={LinearTransition}
style={applyStyle(cardStyle, { wasOpened: !isOpened && !isChecked })}
>
<VStack spacing="sp16">
<VStack spacing="sp12">
<HStack spacing="sp8" alignItems="center">
<Icon name={iconName} size="mediumLarge" color={headerColor} />
<Text variant="callout" color={headerColor}>
{header}
</Text>
</HStack>
{isOpened && <Divider />}
</VStack>
{isOpened && (
<AnimatedVStack
spacing="sp16"
entering={isFirstStepCard ? undefined : FadeIn.delay(150)}
exiting={FadeOutUp}
>
<Text variant="highlight">{description}</Text>
<HStack flex={1} justifyContent="space-between">
<Button
size="small"
style={applyStyle(buttonStyle)}
onPress={onPressConfirmButton}
>
<Translation id="generic.buttons.yes" />
</Button>
<Button
size="small"
style={applyStyle(buttonStyle)}
colorScheme="tertiaryElevation0"
onPress={navigateToSuspiciousDeviceScreen}
>
<Translation id="moduleOnboarding.securityCheckScreen.declineButton" />
</Button>
</HStack>
</AnimatedVStack>
)}
</VStack>
</AnimatedCard>
);
};
Loading

0 comments on commit 5594e18

Please sign in to comment.