feat(notsecrets): scaffold age-native domain types and trait ports

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Joseph O'Brien
2026-04-01 20:44:05 -04:00
parent 3760b59f31
commit 34d9e3d677
10 changed files with 276 additions and 147 deletions

View File

@@ -1,7 +1,6 @@
use anyhow::{bail, Result};
use crate::_legacy::AgeKeySource;
use anyhow::{Result, bail};
use std::process::Command;
use which::which;
use crate::AgeKeySource;
pub struct BitwardenSource {
pub item_name: String,
@@ -9,15 +8,24 @@ pub struct BitwardenSource {
impl BitwardenSource {
pub fn new(item_name: impl Into<String>) -> Self {
Self { item_name: item_name.into() }
Self {
item_name: item_name.into(),
}
}
}
impl AgeKeySource for BitwardenSource {
fn name(&self) -> &str { "bitwarden" }
fn name(&self) -> &str {
"bitwarden"
}
fn retrieve(&self) -> Result<String> {
if which("bw").is_err() {
let bw_available = Command::new("sh")
.args(["-c", "command -v bw"])
.status()
.map(|s| s.success())
.unwrap_or(false);
if !bw_available {
bail!("bw CLI not found in PATH");
}
@@ -29,7 +37,10 @@ impl AgeKeySource for BitwardenSource {
.args(["unlock", "--raw", &password])
.output()?;
if !output.status.success() {
bail!("bw unlock failed: {}", String::from_utf8_lossy(&output.stderr));
bail!(
"bw unlock failed: {}",
String::from_utf8_lossy(&output.stderr)
);
}
String::from_utf8(output.stdout)?.trim().to_string()
} else {

View File

@@ -1,6 +1,6 @@
use std::path::PathBuf;
use crate::_legacy::AgeKeySource;
use anyhow::Result;
use crate::AgeKeySource;
use std::path::PathBuf;
pub struct FileSource {
path: PathBuf,
@@ -13,7 +13,9 @@ impl FileSource {
}
impl AgeKeySource for FileSource {
fn name(&self) -> &str { "file" }
fn name(&self) -> &str {
"file"
}
fn retrieve(&self) -> Result<String> {
std::fs::read_to_string(&self.path)

View File

@@ -1,10 +1,12 @@
use crate::_legacy::AgeKeySource;
use anyhow::Result;
use crate::AgeKeySource;
pub struct PromptSource;
impl AgeKeySource for PromptSource {
fn name(&self) -> &str { "prompt" }
fn name(&self) -> &str {
"prompt"
}
fn retrieve(&self) -> Result<String> {
let key = rpassword::prompt_password("Paste your age private key: ")