Skip to content

Commit

Permalink
Merge pull request #1685 from Emurgo/password-error-message
Browse files Browse the repository at this point in the history
fix decryption error detection
  • Loading branch information
stackchain committed Oct 15, 2021
2 parents d36ae26 + e998a05 commit 2f17385
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/crypto/commonUtils.js
Expand Up @@ -61,12 +61,11 @@ export const decryptData = async (ciphertext: string, secretKey: string): Promis
const secretKeyHex = Buffer.from(secretKey, 'utf8').toString('hex')
try {
return await decrypt_with_password(secretKeyHex, ciphertext)
} catch (e) {
if (String(e) === 'Decryption error') {
} catch (error) {
if (error.message === 'Decryption error') {
throw new WrongPassword()
}
// note: JS error from rust doesn't set e.message
throw new CardanoError(String(e))
throw new CardanoError(String(error))
}
}

Expand Down

0 comments on commit 2f17385

Please sign in to comment.