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 { 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 CreateStep2Screen() { const navigate = useNavigate(); const [passwordInput, setPasswordInput] = useState('password'); const [loading, setLoading] = useState(false); const [privkey, setPassword] = useStronghold((state) => [ state.privkey, state.setPassword, ]); const pubkey = useOnboarding((state) => state.privkey); 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) { // add password to local state setPassword(data.password); // save privkey to secure storage await save(pubkey, privkey, data.password); // redirect to next step navigate('/auth/create/step-3', { replace: true }); } else { setLoading(false); setError('password', { type: 'custom', message: 'Password is required and must be greater than 3', }); } }; return (

Set password to secure your key

Password is use to 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}

}
); }