mirror of
https://github.com/HolgerHatGarKeineNode/einundzwanzig-app.git
synced 2026-06-17 04:30:31 +00:00
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:
@@ -8,23 +8,27 @@
|
||||
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; }
|
||||
.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; }
|
||||
button.launch { margin-top: 1.5rem; padding: .875rem 1.25rem; border: 0; border-radius: .75rem;
|
||||
background: #f7931a; color: #09090b; font-weight: 600; font-size: 1rem; cursor: pointer; }
|
||||
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: 1.05rem; cursor: pointer; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="card">
|
||||
<h1>{{ __('Anmeldung mit Nostr') }}</h1>
|
||||
<p>{{ __('Dein Nostr-Signer (z. B. Amber) öffnet sich gleich. Falls nicht, tippe auf den Button.') }}</p>
|
||||
<button class="launch" onclick="launchSigner()">{{ __('Signer öffnen') }}</button>
|
||||
<p>{{ __('Tippe auf den Button, um die Anmeldung mit deinem Nostr-Signer (z. B. Amber) zu signieren.') }}</p>
|
||||
{{-- 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>
|
||||
<script>
|
||||
// Build the NIP-55 signer URI in the browser with
|
||||
// encodeURIComponent(JSON.stringify(event)) — the exact encoding
|
||||
// Amber accepts. Launch via window.location so the intent carries
|
||||
// category.BROWSABLE and Amber uses its web-signing flow.
|
||||
// encodeURIComponent(JSON.stringify(event)) and launch via
|
||||
// window.location so the intent carries category.BROWSABLE.
|
||||
function launchSigner() {
|
||||
const event = {
|
||||
kind: 22242,
|
||||
@@ -36,8 +40,6 @@
|
||||
+ '?compressionType=none&returnType=event&type=sign_event&appName=Einundzwanzig'
|
||||
+ '&callbackUrl=' + encodeURIComponent(@js($callbackUrl));
|
||||
}
|
||||
|
||||
launchSigner();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user