[package]
name = "jacquard-common"
description = "Core AT Protocol types and utilities for Jacquard"
edition.workspace = true
version = "0.12.0"
authors.workspace = true
repository.workspace = true
keywords.workspace = true
categories.workspace = true
readme.workspace = true
exclude.workspace = true
license.workspace = true

[features]
default = ["std", "service-auth", "reqwest-client", "crypto", "reqwest-compression"]
std = [
    "dep:tokio",
    "dep:tokio-util",
    "dep:regex",
    "regex?/std",
    "rand/std",
    "rand/std_rng",
    "rand/os_rng",
    "rand/thread_rng",
    "serde_json/std",
    "serde/std",
    "postcard/use-std",
    "ciborium?/std",
    "ciborium-io?/std",
    "cid/std",
    "ipld-core/std",
    "multihash/std",
    "multibase/std",
    "serde_ipld_dagcbor/std",
    "serde_html_form/std",
    "miette",
    "dep:bon",
    "chrono/std",
    "chrono/clock",
    "http/std",
    "bytes/std",
    "oxilangtag/std",
    "serde_bytes/std"
]
crypto = []
crypto-ed25519 = ["crypto", "dep:ed25519-dalek"]
crypto-k256 = ["crypto", "dep:k256", "k256/ecdsa"]
crypto-p256 = ["crypto", "dep:p256", "p256/ecdsa"]
service-auth = ["crypto-k256", "crypto-p256", "dep:signature"]
reqwest-client = ["std", "dep:reqwest"]
tracing = ["std", "dep:tracing"]
streaming = ["n0-future", "futures", "reqwest/stream"]
websocket = ["streaming", "tokio-tungstenite-wasm", "dep:ciborium", "dep:ciborium-io"]
zstd = ["dep:zstd"]
reqwest-compression = ["reqwest/gzip", "reqwest/brotli", "reqwest/deflate"]

[dependencies]
trait-variant.workspace = true
bon = { workspace = true, optional = true }
base64.workspace = true
phf.workspace = true
bytes = { workspace = true, features = ["serde"] }
chrono.workspace = true
cid.workspace = true
ipld-core.workspace = true
oxilangtag = { version = "0.1", default-features = false, features = ["alloc", "serde"] }
miette = { workspace = true, optional = true } # also need to gate this to std only
multibase = { version = "0.9.1", default-features = false }
multihash = { version = "0.19.3", default-features = false, features = ["alloc"] }
rand = { version = "0.9.2", default-features = false, features = ["alloc"] }
serde.workspace = true
serde_html_form.workspace = true # need to check these at workspace level
serde_json.workspace = true
smol_str.workspace = true
thiserror.workspace = true
rustversion.workspace = true
unicode-segmentation.workspace = true
fluent-uri.workspace = true
http.workspace = true
serde_bytes.workspace = true
spin = { version = "0.10", default-features = false, features = ["lazy"] }
maitake-sync = { version = "0.1", default-features = false }
hashbrown = "0.15"

reqwest = { workspace = true, optional = true, features = ["json", "charset"] }
serde_ipld_dagcbor.workspace = true
signature = { version = "2", optional = true }
tracing = { workspace = true, optional = true }
tokio = { workspace = true, default-features = false, features = ["sync"], optional = true }

# Streaming support (optional)
n0-future = { workspace = true, optional = true }
futures = { version = "0.3", optional = true, default-features = false, features = ["alloc"] }
tokio-tungstenite-wasm = { version = "0.4", default-features = false, optional = true }
ciborium = { version = "0.2.0", default-features = false, optional = true }
ciborium-io = { version = "0.2.0", default-features = false, optional = true }
zstd = { version = "0.13", optional = true }
postcard = { version = "1.1.3" }

# regex-automata for no_std embedded, regex-lite for wasm, full regex with std on native
regex-automata = { version = "0.4", default-features = false, features = ["alloc", "meta", "nfa-pikevm", "syntax"] }
regex = { version = "1.11.3", default-features = false, features = ["perf-literal"], optional = true }

[target.'cfg(target_family = "wasm")'.dependencies]
getrandom = { version = "0.3.4", features = ["wasm_js"] }
chrono = { workspace = true, features = ["wasmbind"] }
getrandom_02 = { package = "getrandom", version = "0.2", features = ["js"] }
regex-lite = "0.1"
#ring = { version = "0.17", features = ["wasm32_unknown_unknown_js"]}
reqwest = { workspace = true, optional = true, features = [ "json", "gzip", "rustls-tls-manual-roots"] }
tokio-tungstenite-wasm = { version = "0.4", features = [], optional = true }

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
reqwest = { workspace = true, optional = true, features = [ "http2", "gzip", "system-proxy", "rustls-tls"] }
tokio-util = { version = "0.7.16", features = ["io"], optional = true }
tokio-tungstenite-wasm = { version = "0.4", features = ["rustls-tls-native-roots"], optional = true }


[dependencies.ed25519-dalek]
version = "2"
optional = true
default-features = false
features = ["pkcs8"]

[dependencies.k256]
version = "0.13"
optional = true
default-features = false
features = ["arithmetic"]

[dependencies.p256]
workspace = true
optional = true
features = ["arithmetic"]

[dev-dependencies]
tokio = { version = "1", features = ["macros", "rt", "rt-multi-thread"] }
futures-lite = "2.6"

[package.metadata.docs.rs]
features = [ "crypto-k256", "crypto-ed25519", "crypto-p256",  "websocket", "zstd", "service-auth", "reqwest-client", "crypto"]
