mkstackwithwelshman/src/hooks/useLoginActions.ts

28 lines
795 B
TypeScript
Raw Normal View History

import { useNostr } from '@nostrify/react';
import { NLogin, useNostrLogin } from '@nostrify/react/login';
2025-04-17 18:12:02 -05:00
// NOTE: This file should not be edited except for adding new login methods.
export function useLoginActions() {
const { nostr } = useNostr();
const { addLogin } = useNostrLogin();
return {
2025-04-17 18:12:02 -05:00
// Login with a Nostr secret key
nsec(nsec: string): void {
const login = NLogin.fromNsec(nsec);
addLogin(login);
},
2025-04-17 18:12:02 -05:00
// Login with a NIP-46 "bunker://" URI
async bunker(uri: string): Promise<void> {
const login = await NLogin.fromBunker(uri, nostr);
addLogin(login);
},
2025-04-17 18:12:02 -05:00
// Login with a NIP-07 browser extension
async extension(): Promise<void> {
const login = await NLogin.fromExtension();
addLogin(login);
},
};
}