From e081094cdfb5cecf09efd4736e999a946a9df1a5 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Thu, 17 Apr 2025 18:12:02 -0500 Subject: [PATCH] Add comments to useLoginActions --- src/hooks/useCurrentUser.ts | 8 ++++---- src/hooks/useLoginActions.ts | 5 +++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/hooks/useCurrentUser.ts b/src/hooks/useCurrentUser.ts index d98513d..4506139 100644 --- a/src/hooks/useCurrentUser.ts +++ b/src/hooks/useCurrentUser.ts @@ -10,14 +10,14 @@ export function useCurrentUser() { const loginToUser = useCallback((login: NLoginType): NUser => { switch (login.type) { - case 'nsec': + case 'nsec': // Nostr login with secret key return NUser.fromNsecLogin(login); - case 'bunker': + case 'bunker': // Nostr login with NIP-46 "bunker://" URI return NUser.fromBunkerLogin(login, nostr); - case 'extension': + case 'extension': // Nostr login with NIP-07 browser extension return NUser.fromExtensionLogin(login); + // Other login types can be defined here default: - // Learn how to define other login types: https://nostrify.dev/react/logins#custom-login-types throw new Error(`Unsupported login type: ${login.type}`); } }, [nostr]); diff --git a/src/hooks/useLoginActions.ts b/src/hooks/useLoginActions.ts index fcb4a9b..dcfda27 100644 --- a/src/hooks/useLoginActions.ts +++ b/src/hooks/useLoginActions.ts @@ -1,19 +1,24 @@ import { useNostr } from '@nostrify/react'; import { NLogin, useNostrLogin } from '@nostrify/react/login'; +// NOTE: This file should not be edited except for adding new login methods. + export function useLoginActions() { const { nostr } = useNostr(); const { addLogin } = useNostrLogin(); return { + // Login with a Nostr secret key nsec(nsec: string): void { const login = NLogin.fromNsec(nsec); addLogin(login); }, + // Login with a NIP-46 "bunker://" URI async bunker(uri: string): Promise { const login = await NLogin.fromBunker(uri, nostr); addLogin(login); }, + // Login with a NIP-07 browser extension async extension(): Promise { const login = await NLogin.fromExtension(); addLogin(login);