fix eslint warnings
This commit is contained in:
@ -30,15 +30,15 @@ export default function LoginPage() {
|
||||
}, [publicKey, navigate]);
|
||||
|
||||
async function getNip05PubKey(addr: string) {
|
||||
let [username, domain] = addr.split("@");
|
||||
let rsp = await fetch(
|
||||
const [username, domain] = addr.split("@");
|
||||
const rsp = await fetch(
|
||||
`https://${domain}/.well-known/nostr.json?name=${encodeURIComponent(
|
||||
username
|
||||
)}`
|
||||
);
|
||||
if (rsp.ok) {
|
||||
let data = await rsp.json();
|
||||
let pKey = data.names[username];
|
||||
const data = await rsp.json();
|
||||
const pKey = data.names[username];
|
||||
if (pKey) {
|
||||
return pKey;
|
||||
}
|
||||
@ -49,17 +49,17 @@ export default function LoginPage() {
|
||||
async function doLogin() {
|
||||
try {
|
||||
if (key.startsWith("nsec")) {
|
||||
let hexKey = bech32ToHex(key);
|
||||
const hexKey = bech32ToHex(key);
|
||||
if (secp.utils.isValidPrivateKey(hexKey)) {
|
||||
dispatch(setPrivateKey(hexKey));
|
||||
} else {
|
||||
throw new Error("INVALID PRIVATE KEY");
|
||||
}
|
||||
} else if (key.startsWith("npub")) {
|
||||
let hexKey = bech32ToHex(key);
|
||||
const hexKey = bech32ToHex(key);
|
||||
dispatch(setPublicKey(hexKey));
|
||||
} else if (key.match(EmailRegex)) {
|
||||
let hexKey = await getNip05PubKey(key);
|
||||
const hexKey = await getNip05PubKey(key);
|
||||
dispatch(setPublicKey(hexKey));
|
||||
} else {
|
||||
if (secp.utils.isValidPrivateKey(key)) {
|
||||
@ -75,17 +75,17 @@ export default function LoginPage() {
|
||||
}
|
||||
|
||||
async function makeRandomKey() {
|
||||
let newKey = secp.utils.bytesToHex(secp.utils.randomPrivateKey());
|
||||
const newKey = secp.utils.bytesToHex(secp.utils.randomPrivateKey());
|
||||
dispatch(setGeneratedPrivateKey(newKey));
|
||||
navigate("/new");
|
||||
}
|
||||
|
||||
async function doNip07Login() {
|
||||
let pubKey = await window.nostr.getPublicKey();
|
||||
const pubKey = await window.nostr.getPublicKey();
|
||||
dispatch(setPublicKey(pubKey));
|
||||
|
||||
if ("getRelays" in window.nostr) {
|
||||
let relays = await window.nostr.getRelays();
|
||||
const relays = await window.nostr.getRelays();
|
||||
dispatch(
|
||||
setRelays({
|
||||
relays: {
|
||||
@ -99,7 +99,7 @@ export default function LoginPage() {
|
||||
}
|
||||
|
||||
function altLogins() {
|
||||
let nip07 = "nostr" in window;
|
||||
const nip07 = "nostr" in window;
|
||||
if (!nip07) {
|
||||
return null;
|
||||
}
|
||||
@ -108,7 +108,7 @@ export default function LoginPage() {
|
||||
<>
|
||||
<h2>Other Login Methods</h2>
|
||||
<div className="flex">
|
||||
<button type="button" onClick={(e) => doNip07Login()}>
|
||||
<button type="button" onClick={doNip07Login}>
|
||||
Login with Extension (NIP-07)
|
||||
</button>
|
||||
</div>
|
||||
@ -129,7 +129,7 @@ export default function LoginPage() {
|
||||
</div>
|
||||
{error.length > 0 ? <b className="error">{error}</b> : null}
|
||||
<div className="tabs">
|
||||
<button type="button" onClick={(e) => doLogin()}>
|
||||
<button type="button" onClick={doLogin}>
|
||||
Login
|
||||
</button>
|
||||
<button type="button" onClick={() => makeRandomKey()}>
|
||||
|
Reference in New Issue
Block a user