import { useState } from 'react'; import { Resolver, useForm } from 'react-hook-form'; import { useNavigate } from 'react-router-dom'; import { EyeOffIcon, EyeOnIcon, LoaderIcon } from '@shared/icons'; import { ArrowRightCircleIcon } from '@shared/icons/arrowRightCircle'; import { useOnboarding } from '@stores/onboarding'; import { useStronghold } from '@stores/stronghold'; 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 ImportStep2Screen() { const navigate = useNavigate(); const [passwordInput, setPasswordInput] = useState('password'); const [loading, setLoading] = useState(false); const privkey = useStronghold((state) => state.privkey); const pubkey = useOnboarding((state) => state.pubkey); 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) { // save privkey to secure storage await save(pubkey, privkey, data.password); // redirect to next step navigate('/auth/import/step-3', { replace: true }); } else { setLoading(false); setError('password', { type: 'custom', message: 'Password is required and must be greater than 3, please check again', }); } }; return (

Set password to secure your key

Password is use to unlock app and secure your key store in local machine. When you move to other clients, you just need to copy your private key as nsec or hexstring

{errors.password &&

{errors.password.message}

}
); }