feat(nip46): launch signer via nostrsigner callback
This commit is contained in:
+10
-10
@@ -15,19 +15,18 @@ const APP_SCHEME = "social.flotilla"
|
|||||||
|
|
||||||
type NostrSignerScheme = "aegis" | "nostrsigner"
|
type NostrSignerScheme = "aegis" | "nostrsigner"
|
||||||
|
|
||||||
const makeSignerCallbackUrl = (path: string, sourceAppScheme: string) =>
|
const makeSignerCallbackUrl = (path: string) => `${APP_SCHEME}://x-callback-url/${path}`
|
||||||
`${sourceAppScheme}://x-callback-url/${path}`
|
|
||||||
|
|
||||||
const makeSignerLaunchUrl = (scheme: NostrSignerScheme, nostrconnectUrl: string) => {
|
const makeSignerLaunchUrl = (nostrconnectUrl: string) => {
|
||||||
const params = new URLSearchParams({
|
const params = new URLSearchParams({
|
||||||
method: "connect",
|
method: "connect",
|
||||||
nostrconnect: nostrconnectUrl,
|
nostrconnect: nostrconnectUrl,
|
||||||
"x-source": APP_SCHEME,
|
"x-source": APP_SCHEME,
|
||||||
"x-success": makeSignerCallbackUrl("authSuccess", APP_SCHEME),
|
"x-success": makeSignerCallbackUrl("authSuccess"),
|
||||||
"x-error": makeSignerCallbackUrl("authError", APP_SCHEME),
|
"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 {
|
export class Nip46Controller {
|
||||||
@@ -54,8 +53,8 @@ export class Nip46Controller {
|
|||||||
|
|
||||||
this.url.set(url)
|
this.url.set(url)
|
||||||
this.signerUrls.set({
|
this.signerUrls.set({
|
||||||
aegis: makeSignerLaunchUrl("aegis", url),
|
aegis: makeSignerLaunchUrl(url),
|
||||||
nostrsigner: makeSignerLaunchUrl("nostrsigner", url),
|
nostrsigner: makeSignerLaunchUrl(url),
|
||||||
})
|
})
|
||||||
|
|
||||||
let response
|
let response
|
||||||
@@ -78,8 +77,9 @@ export class Nip46Controller {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
launchSigner(scheme: NostrSignerScheme) {
|
launchSigner(_scheme?: NostrSignerScheme) {
|
||||||
const signerUrl = get(this.signerUrls)?.[scheme]
|
const nostrconnectUrl = get(this.url)
|
||||||
|
const signerUrl = nostrconnectUrl && makeSignerLaunchUrl(nostrconnectUrl)
|
||||||
|
|
||||||
if (!signerUrl) {
|
if (!signerUrl) {
|
||||||
pushToast({
|
pushToast({
|
||||||
|
|||||||
Reference in New Issue
Block a user