[package]
name = "c2pa"

version.workspace = true

description = "Rust SDK for C2PA (Coalition for Content Provenance and Authenticity) implementors"
authors = [
    "Maurice Fisher <mfisher@adobe.com>",
    "Gavin Peacock <gpeacock@adobe.com>",
    "Eric Scouten <scouten@adobe.com>",
    "Leonard Rosenthol <lrosenth@adobe.com>",
    "Dave Kozma <dkozma@adobe.com>",
    "Dylan Ross <dyross@adobe.com>",
]
license = "MIT OR Apache-2.0"
documentation = "https://docs.rs/c2pa"
homepage = "https://contentauthenticity.org"
repository = "https://github.com/contentauth/c2pa-rs"
readme = "../README.md"
keywords = ["xmp", "metadata"]
categories = ["api-bindings"]
edition = "2021"
rust-version = "1.88.0"
exclude = ["tests/fixtures"]

[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]

[features]
default = ["openssl", "default_http"]
add_thumbnails = ["image"]
file_io = []
fetch_remote_manifests = ["dep:wasi"]
json_schema = ["dep:schemars"]
openssl = [
    "dep:openssl",
]
pdf = ["dep:lopdf"]
rust_native_crypto = [
    "dep:const-oid",
    "dep:ecdsa",
    "dep:num-bigint-dig",
    "dep:p256",
    "dep:p384",
    "dep:p521",
    "dep:pkcs1",
    "dep:rsa",
    "dep:spki",
]
# TODO: make our async tests always use the async API so we don't need ureq + reqwest
#       see https://github.com/contentauth/c2pa-rs/issues/1364
default_http = ["http_reqwest", "http_ureq", "http_wasi", "http_wstd"]
http_reqwest_blocking = ["dep:reqwest", "reqwest/blocking"]
http_ureq = ["dep:ureq"]
http_wasi = ["dep:wasi"]
http_wstd = ["dep:wstd"]
http_reqwest = ["dep:reqwest"]

# The diagnostics feature is unsupported and might be removed.
# It enables some low-overhead timing features used in our development cycle.
diagnostics = []

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(test)'] }
# Workaround for https://github.com/est31/cargo-udeps/issues/293.

[[example]]
name = "cawg_identity"
required-features = ["file_io"]

[[example]]
name = "client"
required-features = ["file_io"]

[[example]]
name = "show"
required-features = ["file_io"]

[[example]]
name = "v2show"

[[example]]
name = "api"

[[example]]
name = "fragmented_bmff"
required-features = ["file_io"]

[[example]]
name = "progress"

[lib]
crate-type = ["lib"]

[dependencies]
asn1-rs = "0.7.1"
async-generic = "1.1"
async-trait = "0.1.78"
atree = "=0.5.2"
base64 = "0.22.1"
bcder = "0.7.3"
bytes = "1.11.1"
brotli = "7.0.0"
byteorder = { version = "1.4.3", default-features = false }
byteordered = "0.6.0"
chrono = { version = "0.4.42", default-features = false, features = ["serde"] }
c2pa_cbor = "0.77.2"
config = { version = "0.14.0", default-features = false, features = [
    "json",
    "toml",
] }
const-hex = "1.14"
const-oid = { version = "0.9.6", optional = true }
coset = "0.4.0"
der = { version = "0.7.9", features = ["alloc"] }
extfmt = "0.2.0"
getrandom = { version = "0.3.4", default-features = false, features = ["std"] }
ecdsa = { version = "0.16.9", features = ["digest", "sha2"], optional = true }
ed25519-dalek = { version = "2.1.1", features = [
    "alloc",
    "digest",
    "pem",
    "pkcs8",
    "rand_core",
] }
env_logger = "0.11.8"
hex = "0.4.3"
hex-literal = "1.0.0" # Might be only a dev dependency
http = "1.3.1"
id3 = "1.16.3"
img-parts = "0.4.0"
iref = { version = "3.2.2", features = ["serde"] }
jfifdump = "0.6.0"
log = "0.4.8"
lopdf = { version = "0.39.0", optional = true }
lazy_static = "1.4.0"
memchr = "2.7.6"
mp4 = "0.14.0"
nom = "7.1.3"
non-empty-string = { version = "0.2.6", features = ["serde"] }
nonempty-collections = { version = "1.2.1", features = ["serde"] }
num-bigint-dig = { version = "0.8.4", optional = true }
p256 = { version = "0.13.2", optional = true }
p384 = { version = "0.13.0", optional = true }
p521 = { version = "0.13.3", features = [
    "pkcs8",
    "digest",
    "ecdsa",
], optional = true }
pem = "3.0.6"
pkcs1 = { version = "0.7.5", optional = true }
pkcs8 = "0.10.2"
png_pong = "0.10.0"
quick-xml = "0.39.0"
rand = "0.8.5"
rand_chacha = { version = "0.9.0", features = ["os_rng"] }
range-set = "0.1.0"
rasn = "0.28.2"
rasn-cms = "0.28.2"
rasn-ocsp = "0.28.2"
rasn-pkix = "0.28.2"
regex = "1.11"
riff = "2.0.0"
rsa = { version = "0.9.10", features = ["pem", "sha2", "std"], optional = true }
schemars = { version = "1.0.4", optional = true }
serde = { version = "1.0.225", features = ["derive"] }
serde_bytes = "0.11.14"
serde_derive = "1.0.197"
serde_json = { version = "1.0.117", features = ["preserve_order"] }
serde_with = "3.15.1"
serde-transcode = "1.1.1"
sha1 = "0.10.6"
spki = { version = "0.7.3", optional = true }
static-iref = "3.0"
tempfile = "3.23.0"
thiserror = "2.0.17"
toml = "1.0.2"
url = "2.5.3"
uuid = { version = "1.18.0", features = ["serde", "v4"] }
web-time = "1.1"
x509-parser = "0.18.0"
zeroize = { version = "1.8", features = ["zeroize_derive"] }
zip = { version = "8.1.0", default-features = false }

