Expand description
Async consumer client for the Transparency Exchange API 1.0.0.
Independent implementation. Not an official CycloneDX project release.
Not a conformance certificate. Checksum
libtea_core::IntegrityOutcome::Verified means declared digests matched
decoded artifact bytes only — it is not publisher authenticity and
not cryptographic signature verification. See signature.
Transport uses rustls. Certificate verification stays enabled. Discovery
and artifact URLs are checked against libtea_core::DestinationPolicy before each
connection, including addresses returned by DNS.
Proxies: HTTP_PROXY / HTTPS_PROXY / ALL_PROXY (and lowercase forms)
are honored by default. Through a proxy the DNS-based destination checks
are not enforced, because the proxy, not this client, resolves the
hostname; scheme, userinfo, literal-IP, and redirect checks still apply.
ClientBuilder::ignore_env_proxies connects directly and keeps the DNS
checks.
Weak checksums: a match on SHA-1 checksums only is
libtea_core::IntegrityOutcome::Weak and the download fails with
ClientError::Integrity, unless ClientBuilder::allow_weak_checksums
is set.
Token refresh is single-flight per origin on a Client: one async lock
per API origin serializes POST /token for that origin; other origins do
not wait for it. For a same-origin burst of resource 401s with no usable
cached bearer, waiters coalesce to one POST /token: they reuse the
stored bearer after a success, and waiters that queued during a failed
exchange return its failure. A waiter that finds a just-stored token
already expired (very short lifetime) exchanges again. POST /token is
bounded by Limits::request_timeout. This is a per-burst bound, not a
process-wide exactly-once guarantee (see docs/auth.md).
The crate README follows; its Rust snippets are compiled as doctests.
§libtea-client
Independent async Rust client for the CycloneDX Transparency Exchange API.
Independent implementation. Not an official CycloneDX project. No conformance
certification. No cryptographic signature verification. Checksum
IntegrityOutcome::Verified is not publisher authenticity.
Implemented against Transparency Exchange API commit
962a0228af1bfcc1232ac3f79239317ff33fdb04. The TEA specification is still beta.
This crate depends on libtea-core 0.1.4. It does not depend on the CLI or the conformance crate.
[dependencies]
libtea-client = "0.1.4"
libtea-core = "0.1.4"
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }The snippet below also uses libtea-core (types such as ListParams) and tokio (#[tokio::main]); libtea-client does not re-export either.
Edition 2021. MSRV 1.89. License Apache-2.0. TLS uses rustls. Certificate verification stays enabled. The default destination policy allows HTTPS to public addresses.
MSRV. The minimum supported Rust version is 1.89 for 0.1.4. Policy: the latest stable release minus about four releases; it is raised only in minor releases, and every raise is listed in the CHANGELOG.md. Dependencies use plain caret ranges and Cargo.lock is committed, so MSRV is verified with the committed lock file (cargo +1.89.0 test --workspace --all-targets --locked).
This snippet is compiled as a doctest but marked no_run, because it would contact a network host. Other examples that build are examples/filter_by_identifier_type.rs and examples/paginate_components.rs.
use libtea_client::Client;
use libtea_core::enums::IdentifierType;
use libtea_core::ListParams;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::builder().build()?;
let service = client.service("https://api.example.com", "1.0.0")?;
let query = ListParams::default().with_id_type(IdentifierType::ComplianceDocument);
let page = service.query_components(&query).await?;
println!("{} components", page.results.len());
Ok(())
}ListParams::default() leaves every field unset and does not require the sort type to implement Default. ListParams, Limits, and PageFollowLimits are #[non_exhaustive]: build them from default() with the with_* setters. Pagination is caller-managed: copy next_page_token into page_token and keep the other fields. A local HTTP origin needs DestinationPolicy::allow_origin for that origin only.
Environment proxies (HTTP_PROXY, HTTPS_PROXY, ALL_PROXY) are honored by default. Through a proxy the DNS-based destination checks are not enforced, because the proxy resolves the hostname; ClientBuilder::ignore_env_proxies(true) connects directly and keeps them.
A match on SHA-1 checksums only is IntegrityOutcome::Weak, not Verified, and the download fails unless ClientBuilder::allow_weak_checksums(true) is set.
libtea_client::url re-exports the url crate used in ClientBuilder::well_known_fetch_url; a major-version bump of url is a breaking change of this crate (see the semver note in libtea-core).
By default the client requires an advertised API version equal to a supported one (1.0.0). ClientBuilder::lenient_versions(true) also accepts 1 / 1.0 and any stable version with the same major (pre-releases only on an exact match), for servers that advertise those forms; exact matches are always tried before same-major ones. Risk: the models were checked against the 1.0.0 schemas only, so a server that matches on version may still send responses this client misreads. Leave it off unless you need it.
Checksum IntegrityOutcome::Verified covers decoded artifact bytes only. It does not establish publisher authenticity. Detached signature and Sigstore verification are not implemented in 0.1.0; signature downloads are not cryptographically interpreted.
The workspace guide is at https://github.com/Mehrn0ush/libtea-rs.
Re-exports§
pub use page_stream::follow_pages;pub use page_stream::FollowedPage;pub use page_stream::PageFollowLimits;pub use page_stream::PageFollowStop;pub use signature::SignatureVerifier;pub use signature::SignatureVerifyOutcome;pub use url;
Modules§
- page_
stream - Opt-in pagination helpers.
- signature
- Extension point for cryptographic signature verification.
Structs§
- ApiKey
- API key identifier and secret. The secret is redacted in
Debug. - Cache
Config - Cache settings. Defaults are conservative; every limit is a ceiling.
- Cache
Stats - What
libtea cache statreports. - Client
- TEA consumer client.
- Client
Builder - Builder for
Client. - Downloaded
Artifact - Bytes of an artifact or signature after HTTP content coding is removed.
- File
Download - A streamed download that was committed to a file.
- File
Download Options - Options for the file-writing download methods.
- Limits
- Bounds for untrusted TEA responses.
- Resolved
Release - A product release selected from
/discovery, with the server and version to call next. - Service
- A versioned TEA API base.
- Streamed
Download - What a streamed download reports. The bytes went to the sink.
Enums§
- Artifact
Fetch - Artifact download result.
- CleFetch
- CLE projection result.
NotImplementedis not a missing parent object. - Client
Error - Failure of a consumer HTTP operation.
- Signature
Fetch - Detached signature fetch.
Functions§
- cache_
clear - Remove every cache entry (and stray temporary files) and return how many
files were removed. Only files this cache writes are touched: names that are
a cache key plus
.entry, and*.tmp. Other files, and the directories themselves, are left alone. A symbolic link with an entry’s name is removed as a link; its target is never followed. - cache_
stat - Summarise a cache directory without changing it.