Skip to content

Commit b3eee9f

Browse files
committed
Add obfuscation toggle for private key input
1 parent 07adba5 commit b3eee9f

File tree

2 files changed

+53
-16
lines changed

2 files changed

+53
-16
lines changed

app/_locales/en/messages.json

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ui/components/multichain/import-account/private-key.js

Lines changed: 41 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,14 @@ import {
66
TEXT_FIELD_SIZES,
77
TEXT_FIELD_TYPES,
88
} from '../../component-library';
9+
import {
10+
Display,
11+
AlignItems,
12+
JustifyContent,
13+
} from '../../../helpers/constants/design-system';
914
import { useI18nContext } from '../../../hooks/useI18nContext';
15+
import Box from '../../ui/box';
16+
import ShowHideToggle from '../../ui/show-hide-toggle';
1017
import BottomButtons from './bottom-buttons';
1118

1219
PrivateKeyImportView.propTypes = {
@@ -20,6 +27,7 @@ export default function PrivateKeyImportView({
2027
}) {
2128
const t = useI18nContext();
2229
const [privateKey, setPrivateKey] = useState('');
30+
const [showPrivateKey, setShowPrivateKey] = useState(false);
2331

2432
const warning = useSelector((state) => state.appState.warning);
2533

@@ -36,22 +44,39 @@ export default function PrivateKeyImportView({
3644

3745
return (
3846
<>
39-
<FormTextField
40-
id="private-key-box"
41-
size={TEXT_FIELD_SIZES.LARGE}
42-
autoFocus
43-
type={TEXT_FIELD_TYPES.PASSWORD}
44-
helpText={warning}
45-
error
46-
label={t('pastePrivateKey')}
47-
value={privateKey}
48-
onChange={(event) => setPrivateKey(event.target.value)}
49-
inputProps={{
50-
onKeyPress: handleKeyPress,
51-
}}
52-
marginBottom={4}
53-
/>
54-
47+
<Box
48+
display={Display.Flex}
49+
alignItems={AlignItems.center}
50+
justifyContent={JustifyContent.center}
51+
>
52+
<FormTextField
53+
id="private-key-box"
54+
size={TEXT_FIELD_SIZES.LARGE}
55+
autoFocus
56+
type={
57+
showPrivateKey ? TEXT_FIELD_TYPES.TEXT : TEXT_FIELD_TYPES.PASSWORD
58+
}
59+
helpText={warning}
60+
error
61+
label={t('pastePrivateKey')}
62+
value={privateKey}
63+
onChange={(event) => setPrivateKey(event.target.value)}
64+
inputProps={{
65+
onKeyPress: handleKeyPress,
66+
}}
67+
marginBottom={4}
68+
/>
69+
<Box marginTop={4}>
70+
<ShowHideToggle
71+
shown={showPrivateKey}
72+
id="show-hide-private-key"
73+
title={t('privateKeyShow')}
74+
ariaLabelShown={t('privateKeyShown')}
75+
ariaLabelHidden={t('privateKeyHidden')}
76+
onChange={() => setShowPrivateKey(!showPrivateKey)}
77+
/>
78+
</Box>
79+
</Box>
5580
<BottomButtons
5681
importAccountFunc={_importAccountFunc}
5782
isPrimaryDisabled={privateKey === ''}

0 commit comments

Comments
 (0)