Require a user tap to launch the Nostr signer (fixes Amber malformed)

Amber v6.2.0 routes nostrsigner: intents by EXTRA_APPLICATION_ID: present
(web flow, reads the event from the URI) vs absent (app-to-app flow,
reads type/event from intent extras → rejects our URI as malformed).
Browsers only attach that extra when the external-app launch comes from a
user gesture, so the auto-redirect on page load always failed. The
launcher now waits for the user to tap "Mit Amber signieren".
This commit is contained in:
HolgerHatGarKeineNode
2026-06-11 22:54:40 +02:00
parent 7e491326a9
commit 76894a6634
@@ -8,23 +8,27 @@
body { margin: 0; min-height: 100dvh; display: flex; align-items: center; justify-content: center; body { margin: 0; min-height: 100dvh; display: flex; align-items: center; justify-content: center;
background: #09090b; color: #fafafa; font-family: ui-sans-serif, system-ui, sans-serif; } background: #09090b; color: #fafafa; font-family: ui-sans-serif, system-ui, sans-serif; }
.card { text-align: center; padding: 2rem; max-width: 22rem; } .card { text-align: center; padding: 2rem; max-width: 22rem; }
h1 { font-size: 1.25rem; margin: 1rem 0 .5rem; } .logo { width: 5rem; height: 5rem; margin: 0 auto 1.5rem; }
h1 { font-size: 1.25rem; margin: 0 0 .5rem; }
p { color: #a1a1aa; line-height: 1.5; } p { color: #a1a1aa; line-height: 1.5; }
button.launch { margin-top: 1.5rem; padding: .875rem 1.25rem; border: 0; border-radius: .75rem; button.launch { margin-top: 1.5rem; width: 100%; padding: 1rem 1.25rem; border: 0; border-radius: .75rem;
background: #f7931a; color: #09090b; font-weight: 600; font-size: 1rem; cursor: pointer; } background: #f7931a; color: #09090b; font-weight: 600; font-size: 1.05rem; cursor: pointer; }
</style> </style>
</head> </head>
<body> <body>
<div class="card"> <div class="card">
<h1>{{ __('Anmeldung mit Nostr') }}</h1> <h1>{{ __('Anmeldung mit Nostr') }}</h1>
<p>{{ __('Dein Nostr-Signer (z. B. Amber) öffnet sich gleich. Falls nicht, tippe auf den Button.') }}</p> <p>{{ __('Tippe auf den Button, um die Anmeldung mit deinem Nostr-Signer (z. B. Amber) zu signieren.') }}</p>
<button class="launch" onclick="launchSigner()">{{ __('Signer öffnen') }}</button> {{-- The signer MUST be launched from a user gesture: browsers only
attach the EXTRA_APPLICATION_ID that routes Amber into its
web-signing flow when the external-app launch is user-initiated.
An auto-redirect on load is rejected by Amber as malformed. --}}
<button class="launch" onclick="launchSigner()">{{ __('Mit Amber signieren') }}</button>
</div> </div>
<script> <script>
// Build the NIP-55 signer URI in the browser with // Build the NIP-55 signer URI in the browser with
// encodeURIComponent(JSON.stringify(event)) — the exact encoding // encodeURIComponent(JSON.stringify(event)) and launch via
// Amber accepts. Launch via window.location so the intent carries // window.location so the intent carries category.BROWSABLE.
// category.BROWSABLE and Amber uses its web-signing flow.
function launchSigner() { function launchSigner() {
const event = { const event = {
kind: 22242, kind: 22242,
@@ -36,8 +40,6 @@
+ '?compressionType=none&returnType=event&type=sign_event&appName=Einundzwanzig' + '?compressionType=none&returnType=event&type=sign_event&appName=Einundzwanzig'
+ '&callbackUrl=' + encodeURIComponent(@js($callbackUrl)); + '&callbackUrl=' + encodeURIComponent(@js($callbackUrl));
} }
launchSigner();
</script> </script>
</body> </body>
</html> </html>