Skip to content

Commit

Permalink
Post-refactoring fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pilartomas committed Dec 21, 2022
1 parent 41530d3 commit 8485560
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/trezorpass/helpers/entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ async def select_entry(entries: List[Entry]) -> Entry:
Raises:
KeyboardInterrupt
"""
choices = [{"value": entry, "name": entry.label} for entry in entries]
choices = [{"value": entry, "name": entry.title} for entry in entries]
selection = await inquirer.fuzzy(
message="Select an entry:",
choices=choices,
Expand Down Expand Up @@ -51,7 +51,7 @@ async def manage_entry(entry: EncryptedEntry, decrypter: EntryDecrypter) -> None
copy(entry.username)
prompt_print("Username has been copied to the clipboard")
elif action == choices[2]:
decrypted_entry = decrypter(entry)
decrypted_entry = decrypter.decrypt(entry)
copy(decrypted_entry.password)
clipboard_dirty = True
prompt_print("Password has been copied to the clipboard")
Expand All @@ -62,7 +62,7 @@ async def manage_entry(entry: EncryptedEntry, decrypter: EntryDecrypter) -> None
("Username", entry.username)
])
elif action == choices[4]:
decrypted_entry = decrypter(entry)
decrypted_entry = decrypter.decrypt(entry)
prompt_print_pairs([
("URL", decrypted_entry.url),
("Title", decrypted_entry.title),
Expand Down
4 changes: 0 additions & 4 deletions src/trezorpass/store/containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ def __init__(self, *, url: str, title: str, username: str, nonce: str, tags: Lis
self.nonce = nonce
self.tags: List[Tag] = tags

@property
def label(self) -> str:
return self.note if self.note is not None else self.title


class Store:
def __init__(self, name: str, entries: List[Entry], tags: List[Tag]):
Expand Down
8 changes: 4 additions & 4 deletions src/trezorpass/store/entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def decode(self, entry_dict) -> EncryptedEntry:
username=entry_dict["username"],
nonce=entry_dict["nonce"],
encrypted_password=entry_dict["password"]["data"],
encrypted_safe_note=entry_dict["password"]["data"],
encrypted_safe_note=entry_dict["safe_note"]["data"],
tags=[]
)

Expand All @@ -51,15 +51,15 @@ def __init__(self, keychain: Keychain):
self.keychain = keychain

def decrypt(self, entry: EncryptedEntry) -> DecryptedEntry:
key = self.keychain(entry)
key = self.keychain.entry_key(entry)
password = json.loads(decrypt(key, bytes(entry.encrypted_password)).decode("utf8"))
secret_note = json.loads(decrypt(key, bytes(entry.encrypted_safe_note)).decode("utf8"))
safe_note = json.loads(decrypt(key, bytes(entry.encrypted_safe_note)).decode("utf8"))
return DecryptedEntry(
url=entry.url,
title=entry.title,
username=entry.username,
nonce=entry.nonce,
tags=entry.tags,
password=password,
secret_note=secret_note
safe_note=safe_note
)

0 comments on commit 8485560

Please sign in to comment.