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#![warn(missing_docs)]
82#![warn(rust_2018_idioms)]
83#![cfg_attr(docsrs, feature(doc_cfg))]
84
85// The core crate lands at the root, flattened: `trust_tasks::TrustTask`,
86// `trust_tasks::specs::…`, `trust_tasks::consume_inbound`. A glob rather than
87// an enumerated list on purpose — an item added to `trust-tasks-rs` should
88// appear here without anyone remembering to add it, which is the failure mode
89// a hand-maintained re-export list has.
90pub use trust_tasks_rs::*;
91
92/// The core crate itself, under its own name.
93///
94/// Useful when you want to be explicit about where a type comes from, or need
95/// to name the crate in a path that a glob re-export cannot express.
96pub use trust_tasks_rs as rs;
97
98/// HTTPS transport binding — typed client, axum-based server, bearer-token
99/// identity. Re-export of [`trust_tasks_https`].
100#[cfg(feature = "https")]
101#[cfg_attr(docsrs, doc(cfg(feature = "https")))]
102pub use trust_tasks_https as https;
103
104/// DIDComm v2.1 transport binding, built on `affinidi-messaging-didcomm`.
105/// Re-export of [`trust_tasks_didcomm`].
106#[cfg(feature = "didcomm")]
107#[cfg_attr(docsrs, doc(cfg(feature = "didcomm")))]
108pub use trust_tasks_didcomm as didcomm;
109
110/// DIDComm **v1** transport binding, for Aries-lineage agents that speak v1
111/// only. Re-export of [`trust_tasks_didcomm_v1`].
112#[cfg(feature = "didcomm-v1")]
113#[cfg_attr(docsrs, doc(cfg(feature = "didcomm-v1")))]
114pub use trust_tasks_didcomm_v1 as didcomm_v1;
115
116/// ToIP Trust Spanning Protocol transport binding, built on `affinidi-tsp`.
117/// Re-export of [`trust_tasks_tsp`].
118#[cfg(feature = "tsp")]
119#[cfg_attr(docsrs, doc(cfg(feature = "tsp")))]
120pub use trust_tasks_tsp as tsp;
121
122/// Signing and proof verification. `proof::ProofExt` adds `.sign()` to a
123/// [`TrustTask`]; `proof::affinidi::Verifier` is what a server hands to
124/// `with_verifier`. Re-export of [`trust_tasks_proof`].
125#[cfg(feature = "proof-affinidi")]
126#[cfg_attr(docsrs, doc(cfg(feature = "proof-affinidi")))]
127pub use trust_tasks_proof as proof;
128
129/// Trust Ceremony verification — salted step digests, receipt checking,
130/// completion rules. Re-export of [`trust_tasks_ceremony`].
131///
132/// Note this crate does **not** depend on `trust-tasks-rs`; it is a standalone
133/// verifier over a ceremony definition.
134#[cfg(feature = "ceremony")]
135#[cfg_attr(docsrs, doc(cfg(feature = "ceremony")))]
136pub use trust_tasks_ceremony as ceremony;
137
138/// Wire helpers for the capability families — `governance/capability/*` and
139/// `git-trust/*` document builders, envelope parsing, reply classification.
140/// Re-export of [`trust_tasks_capability_client`].
141#[cfg(feature = "capability-client")]
142#[cfg_attr(docsrs, doc(cfg(feature = "capability-client")))]
143pub use trust_tasks_capability_client as capability_client;