use serde::Deserialize;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum SupportedHashAlg {
Sha2_256,
Blake2b256,
}
impl SupportedHashAlg {
#[must_use]
pub const fn as_str(self) -> &'static str {
match self {
SupportedHashAlg::Sha2_256 => "sha2-256",
SupportedHashAlg::Blake2b256 => "blake2b-256",
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum SealedKemChoice {
X25519,
Mlkem768X25519,
}
pub type PoeStatus = String;
pub type ConformanceProfile = String;
#[derive(Debug, Clone, Copy)]
pub struct QuoteInput {
pub record_bytes: u64,
pub recipient_count: u64,
pub file_bytes_total: u64,
}
#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
pub struct QuoteResponse {
pub quote_id: String,
pub amount: String,
pub currency: String,
pub expires_at: String,
}
#[derive(Debug, Clone)]
pub struct UploadsInput {
pub target: String,
pub data: Vec<Vec<u8>>,
pub idempotency_key: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
#[serde(untagged)]
pub enum UploadEntry {
Success {
idx: u64,
ok: bool,
uri: String,
sha256: String,
bytes: u64,
},
Failure {
idx: u64,
ok: bool,
error: UploadError,
},
}
impl UploadEntry {
#[must_use]
pub fn is_ok(&self) -> bool {
matches!(self, UploadEntry::Success { .. })
}
#[must_use]
pub fn idx(&self) -> u64 {
match self {
UploadEntry::Success { idx, .. } | UploadEntry::Failure { idx, .. } => *idx,
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
pub struct UploadError {
pub code: String,
pub detail: String,
}
#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
pub struct UploadsResponse {
pub uploads: Vec<UploadEntry>,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct RecordSignature {
pub cose_sign1: String,
pub cose_key: Option<String>,
}
#[derive(Debug, Clone)]
pub struct PublishInput {
pub record: Vec<u8>,
pub quote_id: String,
pub signatures: Option<Vec<RecordSignature>>,
pub idempotency_key: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Deserialize)]
pub struct PoeItemResponse {
pub item_idx: u64,
pub hashes: std::collections::BTreeMap<String, String>,
pub uris: Option<Vec<String>>,
pub enc: Option<serde_json::Value>,
}
#[derive(Debug, Clone, PartialEq, Deserialize)]
pub struct PublishResponse {
pub id: String,
pub tx_hash: Option<String>,
pub status: PoeStatus,
pub items_count: u64,
pub signed: bool,
pub sealed: bool,
pub items: Vec<PoeItemResponse>,
pub conformance_profile: ConformanceProfile,
pub balance_after_usd_micros: String,
#[serde(default)]
pub dedup_hit: bool,
}
#[derive(Debug, Clone)]
pub struct PublishBatchEntry {
pub record: Vec<u8>,
pub quote_id: String,
pub signatures: Option<Vec<RecordSignature>>,
}
#[derive(Debug, Clone)]
pub struct PublishBatchInput {
pub records: Vec<PublishBatchEntry>,
pub idempotency_key: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Deserialize)]
pub struct PublishBatchSuccessEntry {
pub record_idx: u64,
pub id: String,
pub tx_hash: Option<String>,
pub status: PoeStatus,
pub items_count: u64,
pub signed: bool,
pub sealed: bool,
pub items: Vec<PoeItemResponse>,
pub conformance_profile: ConformanceProfile,
}
#[derive(Debug, Clone, PartialEq, Deserialize)]
pub struct PublishBatchFailureError {
pub code: String,
pub detail: String,
pub errors: Option<Vec<crate::client::errors::ProblemErrorEntry>>,
pub extensions: Option<serde_json::Map<String, serde_json::Value>>,
}
#[derive(Debug, Clone, PartialEq, Deserialize)]
pub struct PublishBatchFailureEntry {
pub record_idx: u64,
pub error: PublishBatchFailureError,
}
#[derive(Debug, Clone, PartialEq, Deserialize)]
#[serde(untagged)]
pub enum PublishBatchResultEntry {
Success(PublishBatchSuccessEntry),
Failure(PublishBatchFailureEntry),
}
#[derive(Debug, Clone, PartialEq, Deserialize)]
pub struct PublishBatchResponse {
pub results: Vec<PublishBatchResultEntry>,
pub balance_after_usd_micros: String,
}
#[derive(Debug, Clone, PartialEq, Deserialize)]
pub struct RecordResource {
pub tx_hash: String,
pub status: Option<String>,
pub block_height: Option<u64>,
pub block_time: Option<String>,
pub num_confirmations: u64,
pub scheme: u8,
pub item_count: u64,
pub signer_ed25519: Option<String>,
pub metadata_cbor_base64: String,
pub account_id: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
pub struct AccountBalance {
pub balance_usd_micros: String,
}
#[derive(Debug, Clone)]
pub struct PoeVerifyDecryption {
pub item_idx: u64,
pub recipient_secret_key: Option<String>,
pub passphrase: Option<String>,
}
#[derive(Debug, Clone, Default)]
pub struct PoeVerifyInput {
pub verify_uris: Option<bool>,
pub decryption: Option<Vec<PoeVerifyDecryption>>,
}
#[derive(Debug, Clone, Default)]
pub struct RecordsListInput {
pub cursor: Option<String>,
pub limit: Option<u64>,
pub sealed: Option<bool>,
}
#[derive(Debug, Clone, PartialEq, Deserialize)]
pub struct RecordsListResponse {
pub object: String,
pub data: Vec<RecordResource>,
pub has_more: bool,
pub next_cursor: Option<String>,
pub url: String,
#[serde(default)]
pub tip_block_height: Option<u64>,
}
pub struct PublishContentInput<'a> {
pub content: Vec<u8>,
pub quote_id: String,
pub hash_alg: Option<SupportedHashAlg>,
pub signer: Option<&'a dyn crate::client::publish::Signer>,
pub idempotency_key: Option<String>,
}
pub struct PublishPrehashedInput<'a> {
pub hashes: Vec<(SupportedHashAlg, String)>,
pub quote_id: String,
pub signer: Option<&'a dyn crate::client::publish::Signer>,
pub idempotency_key: Option<String>,
}
pub struct PublishSealedInput<'a> {
pub content: Vec<u8>,
pub recipients: Vec<Vec<u8>>,
pub quote_id: String,
pub hash_alg: Option<SupportedHashAlg>,
pub kem: Option<SealedKemChoice>,
pub signer: Option<&'a dyn crate::client::publish::Signer>,
pub idempotency_key: Option<String>,
}
#[derive(Debug, Clone)]
pub enum MerkleLeaf {
Bytes(Vec<u8>),
Hex(String),
}
pub struct PublishMerkleInput<'a> {
pub leaves: Vec<MerkleLeaf>,
pub quote_id: String,
pub hash_alg: Option<SupportedHashAlg>,
pub signer: Option<&'a dyn crate::client::publish::Signer>,
pub idempotency_key: Option<String>,
}
#[derive(Debug, Clone, PartialEq)]
pub struct PublishMerkleResponse {
pub id: String,
pub tx_hash: Option<String>,
pub status: PoeStatus,
pub root: String,
pub leaf_count: u64,
pub ar_uri: String,
pub balance_after_usd_micros: String,
}