diff --git a/apps/desktop/src/routes/auth/create-keys.tsx b/apps/desktop/src/routes/auth/create-keys.tsx
index 4090075c..46cb4347 100644
--- a/apps/desktop/src/routes/auth/create-keys.tsx
+++ b/apps/desktop/src/routes/auth/create-keys.tsx
@@ -1,13 +1,16 @@
import { useArk } from "@lume/ark";
+import { CheckIcon, EyeOffIcon, EyeOnIcon, LoaderIcon } from "@lume/icons";
import { useStorage } from "@lume/storage";
import { onboardingAtom } from "@lume/utils";
import { NDKPrivateKeySigner } from "@nostr-dev-kit/ndk";
+import * as Checkbox from "@radix-ui/react-checkbox";
import { desktopDir } from "@tauri-apps/api/path";
import { save } from "@tauri-apps/plugin-dialog";
import { writeTextFile } from "@tauri-apps/plugin-fs";
import { useSetAtom } from "jotai";
import { nanoid } from "nanoid";
import { getPublicKey, nip19 } from "nostr-tools";
+import { useEffect, useState } from "react";
import { useNavigate } from "react-router-dom";
import { toast } from "sonner";
@@ -17,73 +20,165 @@ export function CreateAccountKeys() {
const setOnboarding = useSetAtom(onboardingAtom);
const navigate = useNavigate();
- const generateNostrKeys = async () => {
- const signer = NDKPrivateKeySigner.generate();
- const pubkey = getPublicKey(signer.privateKey);
+ const [key, setKey] = useState("");
+ const [loading, setLoading] = useState(false);
+ const [showKey, setShowKey] = useState(false);
+ const [confirm, setConfirm] = useState({ c1: false, c2: false, c3: false });
- const npub = nip19.npubEncode(pubkey);
- const nsec = nip19.nsecEncode(signer.privateKey);
+ const submit = async () => {
+ try {
+ setLoading(true);
- ark.updateNostrSigner({ signer });
+ const privkey = nip19.decode(key).data as string;
+ const signer = new NDKPrivateKeySigner(privkey);
+ const pubkey = getPublicKey(privkey);
- const downloadPath = await desktopDir();
- const fileName = `nostr_keys_${nanoid(4)}.txt`;
- const filePath = await save({
- defaultPath: `${downloadPath}/${fileName}`,
- });
+ ark.updateNostrSigner({ signer });
- if (!filePath) {
- return toast.info("You need to save account keys before continue.");
+ const downloadPath = await desktopDir();
+ const fileName = `nostr_keys_${nanoid(4)}.txt`;
+ const filePath = await save({
+ defaultPath: `${downloadPath}/${fileName}`,
+ });
+
+ if (!filePath) {
+ return toast.info("You need to save account keys before continue.");
+ }
+
+ await writeTextFile(
+ filePath,
+ `Nostr Account\nGenerated by Lume (lume.nu)\n---\nPrivate key: ${key}`,
+ );
+
+ const newAccount = await storage.createAccount({
+ pubkey: pubkey,
+ privkey: privkey,
+ });
+ ark.account = newAccount;
+
+ setLoading(false);
+ setOnboarding({ open: true, newUser: true });
+
+ return navigate("/auth/onboarding", { replace: true });
+ } catch (e) {
+ setLoading(false);
+ toast.error(String(e));
}
-
- await writeTextFile(
- filePath,
- `Nostr Account\nGenerated by Lume (lume.nu)\n---\nPublic key: ${npub}\nPrivate key: ${nsec}`,
- );
-
- await storage.createAccount({
- pubkey: pubkey,
- privkey: signer.privateKey,
- });
-
- setOnboarding({ open: true, newUser: true });
-
- return navigate("/auth/onboarding", { replace: true });
};
+ useEffect(() => {
+ const privkey = NDKPrivateKeySigner.generate().privateKey;
+ setKey(nip19.nsecEncode(privkey));
+ }, []);
+
return (
-
+
-
Create Account
+
+ This is your new Account Key
+
+
+ Keep your key in safe place. If you lose this key, you will lose
+ access to your account.
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+ setConfirm((state) => ({ ...state, c1: !state.c1 }))
+ }
+ className="flex size-7 appearance-none items-center justify-center rounded-lg bg-neutral-900 outline-none"
+ id="confirm1"
+ >
+
+
+
+
+
+
+
+
+ setConfirm((state) => ({ ...state, c2: !state.c2 }))
+ }
+ className="flex size-7 appearance-none items-center justify-center rounded-lg bg-neutral-900 outline-none"
+ id="confirm2"
+ >
+
+
+
+
+
+
+
+
+ setConfirm((state) => ({ ...state, c3: !state.c3 }))
+ }
+ className="flex size-7 appearance-none items-center justify-center rounded-lg bg-neutral-900 outline-none"
+ id="confirm3"
+ >
+
+
+
+
+
+
+
+
diff --git a/apps/desktop/src/routes/auth/create.tsx b/apps/desktop/src/routes/auth/create.tsx
index 9a1a7c3f..c0b5a301 100644
--- a/apps/desktop/src/routes/auth/create.tsx
+++ b/apps/desktop/src/routes/auth/create.tsx
@@ -21,29 +21,14 @@ export function CreateAccountScreen() {
return (
-
+
-
- Let's get you set up on Nostr.
-
+
Let's Get Started
Choose one of methods below to create your account
-
+