From 007e0b41d07ed942b326b84152dd52ff22d70ed8 Mon Sep 17 00:00:00 2001 From: Kai Date: Sat, 28 Mar 2026 03:04:16 +0100 Subject: [PATCH] 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 --- nip46.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/nip46.ts b/nip46.ts index 9aa426c..78c2693 100644 --- a/nip46.ts +++ b/nip46.ts @@ -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) {