use serde::{Deserialize, Serialize};
use crate::context_provision::ContextProvisionBundle;
use crate::credentials::CredentialBundle;
use crate::did_secrets::DidSecretsBundle;
#[derive(Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[serde(deny_unknown_fields)]
pub struct LabeledKey {
pub label: String,
pub key_b64: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub key_type: Option<String>,
}
impl std::fmt::Debug for LabeledKey {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("LabeledKey")
.field("label", &self.label)
.field("key_b64", &"<redacted>")
.field("key_type", &self.key_type)
.finish()
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum SealedPayloadV1 {
AdminCredential(Box<CredentialBundle>),
ContextProvision(Box<ContextProvisionBundle>),
DidSecrets(Box<DidSecretsBundle>),
AdminKeySet(Vec<LabeledKey>),
RawPrivateKey(RawPrivateKey),
TemplateBootstrap(Box<super::template_bootstrap::TemplateBootstrapPayload>),
TemplateBootstrapV2(Box<super::template_bootstrap::TemplateBootstrapPayloadV2>),
AdminRotation(Box<super::template_bootstrap::AdminRotationPayload>),
IssuedCredential(Box<IssuedCredentialBundle>),
MessagingBridgeCredentials(Box<MessagingBridgeCredentialsBundle>),
SeedMnemonic(Box<SeedMnemonicBundle>),
}
#[derive(Clone, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct SeedMnemonicBundle {
pub mnemonic: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub vta_did: Option<String>,
}
impl Drop for SeedMnemonicBundle {
fn drop(&mut self) {
zeroize::Zeroize::zeroize(&mut self.mnemonic);
}
}
impl std::fmt::Debug for SeedMnemonicBundle {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("SeedMnemonicBundle")
.field("mnemonic", &"<redacted>")
.field("vta_did", &self.vta_did)
.finish()
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct MessagingBridgeCredentialsBundle {
pub platform: String,
pub fields: serde_json::Map<String, serde_json::Value>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct IssuedCredentialBundle {
pub credential: serde_json::Value,
pub issuer_did: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub label: Option<String>,
}
#[derive(Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[serde(deny_unknown_fields)]
pub struct RawPrivateKey {
pub key_type: String,
pub key_bytes_b64: String,
}
impl std::fmt::Debug for RawPrivateKey {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("RawPrivateKey")
.field("key_type", &self.key_type)
.field("key_bytes_b64", &"<redacted>")
.finish()
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[serde(deny_unknown_fields)]
pub struct DidSignedAssertion {
pub did: String,
pub signature_b64: String,
pub verification_method: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[serde(deny_unknown_fields)]
pub struct AttestationQuoteAssertion {
pub format: String,
pub quote_b64: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[serde(tag = "type", rename_all = "snake_case")]
pub enum AssertionProof {
DidSigned(DidSignedAssertion),
Attested(AttestationQuoteAssertion),
PinnedOnly,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[serde(deny_unknown_fields)]
pub struct ProducerAssertion {
pub producer_did: String,
pub proof: AssertionProof,
}
#[derive(Debug, Clone)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
pub struct SealedBundle {
pub bundle_id: [u8; 16],
pub digest_algo: String,
pub chunks: Vec<ArmoredChunk>,
}
#[derive(Debug, Clone)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
pub struct ArmoredChunk {
pub chunk_index: u16,
pub total_chunks: u16,
pub sealed_bytes: Vec<u8>,
}