Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3372800
D12051.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D12051.diff
View Options
diff --git a/native/account/registration/missing-registration-data/missing-siwe-backup-message.react.js b/native/account/registration/missing-registration-data/missing-siwe-backup-message.react.js
--- a/native/account/registration/missing-registration-data/missing-siwe-backup-message.react.js
+++ b/native/account/registration/missing-registration-data/missing-siwe-backup-message.react.js
@@ -1,13 +1,17 @@
// @flow
+import invariant from 'invariant';
import * as React from 'react';
+import { Alert } from 'react-native';
import { SafeAreaView } from 'react-native-safe-area-context';
import { type SIWEResult } from 'lib/types/siwe-types.js';
+import { isValidEthereumAddress } from 'lib/utils/siwe-utils.js';
import { commCoreModule } from '../../../native-modules.js';
import { type RootNavigationProp } from '../../../navigation/root-navigator.react.js';
import { type NavigationRoute } from '../../../navigation/route-names.js';
+import { useSelector } from '../../../redux/redux-utils.js';
import { useStyles } from '../../../themes/colors.js';
import { CreateSIWEBackupMessageBase } from '../siwe-backup-message-creation.react.js';
@@ -19,16 +23,33 @@
function CreateMissingSIWEBackupMessage(props: Props): React.Node {
const styles = useStyles(unboundStyles);
const { goBack } = props.navigation;
+ const currentUserInfo = useSelector(state => state.currentUserInfo);
+ const loggedInEthereumAccountAddress = currentUserInfo?.username;
+
+ invariant(
+ loggedInEthereumAccountAddress &&
+ isValidEthereumAddress(loggedInEthereumAccountAddress),
+ 'current username must be valid ethereum address to attempt ' +
+ 'backup message generation',
+ );
const onSuccessfulWalletSignature = React.useCallback(
(result: SIWEResult) => {
void (async () => {
- const { message, signature } = result;
+ const { message, signature, address } = result;
+ if (loggedInEthereumAccountAddress !== address) {
+ Alert.alert(
+ 'Mismatched Ethereum address',
+ 'You picked a different wallet than the one you use to sign in.',
+ );
+ return;
+ }
+
await commCoreModule.setSIWEBackupSecrets({ message, signature });
goBack();
})();
},
- [goBack],
+ [goBack, loggedInEthereumAccountAddress],
);
return (
diff --git a/native/account/registration/siwe-backup-message-creation.react.js b/native/account/registration/siwe-backup-message-creation.react.js
--- a/native/account/registration/siwe-backup-message-creation.react.js
+++ b/native/account/registration/siwe-backup-message-creation.react.js
@@ -3,7 +3,7 @@
import Icon from '@expo/vector-icons/MaterialIcons.js';
import invariant from 'invariant';
import * as React from 'react';
-import { View, Text } from 'react-native';
+import { View, Text, Alert } from 'react-native';
import { type SIWEResult, SIWEMessageTypes } from 'lib/types/siwe-types.js';
@@ -163,7 +163,17 @@
const onSuccessfulWalletSignature = React.useCallback(
(result: SIWEResult) => {
- const { message, signature } = result;
+ const selectedEthereumAddress = userSelections.accountSelection.address;
+ const { message, signature, address } = result;
+
+ if (address !== selectedEthereumAddress) {
+ Alert.alert(
+ 'Mismatched Ethereum address',
+ 'You picked a different wallet than the one you use to sign in.',
+ );
+ return;
+ }
+
const newUserSelections = {
...userSelections,
siweBackupSecrets: { message, signature },
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Nov 27, 7:58 AM (20 h, 11 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2589482
Default Alt Text
D12051.diff (3 KB)
Attached To
Mode
D12051: Ensure that the same ETH account is used for each signature
Attached
Detach File
Event Timeline
Log In to Comment