livekit-api 0.6.0

Rust Server SDK for LiveKit
Documentation
[package]
name = "livekit-api"
version = "0.6.0"
license.workspace = true
description = "Rust Server SDK for LiveKit"
edition.workspace = true
repository.workspace = true
readme = "README.md"

[features]
# By default ws TLS is not enabled
default = ["services-tokio", "access-token", "webhooks"]

# Signalling client, blind to the transport backend. Pulls livekit-net (no
# backend), the tokio crate (signal_client uses tokio::sync directly), and
# protobuf helpers. The livekit-runtime flavor comes from the signal-client-<rt>
# wrappers below or the top crate — not here, so async/dispatcher don't collide
# with tokio under the one-runtime guard. Needs a runtime flavor to compile, and
# a registered livekit_net::transport() at runtime.
signal-client = [
    "dep:livekit-net",
    "dep:livekit-runtime",
    "dep:tokio",
    "dep:base64",
    "dep:flate2",
    "dep:bytes",
    "dep:serde_json",
]

signal-client-tokio      = ["signal-client", "livekit-net/native-tokio", "livekit-runtime/tokio"]
signal-client-async      = ["signal-client", "livekit-net/native-async",      "livekit-runtime/async"]
signal-client-dispatcher = ["signal-client", "livekit-net/native-dispatcher",  "livekit-runtime/dispatcher"]

services-tokio = ["dep:reqwest", "dep:tokio", "tokio/time", "dep:livekit-runtime", "livekit-runtime/tokio"]
services-async = ["dep:isahc", "dep:livekit-runtime", "livekit-runtime/async"]
access-token = ["dep:jsonwebtoken", "dep:hmac", "dep:signature"]
webhooks = ["access-token", "dep:serde_json", "dep:base64"]

# TLS Configuration
# -----------------
# These features control TLS behavior for WebSocket and HTTP connections.
# TLS is delegated to livekit-net; no local tungstenite/rustls deps.
#
# IMPORTANT FOR CONTAINER DEPLOYMENTS:
# When using `rustls-tls-native-roots`, the SDK relies on the operating system's
# CA certificate store. In container environments using slim/minimal base images,
# this store may be empty, causing TLS errors like "invalid peer certificate: UnknownIssuer".
#
# Solutions:
#   1. Install CA certificates in your Dockerfile:
#      - Debian/Ubuntu: RUN apt-get update && apt-get install -y ca-certificates
#      - Alpine: RUN apk add --no-cache ca-certificates
#
#   2. Use `rustls-tls-webpki-roots` instead, which bundles Mozilla's root
#      certificates and doesn't require system CA certificates. This is the
#      recommended option for containerized deployments. The drawback is that
#      the embedded certificates can expire, requiring a fresh build to update them.

# Uses the platform's native TLS implementation (OpenSSL on Linux, Secure Transport on macOS, SChannel on Windows)
native-tls              = ["livekit-net?/native-tls",             "reqwest?/native-tls"]
# Same as native-tls but compiles OpenSSL from source (useful for cross-compilation)
native-tls-vendored     = ["livekit-net?/native-tls-vendored",    "reqwest?/native-tls-vendored"]
# Uses rustls with the operating system's CA certificate store.
# Requires ca-certificates to be installed in container environments.
rustls-tls-native-roots = ["livekit-net?/rustls-tls-native-roots", "reqwest?/rustls-tls-native-roots"]
# Uses rustls with Mozilla's bundled root certificates.
# RECOMMENDED for container deployments - no system CA certificates required.
rustls-tls-webpki-roots = ["livekit-net?/rustls-tls-webpki-roots", "reqwest?/rustls-tls-webpki-roots"]
__rustls-tls            = ["livekit-net?/__rustls-tls",             "reqwest?/__rustls"]

[dependencies]
livekit-net = { workspace = true, optional = true }
livekit-protocol = { workspace = true }
livekit-common = { workspace = true }
thiserror = { workspace = true }
serde = { workspace = true, features = ["derive"] }
sha2 = "0.10"
url = "2.3"
log = { workspace = true }
parking_lot = { workspace = true }
prost = "0.12"
pbjson-types = "0.6"

# webhooks
serde_json = { workspace = true, optional = true }
base64 = { version = "0.21", optional = true, features = ["std"] }

# access_token: HS256 only, via the in-crate HMAC CryptoProvider (jwt_provider.rs).
# Dropping jsonwebtoken's rust_crypto bundle avoids linking RSA/EC/EdDSA.
jsonwebtoken = { version = "10", default-features = false, optional = true }
hmac = { version = "0.12", optional = true }
signature = { version = "2", optional = true }

# signal_client
livekit-runtime = { workspace = true, optional = true, default-features = false }
tokio = { workspace = true, default-features = false, features = ["sync", "macros", "signal", "io-util", "net"], optional = true }

# This dependency must be kept in sync with reqwest's version
http = "1.1"
reqwest = { version = "0.12", default-features = false, features = [ "json" ], optional = true }
isahc = { version = "1.7.2", default-features = false, features = [ "json", "text-decoding" ], optional = true }

flate2 = { version = "1", optional = true }
bytes = { workspace = true, optional = true }
scopeguard = "1.2.0"
rand = { workspace = true }
os_info = "3.14.0"
device-info = { workspace = true }

[dev-dependencies]
tokio = { workspace = true, features = ["rt", "rt-multi-thread", "net", "time", "macros", "io-util"] }
# Minimal executor to drive the runtime-agnostic `services-async` (isahc) tests.
futures = "0.3"
async-trait = "0.1"