[package]
name = "cts-common"
description = "Common types and traits used across the CipherStash ecosystem"
documentation = "https://docs.rs/cts-common"
version = "0.37.0"
edition.workspace = true
authors.workspace = true
repository.workspace = true
homepage.workspace = true
keywords.workspace = true
categories.workspace = true
license-file = "LICENSE"

[dependencies]
base32 = "0.5.1"
derive_more = { version = "2.0.1", features = ["display"] }
either = { version = "1.15.0", features = ["serde"] }
nom = "8.0.0"
regex = "1.11.1"

# Workspace dependencies
arrayvec = { workspace = true }
miette = { workspace = true }
serde = { workspace = true, features = ["derive"] }
serde_json = { workspace = true }
thiserror = { workspace = true }
tracing = { workspace = true }
url = { workspace = true }
uuid = { workspace = true }
utoipa = { workspace = true }
vitaminc = { workspace = true, features = ["random"] }

# Optional dependencies
# Note: Axum is not a workspace dep because ZeroKMS and CTS don't necessarily use the same version.
# Once we upgrade to Axum 0.8, we can make it a workspace dep.
axum = { version = "0.8.4", optional = true }
axum-extra = { version = "0.10.1", optional = true, features = ["typed-routing"] }
cached = { version = "0.54.0", optional = true }
chrono = { workspace = true, optional = true }
http = { workspace = true, optional = true }
diesel = { workspace = true, optional = true }
pq-sys = { workspace = true, optional = true }
openssl-sys = { workspace = true, optional = true }
fake = { workspace = true, optional = true }
rand = { workspace = true, optional = true }

# Wasm32 deps:
# - `getrandom 0.4` `wasm_js` feature for the rand 0.10 chain pulled in by
#   `vitaminc-random`. Paired with `--cfg getrandom_backend="wasm_js"` in
#   `.cargo/config.toml`.
# - `uuid` `js` feature so `Uuid::new_v4()` can source entropy in the browser.
[target.'cfg(target_arch = "wasm32")'.dependencies]
getrandom = { version = "0.4", features = ["wasm_js"] }
uuid = { workspace = true, features = ["js"] }

[dev-dependencies]
anyhow = { workspace = true }

[features]
default = ["server", "test_utils"]
cached = ["dep:cached", "dep:chrono"]
server = ["dep:axum", "dep:axum-extra", "dep:http", "dep:diesel", "dep:pq-sys", "dep:openssl-sys"]
test_utils = ["dep:fake", "dep:rand"]
