import { Info } from 'phosphor-react'; import { useEffect, useRef, useState } from 'react'; import { Algorithm, HASHING_ALGOS, HashingAlgoSlug, useLibraryMutation } from '@sd/client'; import { Button, CategoryHeading, PasswordInput, Select, SelectOption, Slider, Switch, Tooltip, tw } from '@sd/ui'; import { generatePassword } from '~/util'; const KeyHeading = tw(CategoryHeading)`mb-1`; export default () => { const ref = useRef(null); const [librarySync, setLibrarySync] = useState(true); const [autoMount, setAutoMount] = useState(false); const [sliderValue, setSliderValue] = useState([64]); const [key, setKey] = useState(''); const [encryptionAlgo, setEncryptionAlgo] = useState('XChaCha20Poly1305'); const [hashingAlgo, setHashingAlgo] = useState('Argon2id-s'); const createKey = useLibraryMutation('keys.add'); // this keeps the input focused when switching tabs // feel free to replace with something cleaner useEffect(() => { setTimeout(() => { ref.current?.focus(); }); }, []); return (
Mount key setKey(e.target.value)} autoFocus />
{ setSliderValue(val); setKey(generatePassword(val[0] ?? 8)); }} onClick={() => { setKey(generatePassword(sliderValue[0] ?? 8)); }} />
{sliderValue}
{ if (autoMount && !e) setAutoMount(false); setLibrarySync(e); }} />
Sync with Library
{/*
{ if (!librarySync && e) setLibrarySync(true); setAutoMount(e); }} />
Automount */}
Encryption
Hashing
); };