From f3a49e1ebf046206c0fba5f6227214dcab0eddf2 Mon Sep 17 00:00:00 2001 From: Priyanshubhartistm Date: Mon, 6 Apr 2026 12:51:12 +0530 Subject: [PATCH 1/5] Support Aegis URL scheme for NIP-46 login --- src/app/components/BunkerConnect.svelte | 16 ++++++++++ src/app/util/nip46.ts | 41 ++++++++++++++++++++++++- src/routes/+layout.svelte | 15 +++++++++ 3 files changed, 71 insertions(+), 1 deletion(-) diff --git a/src/app/components/BunkerConnect.svelte b/src/app/components/BunkerConnect.svelte index 8755c61a..6d795a7c 100644 --- a/src/app/components/BunkerConnect.svelte +++ b/src/app/components/BunkerConnect.svelte @@ -1,4 +1,6 @@ {#if $url} @@ -20,6 +30,12 @@

Scan with your signer to log in, or click to copy.

+ {#if Capacitor.isNativePlatform()} +
+ + +
+ {/if}
{/if} {/if} diff --git a/src/app/util/nip46.ts b/src/app/util/nip46.ts index b7eaccad..5d1f1a01 100644 --- a/src/app/util/nip46.ts +++ b/src/app/util/nip46.ts @@ -1,4 +1,4 @@ -import {writable} from "svelte/store" +import {get, writable} from "svelte/store" import type {Nip46ResponseWithResult} from "@welshman/signer" import {Nip46Broker} from "@welshman/signer" import {makeSecret} from "@welshman/util" @@ -11,8 +11,28 @@ import { } from "@app/core/state" import {pushToast} from "@app/util/toast" +const APP_SCHEME = "social.flotilla" + +type NostrSignerScheme = "aegis" | "nostrsigner" + +const makeSignerCallbackUrl = (path: string, sourceAppScheme: string) => + `${sourceAppScheme}://x-callback-url/${path}` + +const makeSignerLaunchUrl = (scheme: NostrSignerScheme, nostrconnectUrl: string) => { + const params = new URLSearchParams({ + method: "connect", + nostrconnect: nostrconnectUrl, + "x-source": APP_SCHEME, + "x-success": makeSignerCallbackUrl("authSuccess", APP_SCHEME), + "x-error": makeSignerCallbackUrl("authError", APP_SCHEME), + }) + + return `${scheme}://x-callback-url/auth/nip46?${params.toString()}` +} + export class Nip46Controller { url = writable("") + signerUrls = writable<{aegis: string; nostrsigner: string} | undefined>(undefined) bunker = writable("") loading = writable(false) clientSecret = makeSecret() @@ -33,6 +53,10 @@ export class Nip46Controller { }) this.url.set(url) + this.signerUrls.set({ + aegis: makeSignerLaunchUrl("aegis", url), + nostrsigner: makeSignerLaunchUrl("nostrsigner", url), + }) let response try { @@ -54,6 +78,21 @@ export class Nip46Controller { } } + launchSigner(scheme: NostrSignerScheme) { + const signerUrl = get(this.signerUrls)?.[scheme] + + if (!signerUrl) { + pushToast({ + theme: "error", + message: "Unable to open signer app right now. Please try again.", + }) + + return + } + + window.location.href = signerUrl + } + stop() { this.broker.cleanup() this.abortController.abort() diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index 9085728f..42b3f197 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -78,6 +78,21 @@ return } + if (url.host === "x-callback-url") { + if (url.pathname === "/authError") { + const errorMessage = url.searchParams.get("errorMessage") + + pushToast({ + theme: "error", + message: errorMessage || "Signer authorization failed.", + }) + } + + if (["/authSuccess", "/authError"].includes(url.pathname)) { + return + } + } + const target = `${url.pathname}${url.search}${url.hash}` goto(target, {replaceState: false, noScroll: false}) }) -- 2.52.0 From 13e1ca46fce27d275e833cff8733cabf9c242f6e Mon Sep 17 00:00:00 2001 From: Priyanshubhartistm Date: Fri, 10 Apr 2026 19:08:57 +0530 Subject: [PATCH 2/5] feat(nip46): launch signer via nostrsigner callback --- src/app/util/nip46.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/app/util/nip46.ts b/src/app/util/nip46.ts index 5d1f1a01..7c67eb7a 100644 --- a/src/app/util/nip46.ts +++ b/src/app/util/nip46.ts @@ -15,19 +15,18 @@ const APP_SCHEME = "social.flotilla" type NostrSignerScheme = "aegis" | "nostrsigner" -const makeSignerCallbackUrl = (path: string, sourceAppScheme: string) => - `${sourceAppScheme}://x-callback-url/${path}` +const makeSignerCallbackUrl = (path: string) => `${APP_SCHEME}://x-callback-url/${path}` -const makeSignerLaunchUrl = (scheme: NostrSignerScheme, nostrconnectUrl: string) => { +const makeSignerLaunchUrl = (nostrconnectUrl: string) => { const params = new URLSearchParams({ method: "connect", nostrconnect: nostrconnectUrl, "x-source": APP_SCHEME, - "x-success": makeSignerCallbackUrl("authSuccess", APP_SCHEME), - "x-error": makeSignerCallbackUrl("authError", APP_SCHEME), + "x-success": makeSignerCallbackUrl("authSuccess"), + "x-error": makeSignerCallbackUrl("authError"), }) - return `${scheme}://x-callback-url/auth/nip46?${params.toString()}` + return `nostrsigner://x-callback-url/auth/nip46?${params.toString()}` } export class Nip46Controller { @@ -54,8 +53,8 @@ export class Nip46Controller { this.url.set(url) this.signerUrls.set({ - aegis: makeSignerLaunchUrl("aegis", url), - nostrsigner: makeSignerLaunchUrl("nostrsigner", url), + aegis: makeSignerLaunchUrl(url), + nostrsigner: makeSignerLaunchUrl(url), }) let response @@ -78,8 +77,9 @@ export class Nip46Controller { } } - launchSigner(scheme: NostrSignerScheme) { - const signerUrl = get(this.signerUrls)?.[scheme] + launchSigner(_scheme?: NostrSignerScheme) { + const nostrconnectUrl = get(this.url) + const signerUrl = nostrconnectUrl && makeSignerLaunchUrl(nostrconnectUrl) if (!signerUrl) { pushToast({ -- 2.52.0 From 6f953ddbc73bf9833cce667141073afd466b9e43 Mon Sep 17 00:00:00 2001 From: Priyanshubhartistm Date: Fri, 10 Apr 2026 19:10:05 +0530 Subject: [PATCH 3/5] refactor(nip46): remove redundant signer URL state --- src/app/util/nip46.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/app/util/nip46.ts b/src/app/util/nip46.ts index 7c67eb7a..1755addf 100644 --- a/src/app/util/nip46.ts +++ b/src/app/util/nip46.ts @@ -31,7 +31,6 @@ const makeSignerLaunchUrl = (nostrconnectUrl: string) => { export class Nip46Controller { url = writable("") - signerUrls = writable<{aegis: string; nostrsigner: string} | undefined>(undefined) bunker = writable("") loading = writable(false) clientSecret = makeSecret() @@ -52,10 +51,6 @@ export class Nip46Controller { }) this.url.set(url) - this.signerUrls.set({ - aegis: makeSignerLaunchUrl(url), - nostrsigner: makeSignerLaunchUrl(url), - }) let response try { -- 2.52.0 From f62171a15ec116ec44d4ebe846d2484928e830c8 Mon Sep 17 00:00:00 2001 From: Priyanshubhartistm Date: Fri, 10 Apr 2026 19:11:18 +0530 Subject: [PATCH 4/5] feat(ui): show single iOS signer action --- src/app/components/BunkerConnect.svelte | 14 +++++--------- src/app/util/nip46.ts | 4 +--- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/app/components/BunkerConnect.svelte b/src/app/components/BunkerConnect.svelte index 6d795a7c..2e53c34a 100644 --- a/src/app/components/BunkerConnect.svelte +++ b/src/app/components/BunkerConnect.svelte @@ -11,13 +11,10 @@ const {controller}: Props = $props() const {url, loading} = controller + const isIos = Capacitor.getPlatform() === "ios" - const openAegis = () => { - controller.launchSigner("aegis") - } - - const openNostrSigner = () => { - controller.launchSigner("nostrsigner") + const openSigner = () => { + controller.launchSigner() } @@ -30,10 +27,9 @@

Scan with your signer to log in, or click to copy.

- {#if Capacitor.isNativePlatform()} + {#if isIos}
- - +
{/if}
diff --git a/src/app/util/nip46.ts b/src/app/util/nip46.ts index 1755addf..62297f3f 100644 --- a/src/app/util/nip46.ts +++ b/src/app/util/nip46.ts @@ -13,8 +13,6 @@ import {pushToast} from "@app/util/toast" const APP_SCHEME = "social.flotilla" -type NostrSignerScheme = "aegis" | "nostrsigner" - const makeSignerCallbackUrl = (path: string) => `${APP_SCHEME}://x-callback-url/${path}` const makeSignerLaunchUrl = (nostrconnectUrl: string) => { @@ -72,7 +70,7 @@ export class Nip46Controller { } } - launchSigner(_scheme?: NostrSignerScheme) { + launchSigner() { const nostrconnectUrl = get(this.url) const signerUrl = nostrconnectUrl && makeSignerLaunchUrl(nostrconnectUrl) -- 2.52.0 From 993cfe1c029f5f27665b071245936f14f86620be Mon Sep 17 00:00:00 2001 From: Priyanshubhartistm Date: Sat, 11 Apr 2026 00:28:24 +0530 Subject: [PATCH 5/5] Move Open in Signer button to Bunker login actions --- src/app/components/BunkerConnect.svelte | 12 ------------ src/app/components/LogInBunker.svelte | 10 ++++++++++ 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/app/components/BunkerConnect.svelte b/src/app/components/BunkerConnect.svelte index 2e53c34a..8755c61a 100644 --- a/src/app/components/BunkerConnect.svelte +++ b/src/app/components/BunkerConnect.svelte @@ -1,6 +1,4 @@ {#if $url} @@ -27,11 +20,6 @@

Scan with your signer to log in, or click to copy.

- {#if isIos} -
- -
- {/if}
{/if} {/if} diff --git a/src/app/components/LogInBunker.svelte b/src/app/components/LogInBunker.svelte index d72d4807..c5fc17de 100644 --- a/src/app/components/LogInBunker.svelte +++ b/src/app/components/LogInBunker.svelte @@ -1,4 +1,5 @@