classic-ui-dev/modules/account/store/actions/decryptNote.js
Danil Kovtonyuk 44f31f8b9f
init
2022-04-22 13:14:19 +10:00

17 lines
463 B
JavaScript

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}`)
}
}