fix: nprofile login

This commit is contained in:
kieran 2024-09-09 16:24:55 +01:00
parent b5c8f39446
commit 88a53a0c06
No known key found for this signature in database
GPG Key ID: DE71CEB3925BE941

View File

@ -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);