# Use the asm feature of sha2 on aarch64 macOS for better performance. This nearly
# halves hashing time for large assets (> 50gb mp4, for example).
#
# Note: This feature has been removed in later versions of sha2.
# If upgrading, ensure sha2 has implemented equivalent optimizations for aarch64.
#
# See: https://github.com/RustCrypto/hashes/pull/542 and
# https://github.com/RustCrypto/hashes/tree/master/sha2#backends (which hasn't been released yet).
sha2 = "0.10.6"
# Apply the "asm" feature only for macOS on AArch64.
[target.'cfg(all(target_arch = "aarch64", target_os = "macos"))'.dependencies]
sha2 = { version = "0.10.6", features = ["asm"] }

[target.'cfg(not(target_os = "wasi"))'.dependencies]
reqwest = { version = "0.12.23", default-features = false, features = [
    # These are some of the defaults in `reqwest`.
    "http2",
    "system-proxy",
    "rustls-tls"
], optional = true }

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
openssl = { version = "0.10.72", features = ["vendored"], optional = true }
ureq = { version = "3.1.0", default-features = false, features = [
    "rustls"
], optional = true }

[target.'cfg(target_os = "wasi")'.dependencies]
wasi = { version = "0.14.3", optional = true }
wstd = { version = "0.5.4", optional = true }

# `wstd` is required for testing, but optional as a normal dependency.
[target.'cfg(target_os = "wasi")'.dev-dependencies]
wstd = "0.5.4"

# This list matches the `rust_native_crypto` feature since they are not optional on WASM.
[target.'cfg(target_arch = "wasm32")'.dependencies]
const-oid = "0.9.6"
ecdsa = { version = "0.16.9", features = ["digest", "sha2"] }
num-bigint-dig = "0.8.4"
p256 = "0.13.2"
p384 = "0.13.0"
p521 = { version = "0.13.3", features = [
    "pkcs8",
    "digest",
    "ecdsa",
] }
pkcs1 = "0.7.5"
rsa = { version = "0.9.10", features = ["sha2"] }
spki = "0.7.3"

[target.'cfg(any(target_os = "wasi", not(target_arch = "wasm32")))'.dependencies]
image = { version = "0.25.6", default-features = false, features = [
    # TODO: eventually define feature flags for the asset handlers and match them
    #       up here.
    "png",
    "jpeg",
    "gif",
    "webp",
    "tiff",
    # "bmp",
    # "ico",
    # "avif",
    # TODO: AVIF requires the dav1d crate which causes some complications compiling
    # "avif-native"
], optional = true }

[target.'cfg(any(not(target_arch = "wasm32"), target_os = "wasi"))'.dependencies.chrono]
version = "0.4.39"
default-features = false
features = ["now"]

[target.'cfg(all(target_arch = "wasm32", target_os = "emscripten"))'.dependencies.chrono]
version = "0.4.39"
default-features = false
features = ["clock", "serde"]

[target.'cfg(all(target_arch = "wasm32", not(target_os = "wasi")))'.dependencies]
getrandom = { version = "0.3.4", features = ["wasm_js"] }
# Also enable getrandom 0.2 with js feature for other dependencies (rand, tempfile, config)
# This is needed until all dependencies migrate to getrandom 0.3
getrandom_02 = { package = "getrandom", version = "0.2", features = ["js"] }
uuid = { version = "1.18.0", features = ["serde", "v4", "js"] }

[target.'cfg(all(target_arch = "wasm32", target_os = "unknown"))'.dependencies]
chrono = { version = "0.4.39", default-features = false, features = [
    "clock",
    "serde",
    "wasmbind",
] }
console_log = { version = "1.0.0", features = ["color"] }
# Enable getrandom with wasm_js feature for WASM support
js-sys = "0.3.89"
serde-wasm-bindgen = "0.6.5"
wasm-bindgen = "0.2.112"
wasm-bindgen-futures = "0.4.31"
web-sys = { version = "0.3.58", features = [
    "console",
    "Crypto",
    "SubtleCrypto",
    "CryptoKey",
    "Window",
    "WorkerGlobalScope",
] }

[dev-dependencies]
anyhow = "1.0.97"
glob = "0.3.1"
hex-literal = "1.0.0"
jumbf = "0.7.0"
c2pa_macros = { path = "../macros" }
mockall = "0.14.0"
jsonschema = { version = "0.45.0", default-features = false }

[target.'cfg(all(target_arch = "wasm32", target_os = "unknown"))'.dev-dependencies]
wasm-bindgen-test = "0.3.55"

[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
httpmock = "0.8.2"
tokio = { version = "1.44.2", features = ["full"] }
criterion = { package = "codspeed-criterion-compat", version = "4.2.1" }

# WASM/WASI doesn't support default criterion features.
# https://github.com/bheisler/criterion.rs/blob/4c19e913b84e6a7e4a8470cb0f766796886ed891/book/src/user_guide/wasi.md
[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
criterion = { package = "codspeed-criterion-compat", version = "4.2.1", default-features = false }

[[bench]]
name = "sign"
harness = false

[[bench]]
name = "read"
harness = false
