fix(crypto): correct cipher type indices to match Bitwarden API

This commit is contained in:
2026-08-26 14:47:23 +02:00
parent ea7f126e73
commit a3e9f9ab0e
3 changed files with 21 additions and 7 deletions
+6 -6
View File
@@ -233,7 +233,7 @@ class BitwardenCrypto:
cipher_type = cipher_data.get("type")
if cipher_type == 1: # Login
if cipher_type == 0: # Login
login = cipher_data.get("login", {})
result["login"] = {
"username": self._decrypt_field(
@@ -255,11 +255,11 @@ class BitwardenCrypto:
for u in login.get("uris", [])
],
}
elif cipher_type == 2: # Secure Note
elif cipher_type == 1: # Secure Note
result["notes"] = self._decrypt_field(
cipher_data.get("notes"), enc_key, mac_key
)
elif cipher_type == 3: # Card
elif cipher_type == 2: # Card
card = cipher_data.get("card", {})
result["card"] = {
"cardholderName": self._decrypt_field(
@@ -278,7 +278,7 @@ class BitwardenCrypto:
card.get("expYear"), enc_key, mac_key
),
}
elif cipher_type == 4: # Identity
elif cipher_type == 3: # Identity
identity = cipher_data.get("identity", {})
result["identity"] = {
"firstName": self._decrypt_field(
@@ -310,8 +310,8 @@ class BitwardenCrypto:
})
result["fields"] = fields
# Decrypt notes
if cipher_data.get("notes") and cipher_type != 2:
# Decrypt notes (only for non-Note types, Notes already handled above)
if cipher_data.get("notes") and cipher_type != 1:
result["notes"] = self._decrypt_field(
cipher_data.get("notes"), enc_key, mac_key
)