From babac497c1f44892b646b30be4d3ad035b461386 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Sat, 1 Aug 2026 23:08:02 -0700 Subject: Fix bunker (NIP-46) login: the pointer goes through fromBunker MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit nostr-tools' BunkerSigner constructor takes (clientSecretKey, params) — passing the bunker pointer as the second argument left the signer with no pointer at all, so connecting died on "reading 'pubkey'" before any network call. Use the static fromBunker, and reject an address that lists no relays with something a human can act on. Covered by a test using a real Amethyst-issued address. Co-Authored-By: Claude Fable 5 --- src/nostr-login.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nostr-login.js b/src/nostr-login.js index 00106c4..7addfc5 100644 --- a/src/nostr-login.js +++ b/src/nostr-login.js @@ -90,8 +90,11 @@ export async function extensionSigner() { export async function bunkerSigner(uri, { onAuth } = {}) { const bp = await parseBunkerInput(String(uri || '').trim()); if (!bp) throw new Error('not a bunker:// address'); + if (!bp.relays || !bp.relays.length) throw new Error('that bunker address lists no relays'); const local = generateSecretKey(); - const signer = new BunkerSigner(local, bp, { + // NB the pointer goes through fromBunker — the constructor takes params + // only, and passing the pointer there leaves the signer without one. + const signer = BunkerSigner.fromBunker(local, bp, { onauth: (url) => { if (onAuth) onAuth(url); else if (typeof window !== 'undefined') window.open(url, '_blank'); }, }); await signer.connect(); -- cgit v1.2.3