Skip to main content

vta_sdk/protocols/
mod.rs

1pub mod acl_management;
2pub mod attestation_management;
3pub mod audit_management;
4pub mod auth;
5pub mod backup_management;
6/// Issued-credential lifecycle (`spec/vta/credentials/{issue,revoke}/0.1`) —
7/// mint + revoke a VTA-signed W3C VC addressed to a holder DID.
8pub mod consent_management;
9pub mod context_management;
10pub mod credential_exchange;
11pub mod credentials_issuance;
12pub mod device_management;
13pub mod did_management;
14pub mod did_template_management;
15pub mod discovery;
16#[cfg(feature = "didcomm")]
17pub mod join_requests;
18pub mod key_management;
19/// Member-side membership-credential exchange (`members/*`) — the member → VTC
20/// reciprocal VMC and the VTC's request for it.
21pub mod members;
22/// Per-context key/value store for AI-agent memory
23/// (`spec/vta/memory/{put,list,delete}/0.1`).
24pub mod memory;
25/// Passkey-based login flow (`vta/auth/passkey-login-{start,finish}/1.0`).
26pub mod passkey_login;
27/// Runtime Policy Decision Point management (`policy/*`) — where the
28/// declarative approvals model is read and written.
29pub mod policy_management;
30pub mod protocol_management;
31#[cfg(feature = "provision-integration")]
32pub mod provision_integration_management;
33pub mod seed_management;
34pub mod vault_management;
35pub mod vta_management;
36
37// Standard DIDComm protocol types used across VTA/VTC services
38pub const PROBLEM_REPORT_TYPE: &str = "https://didcomm.org/report-problem/2.0/problem-report";
39pub const TRUST_PING_TYPE: &str = "https://didcomm.org/trust-ping/2.0/ping";
40pub const MESSAGE_PICKUP_STATUS_TYPE: &str = "https://didcomm.org/messagepickup/3.0/status";
41
42/// Problem-report `code` values emitted by VTA/VTC services. Kept in sync with
43/// the `affinidi_messaging_didcomm_service::problem_report::codes` taxonomy so
44/// the SDK can classify errors without depending on the server-side crate.
45pub mod problem_report_codes {
46    pub const UNAUTHORIZED: &str = "e.p.msg.unauthorized";
47    pub const BAD_REQUEST: &str = "e.p.msg.bad-request";
48    pub const NOT_FOUND: &str = "e.p.msg.not-found";
49    pub const CONFLICT: &str = "e.p.msg.conflict";
50    pub const INTERNAL: &str = "e.p.msg.internal-error";
51    /// Workspace-specific extension to the affinidi taxonomy.
52    /// Distinguishes "permission denied" (caller authenticated but
53    /// lacks the role / context / sender-identity) from
54    /// `unauthorized` (auth failed). Without this, the SDK
55    /// collapses both into `VtaError::Auth` and the CLI prints
56    /// "Token may be expired" — which is misleading when the real
57    /// problem is a privilege-laundering rejection or an ACL miss.
58    pub const FORBIDDEN: &str = "e.p.msg.forbidden";
59    /// Per the canonical `provision/integration/0.1` spec: emitted
60    /// when the caller omits `payload.context` AND the maintainer
61    /// cannot infer a unique target context from the relayer's grant
62    /// or its own contexts state. The problem-report body's `args`
63    /// carries `candidates: Vec<String>` so the relayer can surface
64    /// the list to the operator and retry with an explicit choice.
65    pub const PROVISION_CONTEXT_REQUIRED: &str = "provision/integration:context_required";
66}
67
68/// Extract code and comment from a problem-report message body.
69pub fn extract_problem_report(body: &serde_json::Value) -> (String, String) {
70    let code = body
71        .get("code")
72        .and_then(|v| v.as_str())
73        .unwrap_or("unknown")
74        .to_string();
75    let comment = body
76        .get("comment")
77        .and_then(|v| v.as_str())
78        .unwrap_or("no details provided")
79        .to_string();
80    (code, comment)
81}