feat: add basic settings page
This commit is contained in:
@ -11,6 +11,7 @@ import Copy from "./copy";
|
||||
import { hexToBech32, openFile } from "utils";
|
||||
import { VoidApi } from "@void-cat/api";
|
||||
import { LoginType } from "login";
|
||||
import { bech32 } from "@scure/base";
|
||||
|
||||
enum Stage {
|
||||
Login = 0,
|
||||
@ -41,6 +42,26 @@ export function LoginSignup({ close }: { close: () => void }) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function doLoginNsec() {
|
||||
try {
|
||||
const nsec = prompt("nsec");
|
||||
if (!nsec) {
|
||||
throw new Error("no nsec provided");
|
||||
}
|
||||
const {words} = bech32.decode(nsec, 5000);
|
||||
const data = new Uint8Array(bech32.fromWords(words));
|
||||
Login.loginWithPrivateKey(bytesToHex(data));
|
||||
close();
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
if (e instanceof Error) {
|
||||
setError(e.message);
|
||||
} else {
|
||||
setError(e as string);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function createAccount() {
|
||||
const newKey = bytesToHex(schnorr.utils.randomPrivateKey());
|
||||
@ -108,6 +129,13 @@ export function LoginSignup({ close }: { close: () => void }) {
|
||||
>
|
||||
Create Account
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-primary"
|
||||
onClick={doLoginNsec}
|
||||
>
|
||||
Enter Nsec (INSECURE)
|
||||
</button>
|
||||
{error && <b className="error">{error}</b>}
|
||||
</>
|
||||
);
|
||||
|
Reference in New Issue
Block a user