mirror of
https://github.com/hzrd149/nostrudel.git
synced 2025-03-18 05:41:44 +01:00
small nip-07 fixes
This commit is contained in:
parent
53055985df
commit
2fd2f7df87
src
3
src/types/nostr-extensions.d.ts
vendored
3
src/types/nostr-extensions.d.ts
vendored
@ -3,10 +3,9 @@ import { DraftNostrEvent, NostrEvent } from "./nostr-event";
|
||||
declare global {
|
||||
interface Window {
|
||||
nostr?: {
|
||||
enabled: boolean;
|
||||
getPublicKey: () => Promise<string> | string;
|
||||
signEvent: (event: DraftNostrEvent) => Promise<NostrEvent> | NostrEvent;
|
||||
getRelays: () => Record<string, { read: boolean; write: boolean }> | string[];
|
||||
getRelays?: () => Record<string, { read: boolean; write: boolean }> | string[];
|
||||
nip04?: {
|
||||
encrypt: (pubkey: string, plaintext: string) => Promise<string> | string;
|
||||
decrypt: (pubkey: string, ciphertext: string) => Promise<string> | string;
|
||||
|
@ -1,4 +1,15 @@
|
||||
import { Alert, AlertDescription, AlertIcon, AlertTitle, Box, Button, Flex, Heading, Spinner } from "@chakra-ui/react";
|
||||
import {
|
||||
Alert,
|
||||
AlertDescription,
|
||||
AlertIcon,
|
||||
AlertTitle,
|
||||
Box,
|
||||
Button,
|
||||
Flex,
|
||||
Heading,
|
||||
Spinner,
|
||||
useToast,
|
||||
} from "@chakra-ui/react";
|
||||
import { useState } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import AccountCard from "./components/account-card";
|
||||
@ -7,6 +18,7 @@ import accountService from "../../services/account";
|
||||
|
||||
export default function LoginStartView() {
|
||||
const navigate = useNavigate();
|
||||
const toast = useToast();
|
||||
const [loading, setLoading] = useState(false);
|
||||
const accounts = useSubject(accountService.accounts);
|
||||
|
||||
@ -19,7 +31,7 @@ export default function LoginStartView() {
|
||||
|
||||
if (!accountService.hasAccount(pubkey)) {
|
||||
let relays: string[] = [];
|
||||
const extRelays = await window.nostr.getRelays();
|
||||
const extRelays = (await window.nostr.getRelays?.()) ?? [];
|
||||
if (Array.isArray(extRelays)) {
|
||||
relays = extRelays;
|
||||
} else {
|
||||
@ -36,6 +48,11 @@ export default function LoginStartView() {
|
||||
accountService.switchAccount(pubkey);
|
||||
} catch (e) {}
|
||||
setLoading(false);
|
||||
} else {
|
||||
toast({
|
||||
status: "warning",
|
||||
title: "Cant find extension",
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@ -50,11 +67,9 @@ export default function LoginStartView() {
|
||||
<AlertDescription>There are bugs and things will break.</AlertDescription>
|
||||
</Box>
|
||||
</Alert>
|
||||
{window.nostr && (
|
||||
<Button onClick={loginWithExtension} colorScheme="brand">
|
||||
Use browser extension (NIP-07)
|
||||
</Button>
|
||||
)}
|
||||
<Button onClick={loginWithExtension} colorScheme="brand">
|
||||
Use browser extension (NIP-07)
|
||||
</Button>
|
||||
<Button onClick={() => navigate("./nip05")}>Login with Nip-05 Id</Button>
|
||||
<Button onClick={() => navigate("./npub")}>Login with pubkey key (npub)</Button>
|
||||
<Button onClick={() => navigate("./nsec")}>Login with secret key (nsec)</Button>
|
||||
|
Loading…
x
Reference in New Issue
Block a user