Skip to content

Commit

Permalink
fix: nprofile login
Browse files Browse the repository at this point in the history
  • Loading branch information
v0l committed Sep 9, 2024
1 parent b5c8f39 commit 88a53a0
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions packages/app/src/Hooks/useLoginHandler.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 88a53a0

Please sign in to comment.