trust_tasks_didcomm/lib.rs
1//! DIDComm v2.1 transport binding for the Trust Tasks framework.
2//!
3//! Wraps `affinidi-messaging-didcomm` so Trust Task documents can ride
4//! inside a DIDComm `Message`, get authcrypt'd or anoncrypt'd in a JWE,
5//! and survive any DIDComm-aware transport (mediator pickup, raw HTTPS
6//! POST, message queue, paper handoff for that matter).
7//!
8//! ## Binding URI
9//!
10//! `https://trusttasks.org/binding/didcomm/0.1`
11//!
12//! ## Wire shape
13//!
14//! Each Trust Task document is packed into a DIDComm v2.1 `Message`
15//! whose `type` is the framework-reserved URI:
16//!
17//! ```text
18//! https://trusttasks.org/binding/didcomm/0.1/envelope
19//! ```
20//!
21//! The `body` of that DIDComm message is the full `TrustTask<P>` JSON.
22//! The outer envelope is then authcrypt'd (sender-authenticated +
23//! encrypted to the recipient) or anoncrypt'd (encrypted-only) before
24//! transmission. The authcrypt'd `UnpackResult::Encrypted` carries a
25//! verified `sender_kid` (a DID URL with a key fragment); the binding
26//! strips the fragment and uses the DID as the framework's
27//! transport-authenticated `issuer` for SPEC.md §4.8.1 precedence.
28//!
29//! ## Sketch
30//!
31//! ```rust,ignore
32//! use affinidi_messaging_didcomm::{DIDCommAgent, identity::PrivateIdentity};
33//! use trust_tasks_didcomm::{pack_trust_task, unpack_trust_task};
34//!
35//! // alice (producer):
36//! let mut agent = DIDCommAgent::new();
37//! agent.add_identity(alice.clone());
38//! agent.add_peer(bob.to_resolved());
39//! let wire = pack_trust_task(&doc, &agent, &alice.did, &bob.did)?;
40//!
41//! // bob (consumer):
42//! let mut agent = DIDCommAgent::new();
43//! agent.add_identity(bob.clone());
44//! agent.add_peer(alice.to_resolved());
45//! let (doc, handler) = unpack_trust_task::<MyPayload>(&wire, &agent)?;
46//! ```
47
48#![warn(missing_docs)]
49#![warn(rust_2018_idioms)]
50
51mod error;
52mod handler;
53mod pack;
54
55pub use error::DidcommError;
56pub use handler::{DidcommHandler, BINDING_URI};
57pub use pack::{pack_trust_task, unpack_trust_task, ENVELOPE_TYPE};