feat(v3): migrate workspace to API, Tauri desktop, and v3 crates; remove legacy MCP stack
Some checks failed
Secrets v3 CI / 检查 (push) Has been cancelled
Some checks failed
Secrets v3 CI / 检查 (push) Has been cancelled
- Add apps/api, desktop Tauri shell, domain/application/crypto/device-auth/infrastructure-db - Replace desktop-daemon vault integration; drop secrets-core and secrets-mcp* - Ignore apps/desktop/dist and generated Tauri icons; document icon/dist steps in AGENTS.md - Apply rustfmt; fix clippy (collapsible_if, HTTP method as str)
This commit is contained in:
138
crates/domain/src/cipher.rs
Normal file
138
crates/domain/src/cipher.rs
Normal file
@@ -0,0 +1,138 @@
|
||||
use chrono::{DateTime, Utc};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::Value;
|
||||
use uuid::Uuid;
|
||||
|
||||
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum CipherType {
|
||||
Login,
|
||||
ApiKey,
|
||||
SecureNote,
|
||||
SshKey,
|
||||
Identity,
|
||||
Card,
|
||||
}
|
||||
|
||||
impl CipherType {
|
||||
pub fn as_str(&self) -> &'static str {
|
||||
match self {
|
||||
Self::Login => "login",
|
||||
Self::ApiKey => "api_key",
|
||||
Self::SecureNote => "secure_note",
|
||||
Self::SshKey => "ssh_key",
|
||||
Self::Identity => "identity",
|
||||
Self::Card => "card",
|
||||
}
|
||||
}
|
||||
|
||||
pub fn parse(input: &str) -> Self {
|
||||
match input {
|
||||
"login" => Self::Login,
|
||||
"api_key" => Self::ApiKey,
|
||||
"secure_note" => Self::SecureNote,
|
||||
"ssh_key" => Self::SshKey,
|
||||
"identity" => Self::Identity,
|
||||
"card" => Self::Card,
|
||||
_ => Self::SecureNote,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
|
||||
pub struct CustomField {
|
||||
pub name: String,
|
||||
pub value: Value,
|
||||
#[serde(default)]
|
||||
pub sensitive: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Default)]
|
||||
pub struct LoginPayload {
|
||||
#[serde(default)]
|
||||
pub username: Option<String>,
|
||||
#[serde(default)]
|
||||
pub uris: Vec<String>,
|
||||
#[serde(default)]
|
||||
pub password: Option<String>,
|
||||
#[serde(default)]
|
||||
pub totp: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Default)]
|
||||
pub struct ApiKeyPayload {
|
||||
#[serde(default)]
|
||||
pub client_id: Option<String>,
|
||||
#[serde(default)]
|
||||
pub secret: Option<String>,
|
||||
#[serde(default)]
|
||||
pub base_url: Option<String>,
|
||||
#[serde(default)]
|
||||
pub host: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Default)]
|
||||
pub struct SecureNotePayload {
|
||||
#[serde(default)]
|
||||
pub text: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Default)]
|
||||
pub struct SshKeyPayload {
|
||||
#[serde(default)]
|
||||
pub username: Option<String>,
|
||||
#[serde(default)]
|
||||
pub host: Option<String>,
|
||||
#[serde(default)]
|
||||
pub port: Option<u16>,
|
||||
#[serde(default)]
|
||||
pub private_key: Option<String>,
|
||||
#[serde(default)]
|
||||
pub passphrase: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
|
||||
#[serde(tag = "kind", rename_all = "snake_case")]
|
||||
pub enum ItemPayload {
|
||||
Login(LoginPayload),
|
||||
ApiKey(ApiKeyPayload),
|
||||
SecureNote(SecureNotePayload),
|
||||
SshKey(SshKeyPayload),
|
||||
}
|
||||
|
||||
impl Default for ItemPayload {
|
||||
fn default() -> Self {
|
||||
Self::SecureNote(SecureNotePayload::default())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
|
||||
pub struct CipherView {
|
||||
pub id: Uuid,
|
||||
pub cipher_type: CipherType,
|
||||
pub name: String,
|
||||
pub folder: String,
|
||||
#[serde(default)]
|
||||
pub notes: Option<String>,
|
||||
#[serde(default)]
|
||||
pub custom_fields: Vec<CustomField>,
|
||||
#[serde(default)]
|
||||
pub deleted_at: Option<DateTime<Utc>>,
|
||||
pub revision_date: DateTime<Utc>,
|
||||
pub payload: ItemPayload,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
|
||||
pub struct Cipher {
|
||||
pub id: Uuid,
|
||||
pub user_id: Uuid,
|
||||
pub object_kind: String,
|
||||
pub cipher_type: CipherType,
|
||||
pub revision: i64,
|
||||
pub cipher_version: i32,
|
||||
pub ciphertext: Vec<u8>,
|
||||
pub content_hash: String,
|
||||
pub deleted_at: Option<DateTime<Utc>>,
|
||||
pub created_at: DateTime<Utc>,
|
||||
pub updated_at: DateTime<Utc>,
|
||||
}
|
||||
Reference in New Issue
Block a user