NIP-46 draft

This commit is contained in:
2023-07-05 11:41:47 +01:00
parent 9640a7fa57
commit 68b9a89278
8 changed files with 256 additions and 65 deletions

View File

@ -5,6 +5,7 @@ import { LoginStore } from "Login";
import { generateBip39Entropy, entropyToPrivateKey } from "nip6";
import { getNip05PubKey } from "Pages/LoginPage";
import { bech32ToHex } from "SnortUtils";
import { Nip7Signer, Nip46Signer } from "@snort/system";
export default function useLoginHandler() {
const { formatMessage } = useIntl();
@ -43,6 +44,13 @@ export default function useLoginHandler() {
throw new Error(insecureMsg);
}
LoginStore.loginWithPrivateKey(key);
} else if (key.startsWith("bunker://")) {
const inner = new Nip7Signer();
const nip46 = new Nip46Signer(key, inner);
await nip46.init();
const loginPubkey = await nip46.getPubKey();
LoginStore.loginWithPubkey(loginPubkey);
} else {
throw new Error("INVALID PRIVATE KEY");
}