trust_tasks_capability_client library

Client-side wire helpers for the capability Trust Task families — governance/capability/* (enable / disable / list a community capability) and git-trust/* (grant / revoke commit-signing trust).

This package owns the documents, not a transport: it builds request documents, parses inbound envelope replies, and classifies them. Signing is deliberately not here — attach a Data Integrity proof with package:trust_tasks_proof (over the document minus its proof member, eddsa-jcs-2022) — so this package stays free of any crypto dependency, and a capability producer and a management UI cannot drift on the contract.

Classes

CapabilityListing
A list response: the community's capabilities.
CapabilityRejected
A trust-task-error document.
CapabilityReply
The classification of a governance/capability/* reply.
CapabilitySummary
One capability entry as rendered by a management UI.
CapabilityToggled
An enable/disable acknowledgement.
ReplyPolicy
How much a caller is willing to infer from a non-conforming peer. The default infers nothing: an outcome is decided from the error code alone.
WriteIdempotentSuccess
Rejected because the end state already holds.
WriteOutcome
The classification of a git-trust write reply.
WriteRejected
Any other rejection: the machine-readable code and human detail.
WriteSuccess
The #response document acknowledged the write.

Constants

capabilityDisableType → const String
capabilityEnableType → const String
capabilityListType → const String
governance/capability/* type URIs.
gitTrustAlreadyGrantedCode → const String
The extended error code git-trust/grant declares for "an active grant already exists" (SPEC §8.5) — the control surface for idempotent success, never decided from the non-normative free-text message.
gitTrustAlreadyGrantedCodeCamel → const String
The lowerCamelCase spellings the registry may normalise to (SPEC §4.10 rule 4). Accepting both means that normalisation is not a flag day.
gitTrustGrantType → const String
git-trust/* type URIs.
gitTrustNotGrantedCode → const String
The git-trust/revoke counterpart.
gitTrustNotGrantedCodeCamel → const String
gitTrustRevokeType → const String
trustTaskEnvelopeType → const String
The trust_tasks_didcomm binding envelope type a registry's DIDComm handler listens for.

Functions

answersRequest(CapabilityDocument reply, CapabilityDocument request) → bool
Whether reply answers request — the four equalities the HTTPS clients apply to a response (SPEC §4.9, §8.1), for a client that holds the request it sent:
buildDocument(String issuerDid, String recipientDid, String typeUri, Map<String, dynamic> payload) → CapabilityDocument
Build a capability Trust Task addressed issuerDid → recipientDid.
buildGitTrustGrant(String authorityDid, String registryDid, String subjectDid, String resource) → CapabilityDocument
Build a git-trust/grant: grant subjectDid commit-signing trust for resource (an org or org/repo slug).
buildGitTrustRevoke(String authorityDid, String registryDid, String subjectDid, String resource, {String? reason}) → CapabilityDocument
Build a git-trust/revoke. A null reason is omitted.
buildListDocument(String issuerDid, String vtcDid) → CapabilityDocument
Build a governance/capability/list request (status all).
buildToggleDocument(String issuerDid, String vtcDid, String slug, String version, {required bool enable}) → CapabilityDocument
Build a governance/capability/enable or /disable request. On enable, config.authority defaults to the community's own DID.
classifyGitTrustReply(CapabilityDocument doc, String expectedThreadId, {ReplyPolicy policy = const ReplyPolicy()}) → WriteOutcome?
Classify the reply to a git-trust/grant or git-trust/revoke write.
classifyGitTrustReplyTo(CapabilityDocument reply, CapabilityDocument request, {ReplyPolicy policy = const ReplyPolicy()}) → WriteOutcome?
Classify the reply to the git-trust/grant or git-trust/revoke document request — the form to use when you hold the request you sent.
correlationThread(CapabilityDocument doc) → String
The thread an exchange started by doc is correlated by: its own threadId, or its id where it opens the exchange (SPEC §4.9's fallback). Hold this from the moment you send a request; every reply-classifying function wants it as expectedThreadId.
isFrameworkError(CapabilityDocument doc) → bool
Whether doc is a framework error document: trust-task-error under the registry's authority. The same slug under another authority is some other publisher's specification, not a refusal.
isRegistryType(String typeUri) → bool
Whether typeUri is under the registry's authority.
isResponseVariant(String typeUri) → bool
Whether a Type URI names the success-response variant.
newAttempt(CapabilityDocument previous) → CapabilityDocument
A new attempt at the request previous carried: the same addressing, type and payload under a fresh id, a fresh issuedAt, and no proof.
parseCapabilityReply(CapabilityDocument doc, String expectedThreadId) → CapabilityReply?
Classify a governance/capability/* reply document. null when it is not part of this family, is not threaded to expectedThreadId, or does not carry the members its kind requires (a listing's capabilities list, each entry's manifest.capability and boolean enabled; a toggle's capability and boolean enabled) — a reply that cannot say what it reports is not read as reporting "disabled".
parseCapabilityReplyTo(CapabilityDocument reply, CapabilityDocument request) → CapabilityReply?
Classify the reply to the governance/capability/* document request — the form to use when you hold the request you sent. null unless reply answers request (answersRequest); otherwise as parseCapabilityReply.
parseEnvelopeDocument(Object? body) → (String, CapabilityDocument)?
Parse a DIDComm envelope body into (threadId, document), or null when the body is not a threaded Trust Task document.
parseEnvelopeDocumentFor(Object? body, String expectedThreadId) → CapabilityDocument?
Parse a DIDComm envelope body into the document it carries, only if that document is threaded to expectedThreadId. null covers both "not a Trust Task document" and "belongs to another exchange".
parseEnvelopeReply(Object? body, String expectedThreadId) → CapabilityReply?
Parse an inbound envelope body directly into a reply to the request threaded expectedThreadId — the entry point for a UI's inbound dispatch, which holds only the body value. null when the body is not a governance/capability/* reply, or belongs to a different exchange.
repliesTo(CapabilityDocument reply, String expectedThreadId) → bool
Whether reply is threaded to expectedThreadId — SPEC §4.9 correlation, and the precondition for acting on any reply. A reply with no threadId matches nothing.
slugOf(String typeUri) → String?
The slug of a Type URI, or null when it is not a Trust Task Type URI.

Typedefs

CapabilityDocument = TrustTaskDocument<Map<String, dynamic>>
A capability document: a Trust Task whose payload is an open JSON object.