Skip to content

Commit

Permalink
fix(v1 decryption): return v1 password error correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
schnogz committed Feb 24, 2021
1 parent 5ba1ca9 commit fb3e70e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,7 @@ const Login = (props: InjectedFormProps<{}, Props> & Props) => {
const guidError =
loginError && loginError.toLowerCase().includes('unknown wallet id')
const passwordError =
loginError &&
(loginError.toLowerCase().includes('wrong_wallet_password') ||
loginError.toLowerCase().includes('wrong_wrapper'))
loginError && loginError.toLowerCase().includes('wrong_wallet_password')
const twoFactorError =
loginError && loginError.toLowerCase().includes('authentication code')
const accountLocked =
Expand Down
13 changes: 7 additions & 6 deletions packages/blockchain-wallet-v4/src/walletCrypto/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,8 @@ export const encryptWallet = curry((data, password, iterations, version) =>
// decryptWalletV1 :: String -> String -> Task Error Object
export const decryptWalletV1 = (password, data) => {
let decrypt = (i, o) =>
decryptDataWithPassword(data, password, i, o).chain(
safeParse,
'v1: wrong_wallet_password'
decryptDataWithPassword(data, password, i, o).chain(p =>
safeParse(p, 'v1: wrong_wallet_password')
)
// v1: CBC, ISO10126, 10 iterations
return (
Expand Down Expand Up @@ -264,7 +263,9 @@ export const decryptWalletV2V3 = (password, data) => {
}

export const decryptWallet = curry((password, data) =>
decryptWalletV1(password, data).orElse(() =>
decryptWalletV2V3(password, data)
)
decryptWalletV1(password, data).orElse(result => {
return result === 'v1: wrong_wallet_password'
? Task.rejected(result)
: decryptWalletV2V3(password, data)
})
)

0 comments on commit fb3e70e

Please sign in to comment.