Skip to content

Commit

Permalink
fix(nostr): handle failing key decrypt #1925
Browse files Browse the repository at this point in the history
  • Loading branch information
escapedcat committed Jan 3, 2023
1 parent d36dab4 commit 7224a68
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/extension/background-script/nostr/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as secp256k1 from "@noble/secp256k1";
import { Buffer } from "buffer";
import { AES } from "crypto-js";
import * as CryptoJS from "crypto-js";
import { AES } from "crypto-js";
import Base64 from "crypto-js/enc-base64";
import Hex from "crypto-js/enc-hex";
import Utf8 from "crypto-js/enc-utf8";
Expand All @@ -16,7 +16,11 @@ class Nostr {
const password = state.getState().password as string;
const encryptedKey = state.getState().nostrPrivateKey as string;
if (encryptedKey) {
return decryptData(encryptedKey, password);
try {
return decryptData(encryptedKey, password);
} catch (e) {
if (e instanceof Error) console.error("Couldn't get key");
}
}

return null;
Expand Down

0 comments on commit 7224a68

Please sign in to comment.