//! Generated by `trust-tasks-codegen` — do not edit by hand.
//!
//! Spec slug: `vta/contexts/secrets`. Version: `1.0`.
/// Why this specification version is deprecated (SPEC "Superseded and
/// Withdrawn Versions"), or `None` while it is current.
pub const DEPRECATION: Option<&str> = None;
#[allow(unused_imports)]
use serde::{Deserialize, Serialize};
/// Error types.
pub mod error {
/// Error from a `TryFrom` or `FromStr` implementation.
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl ::std::fmt::Debug for ConversionError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
fn from(value: &'static str) -> Self {
Self(value.into())
}
}
impl From<String> for ConversionError {
fn from(value: String) -> Self {
Self(value.into())
}
}
}
///Vendor-namespaced extension object per SPEC.md §4.5.1. Each immediate key MUST be a reverse-DNS namespace; structure under each namespace is opaque to the framework.
///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(transparent)]
pub struct Ext(pub ::std::collections::HashMap<ExtKey, ::serde_json::Value>);
impl ::std::ops::Deref for Ext {
type Target = ::std::collections::HashMap<ExtKey, ::serde_json::Value>;
fn deref(&self) -> &::std::collections::HashMap<ExtKey, ::serde_json::Value> {
&self.0
}
}
impl ::std::convert::From<Ext> for ::std::collections::HashMap<ExtKey, ::serde_json::Value> {
fn from(value: Ext) -> Self {
value.0
}
}
impl ::std::convert::From<::std::collections::HashMap<ExtKey, ::serde_json::Value>> for Ext {
fn from(value: ::std::collections::HashMap<ExtKey, ::serde_json::Value>) -> Self {
Self(value)
}
}
///`ExtKey`
///
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct ExtKey(::std::string::String);
impl ::std::ops::Deref for ExtKey {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<ExtKey> for ::std::string::String {
fn from(value: ExtKey) -> Self {
value.0
}
}
impl ::std::str::FromStr for ExtKey {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
static PATTERN: ::std::sync::LazyLock<::regress::Regex> =
::std::sync::LazyLock::new(|| {
::regress::Regex::new("^[a-z][a-z0-9-]*(\\.[a-z0-9-]+)+$").unwrap()
});
if PATTERN.find(value).is_none() {
return Err("doesn't match pattern \"^[a-z][a-z0-9-]*(\\.[a-z0-9-]+)+$\"".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for ExtKey {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for ExtKey {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for ExtKey {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for ExtKey {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///Names the trust context whose DID key material is being asked for. The outer document members (id, type, issuer, recipient, issuedAt, expiresAt, proof) are owned by the framework — SPEC §6.3.
///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct Payload {
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub ext: ::std::option::Option<Ext>,
///Context id. For a nested context this is the full path (`parent/leaf`). Named `id` to match the rest of the `vta/contexts/*` family, where it always identifies the context being acted on.
pub id: PayloadId,
}
impl Payload {
pub fn builder() -> builder::Payload {
Default::default()
}
}
///Context id. For a nested context this is the full path (`parent/leaf`). Named `id` to match the rest of the `vta/contexts/*` family, where it always identifies the context being acted on.
///
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct PayloadId(::std::string::String);
impl ::std::ops::Deref for PayloadId {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<PayloadId> for ::std::string::String {
fn from(value: PayloadId) -> Self {
value.0
}
}
impl ::std::str::FromStr for PayloadId {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for PayloadId {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for PayloadId {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for PayloadId {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for PayloadId {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///The context's DID and the private key material behind it, sufficient to operate as that DID and nothing more. Failures use trust-task-error, not this shape. Type https://trusttasks.org/spec/vta/contexts/secrets/1.0#response.
///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct Response {
///The DID the returned secrets belong to — the DID recorded on the named context. Every `keyId` below is a verification method of this DID, so a consumer can check the two agree before installing anything.
pub did: ResponseDid,
///One entry per verification method of `did` whose secret the recipient holds and is willing to release. MAY be empty: a context whose DID has no releasable key material is not an error, and a consumer that treats an empty array as a failure will misreport a context that is merely not provisioned yet.
pub secrets: ::std::vec::Vec<SecretEntry>,
}
impl Response {
pub fn builder() -> builder::Response {
Default::default()
}
}
///The DID the returned secrets belong to — the DID recorded on the named context. Every `keyId` below is a verification method of this DID, so a consumer can check the two agree before installing anything.
///
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct ResponseDid(::std::string::String);
impl ::std::ops::Deref for ResponseDid {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<ResponseDid> for ::std::string::String {
fn from(value: ResponseDid) -> Self {
value.0
}
}
impl ::std::str::FromStr for ResponseDid {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for ResponseDid {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for ResponseDid {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for ResponseDid {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for ResponseDid {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///One private key, named by the verification method it backs.
///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct SecretEntry {
///The verification method this key backs, as an absolute DID URL under the response's `did` (`{did}#key-0`). It is the DID document — not the recipient's own storage — that decides this name, so a consumer installs the key under a `kid` that an inbound message's recipient field will actually match.
#[serde(rename = "keyId")]
pub key_id: SecretEntryKeyId,
///What the key is for, and how to reconstruct it. `ed25519` signs, `x25519` is a key-agreement key and signs nothing, `p256` is an ECDSA key for ES256. Stated as well as encoded in `privateKeyMultibase` so a consumer can select a key by purpose without decoding every entry.
#[serde(rename = "keyType")]
pub key_type: SecretEntryKeyType,
///The private key, multibase-encoded (Base58BTC, `z` prefix) over its multicodec-prefixed bytes — `0x1300` Ed25519, `0x1302` X25519, `0x1306` P-256. The multicodec prefix, not this member's position in the array, is what identifies the key material.
#[serde(rename = "privateKeyMultibase")]
pub private_key_multibase: SecretEntryPrivateKeyMultibase,
}
impl SecretEntry {
pub fn builder() -> builder::SecretEntry {
Default::default()
}
}
///The verification method this key backs, as an absolute DID URL under the response's `did` (`{did}#key-0`). It is the DID document — not the recipient's own storage — that decides this name, so a consumer installs the key under a `kid` that an inbound message's recipient field will actually match.
///
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct SecretEntryKeyId(::std::string::String);
impl ::std::ops::Deref for SecretEntryKeyId {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<SecretEntryKeyId> for ::std::string::String {
fn from(value: SecretEntryKeyId) -> Self {
value.0
}
}
impl ::std::str::FromStr for SecretEntryKeyId {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for SecretEntryKeyId {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for SecretEntryKeyId {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for SecretEntryKeyId {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for SecretEntryKeyId {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///What the key is for, and how to reconstruct it. `ed25519` signs, `x25519` is a key-agreement key and signs nothing, `p256` is an ECDSA key for ES256. Stated as well as encoded in `privateKeyMultibase` so a consumer can select a key by purpose without decoding every entry.
///
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd,
)]
#[non_exhaustive]
pub enum SecretEntryKeyType {
#[serde(rename = "ed25519")]
Ed25519,
#[serde(rename = "x25519")]
X25519,
#[serde(rename = "p256")]
P256,
}
impl ::std::fmt::Display for SecretEntryKeyType {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Ed25519 => f.write_str("ed25519"),
Self::X25519 => f.write_str("x25519"),
Self::P256 => f.write_str("p256"),
}
}
}
impl ::std::str::FromStr for SecretEntryKeyType {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"ed25519" => Ok(Self::Ed25519),
"x25519" => Ok(Self::X25519),
"p256" => Ok(Self::P256),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for SecretEntryKeyType {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for SecretEntryKeyType {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for SecretEntryKeyType {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///The private key, multibase-encoded (Base58BTC, `z` prefix) over its multicodec-prefixed bytes — `0x1300` Ed25519, `0x1302` X25519, `0x1306` P-256. The multicodec prefix, not this member's position in the array, is what identifies the key material.
///
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct SecretEntryPrivateKeyMultibase(::std::string::String);
impl ::std::ops::Deref for SecretEntryPrivateKeyMultibase {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<SecretEntryPrivateKeyMultibase> for ::std::string::String {
fn from(value: SecretEntryPrivateKeyMultibase) -> Self {
value.0
}
}
impl ::std::str::FromStr for SecretEntryPrivateKeyMultibase {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for SecretEntryPrivateKeyMultibase {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for SecretEntryPrivateKeyMultibase {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for SecretEntryPrivateKeyMultibase {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for SecretEntryPrivateKeyMultibase {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct Payload {
ext: ::std::result::Result<::std::option::Option<super::Ext>, ::std::string::String>,
id: ::std::result::Result<super::PayloadId, ::std::string::String>,
}
impl ::std::default::Default for Payload {
fn default() -> Self {
Self {
ext: Ok(Default::default()),
id: Err("no value supplied for id".to_string()),
}
}
}
impl Payload {
pub fn ext<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::Ext>>,
T::Error: ::std::fmt::Display,
{
self.ext = value
.try_into()
.map_err(|e| format!("error converting supplied value for ext: {e}"));
self
}
pub fn id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::PayloadId>,
T::Error: ::std::fmt::Display,
{
self.id = value
.try_into()
.map_err(|e| format!("error converting supplied value for id: {e}"));
self
}
}
impl ::std::convert::TryFrom<Payload> for super::Payload {
type Error = super::error::ConversionError;
fn try_from(value: Payload) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
ext: value.ext?,
id: value.id?,
})
}
}
impl ::std::convert::From<super::Payload> for Payload {
fn from(value: super::Payload) -> Self {
Self {
ext: Ok(value.ext),
id: Ok(value.id),
}
}
}
#[derive(Clone, Debug)]
pub struct Response {
did: ::std::result::Result<super::ResponseDid, ::std::string::String>,
secrets: ::std::result::Result<::std::vec::Vec<super::SecretEntry>, ::std::string::String>,
}
impl ::std::default::Default for Response {
fn default() -> Self {
Self {
did: Err("no value supplied for did".to_string()),
secrets: Err("no value supplied for secrets".to_string()),
}
}
}
impl Response {
pub fn did<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ResponseDid>,
T::Error: ::std::fmt::Display,
{
self.did = value
.try_into()
.map_err(|e| format!("error converting supplied value for did: {e}"));
self
}
pub fn secrets<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::SecretEntry>>,
T::Error: ::std::fmt::Display,
{
self.secrets = value
.try_into()
.map_err(|e| format!("error converting supplied value for secrets: {e}"));
self
}
}
impl ::std::convert::TryFrom<Response> for super::Response {
type Error = super::error::ConversionError;
fn try_from(value: Response) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
did: value.did?,
secrets: value.secrets?,
})
}
}
impl ::std::convert::From<super::Response> for Response {
fn from(value: super::Response) -> Self {
Self {
did: Ok(value.did),
secrets: Ok(value.secrets),
}
}
}
#[derive(Clone, Debug)]
pub struct SecretEntry {
key_id: ::std::result::Result<super::SecretEntryKeyId, ::std::string::String>,
key_type: ::std::result::Result<super::SecretEntryKeyType, ::std::string::String>,
private_key_multibase:
::std::result::Result<super::SecretEntryPrivateKeyMultibase, ::std::string::String>,
}
impl ::std::default::Default for SecretEntry {
fn default() -> Self {
Self {
key_id: Err("no value supplied for key_id".to_string()),
key_type: Err("no value supplied for key_type".to_string()),
private_key_multibase: Err(
"no value supplied for private_key_multibase".to_string()
),
}
}
}
impl SecretEntry {
pub fn key_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::SecretEntryKeyId>,
T::Error: ::std::fmt::Display,
{
self.key_id = value
.try_into()
.map_err(|e| format!("error converting supplied value for key_id: {e}"));
self
}
pub fn key_type<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::SecretEntryKeyType>,
T::Error: ::std::fmt::Display,
{
self.key_type = value
.try_into()
.map_err(|e| format!("error converting supplied value for key_type: {e}"));
self
}
pub fn private_key_multibase<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::SecretEntryPrivateKeyMultibase>,
T::Error: ::std::fmt::Display,
{
self.private_key_multibase = value.try_into().map_err(|e| {
format!("error converting supplied value for private_key_multibase: {e}")
});
self
}
}
impl ::std::convert::TryFrom<SecretEntry> for super::SecretEntry {
type Error = super::error::ConversionError;
fn try_from(
value: SecretEntry,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
key_id: value.key_id?,
key_type: value.key_type?,
private_key_multibase: value.private_key_multibase?,
})
}
}
impl ::std::convert::From<super::SecretEntry> for SecretEntry {
fn from(value: super::SecretEntry) -> Self {
Self {
key_id: Ok(value.key_id),
key_type: Ok(value.key_type),
private_key_multibase: Ok(value.private_key_multibase),
}
}
}
}
impl crate::Payload for Payload {
const TYPE_URI: &'static str = "https://trusttasks.org/spec/vta/contexts/secrets/1.0";
const IS_PROOF_REQUIRED: bool = true;
const IS_ISSUED_AT_REQUIRED: bool = true;
const IS_RECIPIENT_REQUIRED: bool = true;
const PAYLOAD_SCHEMA: Option<&'static str> = Some(
"{\"$defs\":{\"Ext\":{\"additionalProperties\":true,\"description\":\"Vendor-namespaced extension object per SPEC.md §4.5.1. Each immediate key MUST be a reverse-DNS namespace; structure under each namespace is opaque to the framework.\",\"minProperties\":1,\"propertyNames\":{\"pattern\":\"^[a-z][a-z0-9-]*(\\\\.[a-z0-9-]+)+$\"},\"title\":\"Ext\",\"type\":\"object\"},\"Response\":{\"$anchor\":\"response\",\"additionalProperties\":false,\"description\":\"The context's DID and the private key material behind it, sufficient to operate as that DID and nothing more. Failures use trust-task-error, not this shape. Type https://trusttasks.org/spec/vta/contexts/secrets/1.0#response.\",\"properties\":{\"did\":{\"description\":\"The DID the returned secrets belong to — the DID recorded on the named context. Every `keyId` below is a verification method of this DID, so a consumer can check the two agree before installing anything.\",\"minLength\":1,\"type\":\"string\"},\"secrets\":{\"description\":\"One entry per verification method of `did` whose secret the recipient holds and is willing to release. MAY be empty: a context whose DID has no releasable key material is not an error, and a consumer that treats an empty array as a failure will misreport a context that is merely not provisioned yet.\",\"items\":{\"$ref\":\"#/$defs/SecretEntry\"},\"type\":\"array\"}},\"required\":[\"did\",\"secrets\"],\"title\":\"VTA Context Secrets — response payload\",\"type\":\"object\"},\"SecretEntry\":{\"additionalProperties\":false,\"description\":\"One private key, named by the verification method it backs.\",\"properties\":{\"keyId\":{\"description\":\"The verification method this key backs, as an absolute DID URL under the response's `did` (`{did}#key-0`). It is the DID document — not the recipient's own storage — that decides this name, so a consumer installs the key under a `kid` that an inbound message's recipient field will actually match.\",\"minLength\":1,\"type\":\"string\"},\"keyType\":{\"description\":\"What the key is for, and how to reconstruct it. `ed25519` signs, `x25519` is a key-agreement key and signs nothing, `p256` is an ECDSA key for ES256. Stated as well as encoded in `privateKeyMultibase` so a consumer can select a key by purpose without decoding every entry.\",\"enum\":[\"ed25519\",\"x25519\",\"p256\"],\"type\":\"string\"},\"privateKeyMultibase\":{\"description\":\"The private key, multibase-encoded (Base58BTC, `z` prefix) over its multicodec-prefixed bytes — `0x1300` Ed25519, `0x1302` X25519, `0x1306` P-256. The multicodec prefix, not this member's position in the array, is what identifies the key material.\",\"minLength\":1,\"type\":\"string\"}},\"required\":[\"keyId\",\"keyType\",\"privateKeyMultibase\"],\"title\":\"Secret entry\",\"type\":\"object\"}},\"$id\":\"https://trusttasks.org/spec/vta/contexts/secrets/1.0\",\"$schema\":\"https://json-schema.org/draft/2020-12/schema\",\"additionalProperties\":false,\"description\":\"Names the trust context whose DID key material is being asked for. The outer document members (id, type, issuer, recipient, issuedAt, expiresAt, proof) are owned by the framework — SPEC §6.3.\",\"properties\":{\"ext\":{\"$ref\":\"#/$defs/Ext\"},\"id\":{\"description\":\"Context id. For a nested context this is the full path (`parent/leaf`). Named `id` to match the rest of the `vta/contexts/*` family, where it always identifies the context being acted on.\",\"minLength\":1,\"type\":\"string\"}},\"required\":[\"id\"],\"title\":\"VTA Context Secrets — payload\",\"type\":\"object\"}\n",
);
}
impl crate::Payload for Response {
const TYPE_URI: &'static str = "https://trusttasks.org/spec/vta/contexts/secrets/1.0#response";
const IS_PROOF_REQUIRED: bool = true;
const IS_ISSUED_AT_REQUIRED: bool = true;
const IS_RECIPIENT_REQUIRED: bool = true;
const PAYLOAD_SCHEMA: Option<&'static str> = Some(
"{\"$defs\":{\"Ext\":{\"additionalProperties\":true,\"description\":\"Vendor-namespaced extension object per SPEC.md §4.5.1. Each immediate key MUST be a reverse-DNS namespace; structure under each namespace is opaque to the framework.\",\"minProperties\":1,\"propertyNames\":{\"pattern\":\"^[a-z][a-z0-9-]*(\\\\.[a-z0-9-]+)+$\"},\"title\":\"Ext\",\"type\":\"object\"},\"Response\":{\"$anchor\":\"response\",\"additionalProperties\":false,\"description\":\"The context's DID and the private key material behind it, sufficient to operate as that DID and nothing more. Failures use trust-task-error, not this shape. Type https://trusttasks.org/spec/vta/contexts/secrets/1.0#response.\",\"properties\":{\"did\":{\"description\":\"The DID the returned secrets belong to — the DID recorded on the named context. Every `keyId` below is a verification method of this DID, so a consumer can check the two agree before installing anything.\",\"minLength\":1,\"type\":\"string\"},\"secrets\":{\"description\":\"One entry per verification method of `did` whose secret the recipient holds and is willing to release. MAY be empty: a context whose DID has no releasable key material is not an error, and a consumer that treats an empty array as a failure will misreport a context that is merely not provisioned yet.\",\"items\":{\"$ref\":\"#/$defs/SecretEntry\"},\"type\":\"array\"}},\"required\":[\"did\",\"secrets\"],\"title\":\"VTA Context Secrets — response payload\",\"type\":\"object\"},\"SecretEntry\":{\"additionalProperties\":false,\"description\":\"One private key, named by the verification method it backs.\",\"properties\":{\"keyId\":{\"description\":\"The verification method this key backs, as an absolute DID URL under the response's `did` (`{did}#key-0`). It is the DID document — not the recipient's own storage — that decides this name, so a consumer installs the key under a `kid` that an inbound message's recipient field will actually match.\",\"minLength\":1,\"type\":\"string\"},\"keyType\":{\"description\":\"What the key is for, and how to reconstruct it. `ed25519` signs, `x25519` is a key-agreement key and signs nothing, `p256` is an ECDSA key for ES256. Stated as well as encoded in `privateKeyMultibase` so a consumer can select a key by purpose without decoding every entry.\",\"enum\":[\"ed25519\",\"x25519\",\"p256\"],\"type\":\"string\"},\"privateKeyMultibase\":{\"description\":\"The private key, multibase-encoded (Base58BTC, `z` prefix) over its multicodec-prefixed bytes — `0x1300` Ed25519, `0x1302` X25519, `0x1306` P-256. The multicodec prefix, not this member's position in the array, is what identifies the key material.\",\"minLength\":1,\"type\":\"string\"}},\"required\":[\"keyId\",\"keyType\",\"privateKeyMultibase\"],\"title\":\"Secret entry\",\"type\":\"object\"}},\"$ref\":\"#/$defs/Response\",\"$schema\":\"https://json-schema.org/draft/2020-12/schema\"}\n",
);
}
impl crate::RequestPayload for Payload {
type Response = Response;
}
/// The earlier `MAJOR.MINOR` of this slug that this version declares it
/// extends (front matter `extends`, SPEC §5.2 "Declared extension"), or
/// `None`. Only the direct declaration; walk a chain with
/// [`crate::extension::extends_for`].
pub const EXTENDS: Option<&str> = None;
/// The extended error codes this specification declares (SPEC §7.3 item 9,
/// §8.5), in declaration order. Empty when it declares none.
pub const ERROR_CODES: &[crate::DeclaredErrorCode] =
&[error_codes::NOT_FOUND, error_codes::NOT_RELEASABLE];
/// One constant per extended error code this specification declares
/// (SPEC §7.3 item 9), named for its local part.
///
/// Emit these rather than a string literal: the code is read from the
/// specification, so it cannot name a code the specification never
/// declared.
pub mod error_codes {
/// `vta/contexts/secrets:notFound`
///
/// No context with this id exists within the caller's entitlement. A caller not entitled to the id is refused for that reason instead, and because entitlement is checked before existence, "not found" is only ever said to a caller already entitled to hear it — so the pair leaks nothing about ids the caller may not reach.
///
/// Declared `retryable: false`.
pub const NOT_FOUND: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "vta/contexts/secrets:notFound",
retryable: false,
details_schema: ::core::option::Option::None,
};
/// `vta/contexts/secrets:notReleasable`
///
/// The context is reachable and has key material, but the recipient's policy marks that material as non-releasable. A refusal about the key, not about the caller — retrying as a more privileged caller does not change it.
///
/// Declared `retryable: false`.
pub const NOT_RELEASABLE: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "vta/contexts/secrets:notReleasable",
retryable: false,
details_schema: ::core::option::Option::None,
};
}