classic-ui/modules/account/store/actions/decryptNote.js

17 lines
463 B
JavaScript
Raw Normal View History

2022-04-21 23:05:56 -04:00
import { decrypt } from 'eth-sig-util'
import { unpackEncryptedMessage } from '@/utils'
export async function decryptNote({ dispatch }, encryptedNote) {
try {
const recoveryKey = await dispatch('getRecoveryKey')
const unpackedMessage = unpackEncryptedMessage(encryptedNote)
const [, note] = decrypt(unpackedMessage, recoveryKey).split('-')
return note
} catch (err) {
console.warn(`Method decryptNote has error: ${err.message}`)
}
}