trust_tasks_https/lib.rs
1//! HTTPS transport binding for the Trust Tasks framework.
2//!
3//! Implements [SPEC.md §9](../../../SPEC.md#9-transport-bindings) over HTTP/1.1
4//! using axum on the server side and reqwest on the client side. The binding
5//! authenticates parties via an `Authorization: Bearer <token>` header that an
6//! [`Auth`] implementation maps to a Verifiable Identifier.
7//!
8//! The server and client are secure by default — attribution required, the
9//! §7.2 item 11 duplicate-execution record and the consequential freshness
10//! bound on, response binding checked by the client — and those defaults are
11//! what a production deployment runs. What is demo-grade is one
12//! implementation of [`Auth`]: [`BearerAuth`], a static token map. A
13//! deployment plugs in its own [`Auth`] (or `JwtBearerAuth`, behind the `jwt`
14//! feature) and terminates TLS in front of the server.
15//!
16//! ## Binding URI
17//!
18//! `https://trusttasks.org/binding/https/0.2`
19//!
20//! ## On the wire
21//!
22//! ```text
23//! POST /trust-tasks HTTP/1.1
24//! Host: example.com
25//! Content-Type: application/json
26//! Authorization: Bearer <token>
27//!
28//! {
29//! "id": "...",
30//! "type": "https://trusttasks.org/spec/acl/grant/0.1",
31//! "issuer": "did:web:org.example",
32//! "recipient": "did:web:maintainer.example",
33//! "issuedAt": "2026-05-17T10:00:00Z",
34//! "payload": { ... }
35//! }
36//! ```
37//!
38//! The server maps the bearer token to a VID, runs the §7.2 / §4.8.1
39//! consumer-side validation pipeline (cross-checking the in-band `issuer`
40//! against the authenticated sender), and dispatches the document to the
41//! handler registered for its `type` URI.
42//!
43//! ## Cargo features
44//!
45//! * `server` (default) — pulls in axum + tokio + tower; exposes
46//! [`HttpsServer`].
47//! * `client` (default) — pulls in reqwest; exposes [`HttpsClient`].
48//!
49//! Disable one or the other if your binary only acts as a producer or only
50//! as a consumer.
51//!
52//! # Versioning
53//!
54//! This crate exposes `trust-tasks-rs` types in its own public API, so a
55//! breaking change there breaks this crate's callers even when nothing here
56//! changes. `cargo-semver-checks` cannot catch that: it compares each crate's
57//! rustdoc against that crate's own published baseline, and does not track
58//! type identity across dependency versions. The crates that share
59//! `trust-tasks-rs` in their public API are therefore released as one
60//! compatibility unit with a single shared version — see `version_group` in
61//! `release-plz.toml`.
62
63#![warn(missing_docs)]
64#![cfg_attr(docsrs, feature(doc_cfg))]
65#![warn(rust_2018_idioms)]
66
67mod auth;
68mod error;
69mod handler;
70mod status;
71
72#[cfg(feature = "client")]
73#[cfg_attr(docsrs, doc(cfg(feature = "client")))]
74mod client;
75
76#[cfg(feature = "server")]
77#[cfg_attr(docsrs, doc(cfg(feature = "server")))]
78mod server;
79
80pub use auth::{AsyncAuth, Auth, AuthFuture, BearerAuth};
81
82#[cfg(feature = "jwt")]
83#[cfg_attr(docsrs, doc(cfg(feature = "jwt")))]
84pub use auth::JwtBearerAuth;
85pub use error::TransportError;
86pub use handler::{HttpsHandler, BINDING_URI};
87pub use status::status_for_code;
88
89#[cfg(feature = "client")]
90pub use client::{
91 ClientError, HttpsClient, HttpsClientBuilder, DEFAULT_CONNECT_TIMEOUT,
92 DEFAULT_MAX_RESPONSE_BYTES, DEFAULT_TIMEOUT,
93};
94
95#[cfg(feature = "server")]
96pub use server::{
97 HttpsServer, HttpsServerBuilder, RequestContext, DEFAULT_ALLOWED_DID_METHODS,
98 DEFAULT_MAX_CONCURRENT_REQUESTS, DEFAULT_REQUEST_TIMEOUT, MAX_BODY_BYTES,
99};