add NIP-46 support (#61)

Co-authored-by: highperfocused <highperfocused@pm.me>
This commit is contained in:
mroxso
2025-04-18 18:35:43 +02:00
committed by GitHub
parent bd8c670a3a
commit 0df571067f
10 changed files with 1056 additions and 5 deletions

View File

@@ -1,5 +1,6 @@
import { Event as NostrEvent, finalizeEvent} from "nostr-tools";
import { hexToBytes } from "@noble/hashes/utils"
import { signEventWithBunker } from "./bunkerUtils";
export function getImageUrl(tags: string[][]): string {
const imetaTag = tags.find(tag => tag[0] === 'imeta');
@@ -33,6 +34,15 @@ export async function signEvent(loginType: string | null, event: NostrEvent): Pr
// TODO: Sign event with amber
alert('Signing with Amber is not implemented yet, sorry!');
return null;
} else if (loginType === 'bunker') {
// Sign with bunker (NIP-46)
const signedWithBunker = await signEventWithBunker(event);
if (signedWithBunker) {
return signedWithBunker;
} else {
alert('Failed to sign with bunker. Please check your connection and try again.');
return null;
}
} else if (loginType === 'raw_nsec') {
if (typeof window !== 'undefined') {
let nsecStr = null;