Show TOTP codes in password details (#75)

This commit is contained in:
2026-08-11 23:40:24 +02:00
parent 9759162eff
commit 2026637a0e
9 changed files with 640 additions and 110 deletions

View File

@@ -7,9 +7,9 @@ use sha2::{Digest as _, Sha256};
use crate::{
command::EditRequest,
crypto::{KeyStore, SecretProvider},
otp::{OtpAlgorithm, OtpKind, OtpUri},
otp::{OtpAlgorithm, OtpError, OtpKind, OtpUri},
recipient::SigningPolicy,
repository::{EntryPath, Repository, SecretBytes},
repository::{EncryptedEntry, EntryPath, Repository, SecretBytes},
write::{EditSession, EntryCommitter, VaultWriter, WriteError, WriteOutcome},
};
@@ -424,6 +424,15 @@ impl EntryDocument {
SecretBytes::new(output)
}
pub(crate) fn original_ciphertext(&self) -> Option<&EncryptedEntry> {
self.session.original_ciphertext()
}
pub(crate) fn otp_uri(&self) -> Result<Option<OtpUri>, OtpError> {
let plaintext = self.serialize();
crate::otp::find_uri(&plaintext, &self.path).map(|found| found.map(|(_, uri)| uri))
}
fn has_final_newline(&self) -> bool {
self.fields
.last()