trust_tasks/lib.rs
1//! One dependency line for the [Trust Tasks] framework.
2//!
3//! The framework ships as eight independently-versioned crates, because each
4//! transport binding drags in a different (and heavy) dependency tree and you
5//! should only pay for the one you use. That split is right for a build; it is
6//! a tax at the front door. This crate is the front door: it re-exports the
7//! others behind Cargo features so that getting started is one line and one
8//! version.
9//!
10//! ```toml
11//! trust-tasks = { version = "0.1", features = ["https", "proof-affinidi"] }
12//! ```
13//!
14//! Everything here is a `pub use`. There are no wrapper types, no shims, and
15//! nothing to keep in step: `trust_tasks::TrustTask` **is**
16//! [`trust_tasks_rs::TrustTask`], and `trust_tasks::https::HttpsClient` **is**
17//! `trust_tasks_https::HttpsClient`. Reaching for the underlying crate
18//! directly later is a find-and-replace, not a migration.
19//!
20//! # Which crates do I need?
21//!
22//! (Module names are written out rather than linked: a link to a module behind a
23//! Cargo feature you have not enabled is a broken link in *your* `cargo doc`.)
24//!
25//! | I want to… | feature | you get | underlying crate |
26//! |---|---|---|---|
27//! | model a Trust Task document, run the SPEC §7.2 consumer checks | *(always on)* | crate root: [`TrustTask`], [`consume_inbound`], [`specs`], [`RejectReason`] | `trust-tasks-rs` |
28//! | send/receive over HTTPS (typed client + axum server) | `https` | `trust_tasks::https` | `trust-tasks-https` |
29//! | send/receive over DIDComm v2.1 | `didcomm` | `trust_tasks::didcomm` | `trust-tasks-didcomm` |
30//! | talk to Aries-lineage agents (DIDComm v1) | `didcomm-v1` | `trust_tasks::didcomm_v1` | `trust-tasks-didcomm-v1` |
31//! | send/receive over the ToIP Trust Spanning Protocol | `tsp` | `trust_tasks::tsp` | `trust-tasks-tsp` |
32//! | **sign** a document, or **verify** an inbound proof | `proof-affinidi` | `trust_tasks::proof` | `trust-tasks-proof` |
33//! | validate payloads against their JSON Schema at runtime | `validate` | `trust_tasks::validate`, `trust_tasks::schema_index` | `trust-tasks-rs` |
34//! | verify Trust Ceremony receipts and step digests | `ceremony` | `trust_tasks::ceremony` | `trust-tasks-ceremony` |
35//! | build/parse `governance/capability/*` + `git-trust/*` wire documents | `capability-client` | `trust_tasks::capability_client` | `trust-tasks-capability-client` |
36//! | bridge two bindings in one process | `all-transports` | all four transport modules | — |
37//! | use `JwtBearerAuth` on the HTTPS server | `https-jwt` | `trust_tasks::https::JwtBearerAuth` | `trust-tasks-https` |
38//!
39//! Almost every real deployment wants **one transport plus `proof-affinidi`**:
40//! a task whose specification declares `proof` REQUIRED (`acl/grant/0.1` is
41//! one) cannot be produced or consumed without a signer and a verifier.
42//!
43//! # What this crate deliberately does not forward
44//!
45//! `trust-tasks-rs` carries **26 per-spec-family features** (`vault`, `acl`,
46//! `keys`, …) so a size-sensitive build can compile only the families it
47//! speaks. Those are **not** forwarded here. Only the `all-specs` umbrella is,
48//! and it is on by default.
49//!
50//! That is a deliberate limit on what a facade is for. Twenty-six more feature
51//! names in front of a newcomer is the problem this crate exists to remove, and
52//! forwarding them would not even work reliably: Cargo unifies features across
53//! the whole dependency graph, so trimming spec families only pays off when
54//! nothing else in the graph asks for them. **If you are trimming spec
55//! families, depend on `trust-tasks-rs` directly and skip this crate.** That is
56//! a supported answer, not a workaround — this crate is a convenience for
57//! getting started, and you have outgrown it.
58//!
59//! The same applies to *subtracting* a transport crate's own defaults. Cargo
60//! features are additive, so nothing here can turn `trust-tasks-https`'s
61//! `server` off or close `trust-tasks-didcomm-v1`'s `legacy-basic-message`
62//! gate. Those need `default-features = false` on the crate itself.
63//!
64//! # A first round trip
65//!
66//! See [`GETTING-STARTED.md`] at the repo root for a signed `acl/grant`
67//! exchange with both ends written out, the TypeScript equivalent, and the
68//! four traps that reliably cost an afternoon. The Rust in that document is
69//! extracted from `examples/acl_grant_roundtrip.rs` in this crate and a test
70//! fails if the two drift, so it is code that compiles and runs rather than
71//! code that once did.
72//!
73//! ```sh
74//! cargo run -p trust-tasks --features https,proof-affinidi \
75//! --example acl_grant_roundtrip
76//! ```
77//!
78//! [Trust Tasks]: https://trusttasks.org/
79//! [`GETTING-STARTED.md`]: https://github.com/trustoverip/dtgwg-trust-tasks-tf/blob/main/GETTING-STARTED.md
80//!
81//! # Versioning
82//!
83//! This crate exposes `trust-tasks-rs` types in its own public API, so a
84//! breaking change there breaks this crate's callers even when nothing here
85//! changes. `cargo-semver-checks` cannot catch that: it compares each crate's
86//! rustdoc against that crate's own published baseline, and does not track
87//! type identity across dependency versions. The crates that share
88//! `trust-tasks-rs` in their public API are therefore released as one
89//! compatibility unit with a single shared version — see `version_group` in
90//! `release-plz.toml`.
91
92#![warn(missing_docs)]
93#![warn(rust_2018_idioms)]
94#![cfg_attr(docsrs, feature(doc_cfg))]
95
96// The core crate lands at the root, flattened: `trust_tasks::TrustTask`,
97// `trust_tasks::specs::…`, `trust_tasks::consume_inbound`. A glob rather than
98// an enumerated list on purpose — an item added to `trust-tasks-rs` should
99// appear here without anyone remembering to add it, which is the failure mode
100// a hand-maintained re-export list has.
101pub use trust_tasks_rs::*;
102
103/// The core crate itself, under its own name.
104///
105/// Useful when you want to be explicit about where a type comes from, or need
106/// to name the crate in a path that a glob re-export cannot express.
107pub use trust_tasks_rs as rs;
108
109/// HTTPS transport binding — typed client, axum-based server, bearer-token
110/// identity. Re-export of [`trust_tasks_https`].
111#[cfg(feature = "https")]
112#[cfg_attr(docsrs, doc(cfg(feature = "https")))]
113pub use trust_tasks_https as https;
114
115/// DIDComm v2.1 transport binding, built on `affinidi-messaging-didcomm`.
116/// Re-export of [`trust_tasks_didcomm`].
117#[cfg(feature = "didcomm")]
118#[cfg_attr(docsrs, doc(cfg(feature = "didcomm")))]
119pub use trust_tasks_didcomm as didcomm;
120
121/// DIDComm **v1** transport binding, for Aries-lineage agents that speak v1
122/// only. Re-export of [`trust_tasks_didcomm_v1`].
123#[cfg(feature = "didcomm-v1")]
124#[cfg_attr(docsrs, doc(cfg(feature = "didcomm-v1")))]
125pub use trust_tasks_didcomm_v1 as didcomm_v1;
126
127/// ToIP Trust Spanning Protocol transport binding, built on `affinidi-tsp`.
128/// Re-export of [`trust_tasks_tsp`].
129#[cfg(feature = "tsp")]
130#[cfg_attr(docsrs, doc(cfg(feature = "tsp")))]
131pub use trust_tasks_tsp as tsp;
132
133/// Signing and proof verification. `proof::ProofExt` adds `.sign()` to a
134/// [`TrustTask`]; `proof::affinidi::Verifier` is what a server hands to
135/// `with_verifier`. Re-export of [`trust_tasks_proof`].
136#[cfg(feature = "proof-affinidi")]
137#[cfg_attr(docsrs, doc(cfg(feature = "proof-affinidi")))]
138pub use trust_tasks_proof as proof;
139
140/// Trust Ceremony verification — salted step digests, receipt checking,
141/// completion rules. Re-export of [`trust_tasks_ceremony`].
142///
143/// Note this crate does **not** depend on `trust-tasks-rs`; it is a standalone
144/// verifier over a ceremony definition.
145#[cfg(feature = "ceremony")]
146#[cfg_attr(docsrs, doc(cfg(feature = "ceremony")))]
147pub use trust_tasks_ceremony as ceremony;
148
149/// Wire helpers for the capability families — `governance/capability/*` and
150/// `git-trust/*` document builders, envelope parsing, reply classification.
151/// Re-export of [`trust_tasks_capability_client`].
152#[cfg(feature = "capability-client")]
153#[cfg_attr(docsrs, doc(cfg(feature = "capability-client")))]
154pub use trust_tasks_capability_client as capability_client;