2025-04-17 11:23:46 -05:00
|
|
|
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.
|
|
|
|
|
2025-04-17 11:23:46 -05:00
|
|
|
export function useLoginActions() {
|
|
|
|
const { nostr } = useNostr();
|
|
|
|
const { addLogin } = useNostrLogin();
|
|
|
|
|
|
|
|
return {
|
2025-04-17 18:12:02 -05:00
|
|
|
// Login with a Nostr secret key
|
2025-04-17 11:23:46 -05:00
|
|
|
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
|
2025-04-17 11:23:46 -05:00
|
|
|
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
|
2025-04-17 11:23:46 -05:00
|
|
|
async extension(): Promise<void> {
|
|
|
|
const login = await NLogin.fromExtension();
|
|
|
|
addLogin(login);
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|