mirror of
https://gitlab.com/soapbox-pub/mkstack.git
synced 2026-12-05 16:33:36 +00:00
feat: add client-initiated NIP-46 (nostrconnect://) login support
Upgrade to @nostrify/[email protected] and implement the nostrconnect:// login flow: - QR code display on desktop, deep link on mobile - Copy URI button, retry on timeout, abort on dialog close - Bunker URI manual input as fallback under the Remote Signer tab - Add QRCodeCanvas component using the existing qrcode dependency
This commit is contained in:
5 files changed
+284
-63
No files matched your search
@@ -1,11 +1,16 @@
|
||||
import { useNostr } from '@nostrify/react';
|
||||
import { NLogin, useNostrLogin } from '@nostrify/react/login';
|
||||
import { NLogin, type NostrConnectParams, useNostrLogin } from '@nostrify/react/login';
|
||||
import { useAppContext } from '@/hooks/useAppContext';
|
||||
|
||||
// NOTE: This file should not be edited except for adding new login methods.
|
||||
|
||||
export type { NostrConnectParams };
|
||||
export { generateNostrConnectParams, generateNostrConnectURI } from '@nostrify/react/login';
|
||||
|
||||
export function useLoginActions() {
|
||||
const { nostr } = useNostr();
|
||||
const { logins, addLogin, removeLogin } = useNostrLogin();
|
||||
const { config } = useAppContext();
|
||||
|
||||
return {
|
||||
// Login with a Nostr secret key
|
||||
@@ -23,6 +28,19 @@ export function useLoginActions() {
|
||||
const login = await NLogin.fromExtension();
|
||||
addLogin(login);
|
||||
},
|
||||
// Login via nostrconnect:// (client-initiated NIP-46)
|
||||
// The client displays a QR code and waits for the remote signer to connect
|
||||
async nostrconnect(params: NostrConnectParams, signal?: AbortSignal): Promise<void> {
|
||||
const login = await NLogin.fromNostrConnect(params, nostr, { signal });
|
||||
addLogin(login);
|
||||
},
|
||||
// Get the relay URLs for NIP-46 nostrconnect communication
|
||||
getRelayUrls(): string[] {
|
||||
const relays = config.relayMetadata.relays
|
||||
.filter((r) => r.write)
|
||||
.map((r) => r.url);
|
||||
return relays.length > 0 ? relays : ['wss://relay.damus.io'];
|
||||
},
|
||||
// Log out the current user
|
||||
async logout(): Promise<void> {
|
||||
const login = logins[0];
|
||||
|
||||
Reference in new issue
Block a user