Implement the in-process structured entry editor

Closes #21
This commit is contained in:
Hermes Agent
2026-08-10 07:22:55 +00:00
parent cf7a6216ac
commit b503de8b2e
14 changed files with 1547 additions and 37 deletions

View File

@@ -46,6 +46,31 @@ impl GeneratorConfig {
pub fn character_set(&self) -> &[char] {
&self.character_set
}
/// Generate a zeroizing password for an in-process structured editor
/// without mutating a repository.
pub fn generate_secret(
&self,
length: Option<NonZeroUsize>,
no_symbols: bool,
) -> Result<SecretBytes, GenerateError> {
self.generate_secret_with_rng(length, no_symbols, &mut OsRng)
}
fn generate_secret_with_rng<R: RngCore + CryptoRng>(
&self,
length: Option<NonZeroUsize>,
no_symbols: bool,
rng: &mut R,
) -> Result<SecretBytes, GenerateError> {
let length = validate_length(length.unwrap_or(self.default_length).get())?;
let characters = if no_symbols {
&self.alphanumeric_set
} else {
&self.character_set
};
generate_password(rng, length, characters)
}
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
@@ -126,14 +151,9 @@ impl<'a> PasswordGenerator<'a> {
if request.force && request.in_place {
return Err(GenerateError::IncompatibleFlags);
}
let length = request.length.unwrap_or(self.config.default_length);
let length = validate_length(length.get())?;
let characters = if request.no_symbols {
&self.config.alphanumeric_set
} else {
&self.config.character_set
};
let password = generate_password(rng, length, characters)?;
let password =
self.config
.generate_secret_with_rng(request.length, request.no_symbols, rng)?;
let path = EntryPath::parse(&request.entry)?;
let contents = if request.in_place {
let ciphertext = self.repository.read_entry(&path)?;