diff --git a/lumina/app/layout.tsx b/lumina/app/layout.tsx index f5595eb..a97188d 100644 --- a/lumina/app/layout.tsx +++ b/lumina/app/layout.tsx @@ -10,6 +10,7 @@ import { Inter } from "next/font/google"; import { Toaster } from "@/components/ui/toaster" import Script from "next/script"; import Umami from "@/components/Umami"; +import { useEffect } from "react"; const inter = Inter({ subsets: ["latin"] }); @@ -19,6 +20,15 @@ export default function RootLayout({ children: React.ReactNode; }>) { + useEffect(() => { + // handle Amber Sign Response + const urlParams = new URLSearchParams(window.location.search); + const amberSignResponse = urlParams.get('amberSignResponse'); + if (amberSignResponse !== null) { + alert(amberSignResponse); + } + }, []); + const relayUrls = [ "wss://relay.nostr.band", "wss://relay.damus.io", diff --git a/lumina/utils/utils.ts b/lumina/utils/utils.ts index 45fd701..b117529 100644 --- a/lumina/utils/utils.ts +++ b/lumina/utils/utils.ts @@ -31,8 +31,18 @@ export async function signEvent(loginType: string | null, event: NostrEvent): Pr eventSigned = await window.nostr.signEvent(event); } else if (loginType === 'amber') { // TODO: Sign event with amber - alert('Signing with Amber is not implemented yet, sorry!'); - return null; + // alert('Signing with Amber is not implemented yet, sorry!'); + // return null; + + // get the full current url of the user + let callbackUrl = window.location.host + window.location.pathname; + + console.log(callbackUrl); + if (!callbackUrl) { + throw new Error("Callback URL is null or undefined but needed for Amber Signing"); + } + const intent = `intent:#Intent;scheme=nostrsigner;S.compressionType=gzip;S.returnType=signature;S.type=get_public_key;S.callbackUrl=http://${callbackUrl}?amberSignResponse=;end`; + window.location.href = intent; } else if (loginType === 'raw_nsec') { if (typeof window !== 'undefined') { let nsecStr = null;