fix: use window.location.href for Amber NIP-55 intent (not window.open)
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 <assistant@shakespeare.diy>
This commit is contained in:
parent
b69756e491
commit
db157efda4
1 changed files with 6 additions and 13 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue