From 46119367c88aaba9064640989e7af85bb055794f Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Wed, 6 May 2026 14:08:59 -0500 Subject: [PATCH] Use APP_RELAYS as nostrconnect fallback When the user has no NIP-65 write relays configured, getRelayUrls() was building the nostrconnect:// URI with a single relay (wss://relay.ditto.pub). Fall back to the full APP_RELAYS write list instead so the remote signer has more connection options during the handshake. Extract the default relay list into src/lib/appRelays.ts as a single source of truth, shared between App.tsx (defaultConfig) and useLoginActions.ts (nostrconnect fallback). --- src/App.tsx | 10 ++-------- src/hooks/useLoginActions.ts | 7 ++++++- src/lib/appRelays.ts | 15 +++++++++++++++ 3 files changed, 23 insertions(+), 9 deletions(-) create mode 100644 src/lib/appRelays.ts diff --git a/src/App.tsx b/src/App.tsx index 2dcab48..ba65387 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -12,6 +12,7 @@ import { TooltipProvider } from "@/components/ui/tooltip"; import { NostrLoginProvider } from '@nostrify/react/login'; import { AppProvider } from '@/components/AppProvider'; import { AppConfig } from '@/contexts/AppContext'; +import { APP_RELAYS } from '@/lib/appRelays'; import AppRouter from './AppRouter'; const head = createHead({ plugins: [ @@ -31,14 +32,7 @@ const queryClient = new QueryClient({ const defaultConfig: AppConfig = { theme: "light", - relayMetadata: { - relays: [ - { url: 'wss://relay.ditto.pub', read: true, write: true }, - { url: 'wss://relay.primal.net', read: true, write: true }, - { url: 'wss://relay.damus.io', read: true, write: true }, - ], - updatedAt: 0, - }, + relayMetadata: APP_RELAYS, blossomServerMetadata: { servers: [ 'https://blossom.ditto.pub/', diff --git a/src/hooks/useLoginActions.ts b/src/hooks/useLoginActions.ts index c087580..f4ebcab 100644 --- a/src/hooks/useLoginActions.ts +++ b/src/hooks/useLoginActions.ts @@ -6,6 +6,7 @@ import { useNostrLogin, } from '@nostrify/react/login'; import { useAppContext } from '@/hooks/useAppContext'; +import { APP_RELAYS } from '@/lib/appRelays'; // NOTE: This file should not be edited except for adding new login methods. @@ -51,7 +52,11 @@ export function useLoginActions() { const relays = config.relayMetadata.relays .filter((r) => r.write) .map((r) => r.url); - return relays.length > 0 ? relays : ['wss://relay.ditto.pub']; + // Fall back to the app default relays if the user has none configured, + // so the remote signer has multiple connection options during handshake. + return relays.length > 0 + ? relays + : APP_RELAYS.relays.filter((r) => r.write).map((r) => r.url); }, // Log out the current user async logout(): Promise { diff --git a/src/lib/appRelays.ts b/src/lib/appRelays.ts new file mode 100644 index 0000000..caa53bb --- /dev/null +++ b/src/lib/appRelays.ts @@ -0,0 +1,15 @@ +import type { RelayMetadata } from '@/contexts/AppContext'; + +/** + * App default relays. Used as the initial `relayMetadata` for new users and as + * a fallback when the user has no NIP-65 relay list configured (e.g. during + * nostrconnect handshakes before any user relays have been loaded). + */ +export const APP_RELAYS: RelayMetadata = { + relays: [ + { url: 'wss://relay.ditto.pub', read: true, write: true }, + { url: 'wss://relay.primal.net', read: true, write: true }, + { url: 'wss://relay.damus.io', read: true, write: true }, + ], + updatedAt: 0, +};