From 772cecf26bf7d1a29f35780087f47172f27c1efc Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Mon, 19 Feb 2024 13:26:39 -0600 Subject: [PATCH] KeygenStep: display user's keys as copyable inputs --- src/components/copyable-input.tsx | 10 +++++++-- .../nostr-signin-modal/steps/keygen-step.tsx | 21 +++++++++++++++---- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/components/copyable-input.tsx b/src/components/copyable-input.tsx index 2422c8276..90089927c 100644 --- a/src/components/copyable-input.tsx +++ b/src/components/copyable-input.tsx @@ -6,10 +6,14 @@ import { Button, HStack, Input } from './ui'; interface ICopyableInput { /** Text to be copied. */ value: string; + /** Input type. */ + type?: 'text' | 'password'; + /** Callback after the value has been copied. */ + onCopy?(): void; } /** An input with copy abilities. */ -const CopyableInput: React.FC = ({ value }) => { +const CopyableInput: React.FC = ({ value, type = 'text', onCopy }) => { const input = useRef(null); const selectInput = () => { @@ -20,13 +24,15 @@ const CopyableInput: React.FC = ({ value }) => { } else { document.execCommand('copy'); } + + onCopy?.(); }; return ( = ({ setSigner, setStep, onClose }) => { const [downloaded, setDownloaded] = useState(false); const handleDownload = () => { - download(nsec, `${slugify(instance.title)}-${npub.slice(5, 9)}.nsec`); + download(nsec, `${slugify(instance.title)}-${npub.slice(5, 9)}.nsec.txt`); setDownloaded(true); }; + const handleCopy = () => setDownloaded(true); + const handleNext = () => { const signer = NKeys.add(secretKey); setSigner(signer); @@ -50,8 +53,18 @@ const KeygenStep: React.FC = ({ setSigner, setStep, onClose }) => { - -