From 88a53a0c065843cf5a17c4a305c8385f66b11aa3 Mon Sep 17 00:00:00 2001 From: kieran Date: Mon, 9 Sep 2024 16:24:55 +0100 Subject: [PATCH] fix: nprofile login --- packages/app/src/Hooks/useLoginHandler.tsx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/app/src/Hooks/useLoginHandler.tsx b/packages/app/src/Hooks/useLoginHandler.tsx index 5d25b7f97..1278ac298 100644 --- a/packages/app/src/Hooks/useLoginHandler.tsx +++ b/packages/app/src/Hooks/useLoginHandler.tsx @@ -1,5 +1,5 @@ import { fetchNostrAddress, unwrap } from "@snort/shared"; -import { KeyStorage, Nip46Signer } from "@snort/system"; +import { KeyStorage, Nip46Signer, NostrPrefix, tryParseNostrLink } from "@snort/system"; import { useIntl } from "react-intl"; import { bech32ToHex } from "@/Utils"; @@ -46,9 +46,12 @@ export default function useLoginHandler() { } // public key logins - if (key.startsWith("npub")) { - const hexKey = bech32ToHex(key); - LoginStore.loginWithPubkey(hexKey, LoginSessionType.PublicKey); + if (key.startsWith("npub") || key.startsWith("nprofile")) { + const link = tryParseNostrLink(key, NostrPrefix.PublicKey); + if (!link) { + throw new Error("Invalid public key"); + } + LoginStore.loginWithPubkey(link.id, LoginSessionType.PublicKey); } else if (key.match(EmailRegex)) { const [name, domain] = key.split("@"); const json = await fetchNostrAddress(name, domain);