From 057767152c4d10957455d8d64163cfc564e33c6d Mon Sep 17 00:00:00 2001 From: jwinterm Date: Fri, 10 Jul 2026 09:55:01 -0400 Subject: [PATCH] fix(smirk): fall back to legacy connect() on a locked signNostrEvent (restores unlock-popup path) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Only an explicit user-cancel skips the fallback now — a LOCKED signNostrEvent again tries connect(), which opens the unlock popup on capable builds. My earlier refinement had removed this path. --- html/js/network/smirkAuth.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/html/js/network/smirkAuth.js b/html/js/network/smirkAuth.js index 454ec0a..341a126 100644 --- a/html/js/network/smirkAuth.js +++ b/html/js/network/smirkAuth.js @@ -77,16 +77,15 @@ const SmirkAuth = { verifyData = result.verifyData; provenPublicKey = result.pubkey; } catch (nip98Err) { - // Only fall back to the legacy path when the wallet genuinely can't do NIP-98 - // (method missing / unsupported). For LOCKED (unlock the extension), USER_REJECTED - // (user closed the popup), or a real signing failure, SURFACE it — re-invoking - // connect() would just pop a second prompt. On a current Smirk build a locked - // signNostrEvent auto-opens the unlock popup and never reaches here. + // Fall back to the legacy connect() path UNLESS the user explicitly cancelled the + // popup. This gives connect() a chance to open the unlock prompt when a locked + // signNostrEvent threw LOCKED instead of prompting (partial/stale builds), and + // covers wallets that lack NIP-98 entirely. Only an explicit cancel is not retried. const code = nip98Err && nip98Err.code; - const methodMissing = code === 'UNSUPPORTED' || code === 'METHOD_NOT_FOUND' - || /not a function|is not supported|no such method|unsupported/i.test((nip98Err && nip98Err.message) || ''); - if (!methodMissing) throw nip98Err; - console.warn('Smirk NIP-98 unsupported, falling back to legacy:', nip98Err && nip98Err.message); + const userCancelled = code === 'USER_REJECTED' + || /reject|cancel|denied|declined/i.test((nip98Err && nip98Err.message) || ''); + if (userCancelled) throw nip98Err; + console.warn('Smirk NIP-98 failed, trying legacy connect():', nip98Err && nip98Err.message); const result = await this._verifyLegacy(socketId, challenge); verifyData = result.verifyData; provenPublicKey = result.pubkey;