feat(nip46): add skipSwitchRelays option to BunkerSignerParams

Adds a skipSwitchRelays option that prevents automatic switchRelays()
call in fromURI. This is useful when users want to call switchRelays
manually at their own pace, avoiding race conditions when making
immediate RPC calls after connection.

Fixes #526
This commit is contained in:
Kai
2026-03-28 10:14:35 -03:00
committed by fiatjaf_
parent 8be6d08a43
commit 007e0b41d0
+5 -1
View File
@@ -115,6 +115,8 @@ export function createNostrConnectURI(params: NostrConnectParams): string {
export type BunkerSignerParams = {
pool?: AbstractSimplePool
onauth?: (url: string) => void
/** Skip automatic switchRelays() call in fromURI. Useful when you want to call it manually at your own pace. */
skipSwitchRelays?: boolean
}
export class BunkerSigner implements Signer {
@@ -220,7 +222,9 @@ export class BunkerSigner implements Signer {
signer.setupSubscription()
success = true
await Promise.race([new Promise(resolve => setTimeout(resolve, 1000)), signer.switchRelays()])
if (!bunkerParams.skipSwitchRelays) {
await Promise.race([new Promise(resolve => setTimeout(resolve, 1000)), signer.switchRelays()])
}
resolve(signer)
}
} catch (e) {