mirror of
https://github.com/hzrd149/nostrudel.git
synced 2025-09-27 12:07:43 +02:00
small nip-07 fixes
This commit is contained in:
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 {
|
declare global {
|
||||||
interface Window {
|
interface Window {
|
||||||
nostr?: {
|
nostr?: {
|
||||||
enabled: boolean;
|
|
||||||
getPublicKey: () => Promise<string> | string;
|
getPublicKey: () => Promise<string> | string;
|
||||||
signEvent: (event: DraftNostrEvent) => Promise<NostrEvent> | NostrEvent;
|
signEvent: (event: DraftNostrEvent) => Promise<NostrEvent> | NostrEvent;
|
||||||
getRelays: () => Record<string, { read: boolean; write: boolean }> | string[];
|
getRelays?: () => Record<string, { read: boolean; write: boolean }> | string[];
|
||||||
nip04?: {
|
nip04?: {
|
||||||
encrypt: (pubkey: string, plaintext: string) => Promise<string> | string;
|
encrypt: (pubkey: string, plaintext: string) => Promise<string> | string;
|
||||||
decrypt: (pubkey: string, ciphertext: 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 { useState } from "react";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import AccountCard from "./components/account-card";
|
import AccountCard from "./components/account-card";
|
||||||
@@ -7,6 +18,7 @@ import accountService from "../../services/account";
|
|||||||
|
|
||||||
export default function LoginStartView() {
|
export default function LoginStartView() {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
const toast = useToast();
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const accounts = useSubject(accountService.accounts);
|
const accounts = useSubject(accountService.accounts);
|
||||||
|
|
||||||
@@ -19,7 +31,7 @@ export default function LoginStartView() {
|
|||||||
|
|
||||||
if (!accountService.hasAccount(pubkey)) {
|
if (!accountService.hasAccount(pubkey)) {
|
||||||
let relays: string[] = [];
|
let relays: string[] = [];
|
||||||
const extRelays = await window.nostr.getRelays();
|
const extRelays = (await window.nostr.getRelays?.()) ?? [];
|
||||||
if (Array.isArray(extRelays)) {
|
if (Array.isArray(extRelays)) {
|
||||||
relays = extRelays;
|
relays = extRelays;
|
||||||
} else {
|
} else {
|
||||||
@@ -36,6 +48,11 @@ export default function LoginStartView() {
|
|||||||
accountService.switchAccount(pubkey);
|
accountService.switchAccount(pubkey);
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
setLoading(false);
|
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>
|
<AlertDescription>There are bugs and things will break.</AlertDescription>
|
||||||
</Box>
|
</Box>
|
||||||
</Alert>
|
</Alert>
|
||||||
{window.nostr && (
|
<Button onClick={loginWithExtension} colorScheme="brand">
|
||||||
<Button onClick={loginWithExtension} colorScheme="brand">
|
Use browser extension (NIP-07)
|
||||||
Use browser extension (NIP-07)
|
</Button>
|
||||||
</Button>
|
|
||||||
)}
|
|
||||||
<Button onClick={() => navigate("./nip05")}>Login with Nip-05 Id</Button>
|
<Button onClick={() => navigate("./nip05")}>Login with Nip-05 Id</Button>
|
||||||
<Button onClick={() => navigate("./npub")}>Login with pubkey key (npub)</Button>
|
<Button onClick={() => navigate("./npub")}>Login with pubkey key (npub)</Button>
|
||||||
<Button onClick={() => navigate("./nsec")}>Login with secret key (nsec)</Button>
|
<Button onClick={() => navigate("./nsec")}>Login with secret key (nsec)</Button>
|
||||||
|
Reference in New Issue
Block a user