Skip to main content

Crate trust_tasks_didcomm

Crate trust_tasks_didcomm 

Source
Expand description

DIDComm v2.1 transport binding for the Trust Tasks framework.

Wraps affinidi-messaging-didcomm so Trust Task documents can ride inside a DIDComm Message, get authcrypt’d or anoncrypt’d in a JWE, and survive any DIDComm-aware transport (mediator pickup, raw HTTPS POST, message queue, paper handoff for that matter).

§Binding URI

https://trusttasks.org/binding/didcomm/0.1

§Wire shape

Each Trust Task document is packed into a DIDComm v2.1 Message whose type is the framework-reserved URI:

https://trusttasks.org/binding/didcomm/0.1/envelope

The body of that DIDComm message is the full TrustTask<P> JSON. The outer envelope is then authcrypt’d (sender-authenticated + encrypted to the recipient) or anoncrypt’d (encrypted-only) before transmission. The authcrypt’d UnpackResult::Encrypted carries a verified sender_kid (a DID URL with a key fragment); the binding strips the fragment and uses the DID as the framework’s transport-authenticated issuer for SPEC.md §4.8.1 precedence.

§Sketch

use affinidi_messaging_didcomm::{DIDCommAgent, identity::PrivateIdentity};
use trust_tasks_didcomm::{pack_trust_task, unpack_trust_task};

// alice (producer):
let mut agent = DIDCommAgent::new();
agent.add_identity(alice.clone());
agent.add_peer(bob.to_resolved());
let wire = pack_trust_task(&doc, &agent, &alice.did, &bob.did)?;

// bob (consumer):
let mut agent = DIDCommAgent::new();
agent.add_identity(bob.clone());
agent.add_peer(alice.to_resolved());
let (doc, handler) = unpack_trust_task::<MyPayload>(&wire, &agent)?;

Structs§

DidcommHandler
A TransportHandler for one DIDComm v2.1 exchange.

Enums§

DidcommError
Failure modes the DIDComm binding can produce. Most variants map cleanly onto a SPEC.md §8.3 StandardCode when surfaced as an unpack failure on the consumer side; the Self::into_reject_reason convenience does the mapping for callers that want to fold this straight into the framework’s RejectReason.

Constants§

BINDING_URI
Stable identifier for the DIDComm binding, per SPEC.md §9.2.
ENVELOPE_TYPE
DIDComm type URI for Trust Tasks envelopes.

Functions§

pack_trust_task
Wrap a Trust Task document in a DIDComm v2.1 envelope and authcrypt it for recipient_did.
unpack_trust_task
Unwrap a DIDComm v2.1 envelope produced by pack_trust_task into a typed TrustTask<P> plus a DidcommHandler populated with the verified peer DID.