import { useQueryClient } from '@tanstack/react-query'; import { useState } from 'react'; import { Resolver, useForm } from 'react-hook-form'; import { useNavigate } from 'react-router-dom'; import { removePrivkey } from '@libs/storage'; import { EyeOffIcon, EyeOnIcon, LoaderIcon } from '@shared/icons'; import { useStronghold } from '@stores/stronghold'; import { useAccount } from '@utils/hooks/useAccount'; import { useSecureStorage } from '@utils/hooks/useSecureStorage'; type FormValues = { password: string; }; const resolver: Resolver = async (values) => { return { values: values.password ? values : {}, errors: !values.password ? { password: { type: 'required', message: 'This is required.', }, } : {}, }; }; export function MigrateScreen() { const queryClient = useQueryClient(); const navigate = useNavigate(); const setPrivkey = useStronghold((state) => state.setPrivkey); const [passwordInput, setPasswordInput] = useState('password'); const [loading, setLoading] = useState(false); const { account } = useAccount(); const { save } = useSecureStorage(); // toggle private key const showPassword = () => { if (passwordInput === 'password') { setPasswordInput('text'); } else { setPasswordInput('password'); } }; const { register, setError, handleSubmit, formState: { errors, isDirty, isValid }, } = useForm({ resolver }); const onSubmit = async (data: { [x: string]: string }) => { setLoading(true); if (data.password.length > 3) { // load private in secure storage try { // save privkey to secure storage await save(account.pubkey, account.privkey, data.password); // add privkey to state setPrivkey(account.privkey); // remove privkey in db await removePrivkey(); // clear cache await queryClient.invalidateQueries(['currentAccount']); // redirect to home navigate('/', { replace: true }); } catch { setLoading(false); setError('password', { type: 'custom', message: 'Wrong password', }); } } else { setLoading(false); setError('password', { type: 'custom', message: 'Password is required and must be greater than 3', }); } }; return (

Upgrade security for your account

You're using old Lume version which store your private key as plaintext in database, this is huge security risk.

To secure your private key, please set a password and Lume will put your private key in secure storage.

It is not possible to start the app without applying this step, it is easy and fast!

Set a password to protect your key
{errors.password &&

{errors.password.message}

}
); }