//! Data models for the vault crate

// Only keep serde derives on structs, remove unused imports

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct VaultMetadata {
    pub name: String,
    pub keyspaces: Vec<KeyspaceMetadata>,
    // ... other vault-level metadata
}

#[derive(serde::Serialize, serde::Deserialize, Debug, Clone)]
pub struct KeyspaceMetadata {
    pub name: String,
    pub salt: [u8; 16], // Unique salt for this keyspace
    pub encrypted_blob: Vec<u8>,
    pub created_at: Option<u64>, // Unix timestamp
    pub tags: Option<Vec<String>>,
    // ... other keyspace metadata
}

#[derive(serde::Serialize, serde::Deserialize, Debug, Clone)]
pub struct KeyspaceData {
    pub keypairs: Vec<KeyEntry>,
    // ... other keyspace-level metadata
}

impl zeroize::Zeroize for KeyspaceData {
    fn zeroize(&mut self) {
        for key in &mut self.keypairs {
            key.zeroize();
        }
        self.keypairs.zeroize();
    }
}

impl zeroize::Zeroize for KeyEntry {
    fn zeroize(&mut self) {
        self.private_key.zeroize();
        // Optionally, zeroize other fields if needed
    }
}

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct KeyEntry {
    pub id: String,
    pub key_type: KeyType,
    pub private_key: Vec<u8>, // Only present in memory after decryption
    pub public_key: Vec<u8>,
    pub metadata: Option<KeyMetadata>,
}

#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub enum KeyType {
    Secp256k1,
    Ed25519,
    // ...
}

#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct KeyMetadata {
    pub name: Option<String>,
    pub created_at: Option<u64>,
    pub tags: Option<Vec<String>>,
    // ...
}
