[WIP] Encryption for secure values (#183)

This commit is contained in:
Gregory Schier
2025-04-15 07:18:26 -07:00
committed by GitHub
parent e114a85c39
commit 2e55a1bd6d
208 changed files with 4063 additions and 28698 deletions

View File

@@ -0,0 +1,47 @@
use serde::{Serialize, Serializer};
use std::io;
use thiserror::Error;
#[derive(Error, Debug)]
pub enum Error {
#[error(transparent)]
DbError(#[from] yaak_models::error::Error),
#[error("Keyring error: {0}")]
KeyringError(#[from] keyring::Error),
#[error("Missing workspace encryption key")]
MissingWorkspaceKey,
#[error("Incorrect workspace key")]
IncorrectWorkspaceKey,
#[error("Crypto IO error: {0}")]
IoError(#[from] io::Error),
#[error("Failed to encrypt")]
EncryptionError,
#[error("Failed to decrypt")]
DecryptionError,
#[error("Invalid encrypted data")]
InvalidEncryptedData,
#[error("Invalid key provided")]
InvalidHumanKey,
#[error("Encryption error: {0}")]
GenericError(String),
}
impl Serialize for Error {
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
where
S: Serializer,
{
serializer.serialize_str(self.to_string().as_ref())
}
}
pub type Result<T> = std::result::Result<T, Error>;