diff --git a/src/utils/nostr.ts b/src/utils/nostr.ts index 0ed4054..474e8dc 100644 --- a/src/utils/nostr.ts +++ b/src/utils/nostr.ts @@ -363,11 +363,21 @@ export const createWrap = (unsignedEvent: UnsignedEvent, receiver: string) => { * @returns The user application data or null if an error occurs or no data is found. */ export const getUsersAppData = async (): Promise => { + // Get an instance of the NostrController + const nostrController = NostrController.getInstance() + // Initialize an array to hold relay URLs const relays: string[] = [] // Retrieve the user's public key and relay map from the Redux store const usersPubkey = store.getState().auth.usersPubkey! + + // Decryption can fail down in the code if extension options changed + // Forcefully log out the user if we detect missmatch between pubkeys + if (usersPubkey !== (await nostrController.capturePublicKey())) { + return null + } + const relayMap = store.getState().relays?.map // Check if relayMap is undefined in the Redux store @@ -448,9 +458,6 @@ export const getUsersAppData = async (): Promise => { } } - // Get an instance of the NostrController - const nostrController = NostrController.getInstance() - // Decrypt the encrypted content const decrypted = await nostrController .nip04Decrypt(usersPubkey, encryptedContent)