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

17 lines
463 B
JavaScript
Raw Permalink Normal View History

2022-04-22 06:05:56 +03: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}`)
}
}