Edit: For this something like tweetnacl is probably more foolproof, checkout: https://github.com/dchest/tweetnacl-js
Or libsodium which can also be compiled to pure js: https://github.com/jedisct1/libsodium.js
Edit: For this something like tweetnacl is probably more foolproof, checkout: https://github.com/dchest/tweetnacl-js
Or libsodium which can also be compiled to pure js: https://github.com/jedisct1/libsodium.js
Another easy to make error would've been to use the same key for the MAC and the encryption. In this case, the library probably uses a unique salt everytime it generate a key from the passphrase, so you're fine there too.
In principle though, using a library like NaCL or Libsodium offers a high level "encrypt and sign" primitive and you should be using something like that to avoid getting anything wrong. There are lots of mistakes to be made.
libsodium is unfortunately a bit broken because the pw_hash functions (argon + scrypt) don't work in the browser.
How could you use AES with a passphrase with no key derivation function?