From db157efda483a9fbbeefd816a4be41ee704b294a Mon Sep 17 00:00:00 2001 From: "shakespeare.diy" Date: Fri, 3 Jul 2026 14:17:51 +0700 Subject: [PATCH] fix: use window.location.href for Amber NIP-55 intent (not window.open) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit window.open(..., '_blank') opens a new browser tab instead of firing the Android intent — causing Amber's "malformed request" error. Per NIP-55 spec the correct method is window.location.href = url, which triggers the nostrsigner: intent that Amber is registered to handle. Co-authored-by: shakespeare.diy --- src/lib/amber.ts | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/src/lib/amber.ts b/src/lib/amber.ts index 68b7898..1c61c96 100644 --- a/src/lib/amber.ts +++ b/src/lib/amber.ts @@ -300,22 +300,15 @@ function buildCallbackUrl(): string { /** * Navigate to an Amber nostrsigner: URL. * - * Amber has two code paths depending on how it receives the intent: + * Per NIP-55, web clients must navigate directly to the nostrsigner: URI + * using window.location.href. This fires an Android intent that Amber + * intercepts via its registered nostrsigner: scheme handler. * - * 1. NATIVE path (no Browser.EXTRA_APPLICATION_ID): reads type from - * intent EXTRAS — not set when coming from a WebView URL navigation. - * - * 2. WEB/BROWSER path (Browser.EXTRA_APPLICATION_ID present): reads type - * from URL query params — set when a browser/WebView opens a URL. - * - * We need the WEB path. window.open('url', '_blank') causes the WebView - * to open the URL as a browser navigation, which sets - * Browser.EXTRA_APPLICATION_ID and routes Amber to parse our URL params. + * DO NOT use window.open(..., '_blank') — that opens a new tab/window + * instead of firing the intent, which is what caused "malformed request". */ function openAmberUrl(url: string): void { - // _blank triggers the browser intent path in Android WebView, - // which sets Browser.EXTRA_APPLICATION_ID so Amber reads URL query params. - window.open(url, '_blank'); + window.location.href = url; } /**