//! Generated by `trust-tasks-codegen` — do not edit by hand.
//!
//! Spec slug: `vault/credentials/present`. Version: `0.1`.
#[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.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "Ext",
/// "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.",
/// "type": "object",
/// "minProperties": 1,
/// "additionalProperties": true,
/// "propertyNames": {
/// "pattern": "^[a-z][a-z0-9-]*(\\.[a-z0-9-]+)+$"
/// }
///}
/// ```
/// </details>
#[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`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "type": "string",
/// "pattern": "^[a-z][a-z0-9-]*(\\.[a-z0-9-]+)+$"
///}
/// ```
/// </details>
#[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())
})
}
}
///Present one stored credential to a verifier the consumer names, bound to that verifier and a nonce it chose, disclosing only the named claims.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "$id": "https://trusttasks.org/spec/vault/credentials/present/0.1",
/// "title": "Payload",
/// "description": "Present one stored credential to a verifier the consumer names, bound to that verifier and a nonce it chose, disclosing only the named claims.",
/// "type": "object",
/// "required": [
/// "audience",
/// "claims",
/// "id",
/// "nonce"
/// ],
/// "properties": {
/// "audience": {
/// "description": "The verifier the presentation is for: the `domain` of a Data Integrity presentation, the `aud` of an SD-JWT key-binding JWT.",
/// "type": "string",
/// "maxLength": 512,
/// "minLength": 1,
/// "pattern": "^\\S+$"
/// },
/// "claims": {
/// "description": "The names of the subject claims to disclose. Nothing outside them is disclosed; a credential that cannot disclose less than all its claims is refused unless they are all named.",
/// "type": "array",
/// "items": {
/// "type": "string",
/// "maxLength": 128,
/// "minLength": 1
/// },
/// "maxItems": 64,
/// "minItems": 1,
/// "uniqueItems": true
/// },
/// "ext": {
/// "description": "Ecosystem-defined extension members per SPEC.md §4.5.1.",
/// "$ref": "#/definitions/Ext"
/// },
/// "id": {
/// "description": "Local handle from a query descriptor. Opaque; consumers must not derive or guess one.",
/// "type": "string",
/// "maxLength": 256,
/// "minLength": 1
/// },
/// "nonce": {
/// "description": "The value the verifier binds the presentation to: the `nonce` of a Data Integrity presentation or of an SD-JWT key-binding JWT.",
/// "type": "string",
/// "maxLength": 256,
/// "minLength": 1
/// },
/// "purpose": {
/// "description": "Optional: why the holder is presenting, recorded with the maintainer's record of the disclosure. Never sent to the verifier.",
/// "type": "string",
/// "maxLength": 256,
/// "minLength": 1
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct Payload {
///The verifier the presentation is for: the `domain` of a Data Integrity presentation, the `aud` of an SD-JWT key-binding JWT.
pub audience: PayloadAudience,
///The names of the subject claims to disclose. Nothing outside them is disclosed; a credential that cannot disclose less than all its claims is refused unless they are all named.
pub claims: Vec<PayloadClaimsItem>,
///Ecosystem-defined extension members per SPEC.md §4.5.1.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub ext: ::std::option::Option<Ext>,
///Local handle from a query descriptor. Opaque; consumers must not derive or guess one.
pub id: PayloadId,
///The value the verifier binds the presentation to: the `nonce` of a Data Integrity presentation or of an SD-JWT key-binding JWT.
pub nonce: PayloadNonce,
///Optional: why the holder is presenting, recorded with the maintainer's record of the disclosure. Never sent to the verifier.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub purpose: ::std::option::Option<PayloadPurpose>,
}
impl Payload {
pub fn builder() -> builder::Payload {
Default::default()
}
}
///The verifier the presentation is for: the `domain` of a Data Integrity presentation, the `aud` of an SD-JWT key-binding JWT.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "The verifier the presentation is for: the `domain` of a Data Integrity presentation, the `aud` of an SD-JWT key-binding JWT.",
/// "type": "string",
/// "maxLength": 512,
/// "minLength": 1,
/// "pattern": "^\\S+$"
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct PayloadAudience(::std::string::String);
impl ::std::ops::Deref for PayloadAudience {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<PayloadAudience> for ::std::string::String {
fn from(value: PayloadAudience) -> Self {
value.0
}
}
impl ::std::str::FromStr for PayloadAudience {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 512usize {
return Err("longer than 512 characters".into());
}
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
static PATTERN: ::std::sync::LazyLock<::regress::Regex> =
::std::sync::LazyLock::new(|| ::regress::Regex::new("^\\S+$").unwrap());
if PATTERN.find(value).is_none() {
return Err("doesn't match pattern \"^\\S+$\"".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for PayloadAudience {
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 PayloadAudience {
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 PayloadAudience {
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 PayloadAudience {
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())
})
}
}
///`PayloadClaimsItem`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "type": "string",
/// "maxLength": 128,
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct PayloadClaimsItem(::std::string::String);
impl ::std::ops::Deref for PayloadClaimsItem {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<PayloadClaimsItem> for ::std::string::String {
fn from(value: PayloadClaimsItem) -> Self {
value.0
}
}
impl ::std::str::FromStr for PayloadClaimsItem {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 128usize {
return Err("longer than 128 characters".into());
}
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for PayloadClaimsItem {
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 PayloadClaimsItem {
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 PayloadClaimsItem {
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 PayloadClaimsItem {
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())
})
}
}
///Local handle from a query descriptor. Opaque; consumers must not derive or guess one.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "Local handle from a query descriptor. Opaque; consumers must not derive or guess one.",
/// "type": "string",
/// "maxLength": 256,
/// "minLength": 1
///}
/// ```
/// </details>
#[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() > 256usize {
return Err("longer than 256 characters".into());
}
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 value the verifier binds the presentation to: the `nonce` of a Data Integrity presentation or of an SD-JWT key-binding JWT.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "The value the verifier binds the presentation to: the `nonce` of a Data Integrity presentation or of an SD-JWT key-binding JWT.",
/// "type": "string",
/// "maxLength": 256,
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct PayloadNonce(::std::string::String);
impl ::std::ops::Deref for PayloadNonce {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<PayloadNonce> for ::std::string::String {
fn from(value: PayloadNonce) -> Self {
value.0
}
}
impl ::std::str::FromStr for PayloadNonce {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 256usize {
return Err("longer than 256 characters".into());
}
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for PayloadNonce {
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 PayloadNonce {
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 PayloadNonce {
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 PayloadNonce {
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())
})
}
}
///Optional: why the holder is presenting, recorded with the maintainer's record of the disclosure. Never sent to the verifier.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "Optional: why the holder is presenting, recorded with the maintainer's record of the disclosure. Never sent to the verifier.",
/// "type": "string",
/// "maxLength": 256,
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct PayloadPurpose(::std::string::String);
impl ::std::ops::Deref for PayloadPurpose {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<PayloadPurpose> for ::std::string::String {
fn from(value: PayloadPurpose) -> Self {
value.0
}
}
impl ::std::str::FromStr for PayloadPurpose {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 256usize {
return Err("longer than 256 characters".into());
}
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for PayloadPurpose {
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 PayloadPurpose {
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 PayloadPurpose {
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 PayloadPurpose {
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())
})
}
}
///`Response`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "Response",
/// "type": "object",
/// "required": [
/// "disclosed",
/// "presentation"
/// ],
/// "properties": {
/// "disclosed": {
/// "description": "The names of the subject claims the presentation discloses.",
/// "type": "array",
/// "items": {
/// "type": "string",
/// "maxLength": 128,
/// "minLength": 1
/// },
/// "maxItems": 256,
/// "uniqueItems": true
/// },
/// "ext": {
/// "description": "Ecosystem-defined extension members per SPEC.md §4.5.1.",
/// "$ref": "#/definitions/Ext"
/// },
/// "presentation": {
/// "description": "The presentation, to be carried to the verifier unchanged.",
/// "anyOf": [
/// {
/// "description": "A W3C Verifiable Presentation carrying `nonce` and `domain` as members its holder's Data Integrity proof signs.",
/// "type": "object",
/// "minProperties": 1
/// },
/// {
/// "description": "A compact SD-JWT presentation with a key-binding JWT carrying `nonce` and `aud`.",
/// "type": "string",
/// "maxLength": 65536,
/// "minLength": 1
/// }
/// ]
/// }
/// },
/// "additionalProperties": false,
/// "$anchor": "response"
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct Response {
///The names of the subject claims the presentation discloses.
pub disclosed: Vec<ResponseDisclosedItem>,
///Ecosystem-defined extension members per SPEC.md §4.5.1.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub ext: ::std::option::Option<Ext>,
///The presentation, to be carried to the verifier unchanged.
pub presentation: ResponsePresentation,
}
impl Response {
pub fn builder() -> builder::Response {
Default::default()
}
}
///`ResponseDisclosedItem`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "type": "string",
/// "maxLength": 128,
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct ResponseDisclosedItem(::std::string::String);
impl ::std::ops::Deref for ResponseDisclosedItem {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<ResponseDisclosedItem> for ::std::string::String {
fn from(value: ResponseDisclosedItem) -> Self {
value.0
}
}
impl ::std::str::FromStr for ResponseDisclosedItem {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 128usize {
return Err("longer than 128 characters".into());
}
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for ResponseDisclosedItem {
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 ResponseDisclosedItem {
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 ResponseDisclosedItem {
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 ResponseDisclosedItem {
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 presentation, to be carried to the verifier unchanged.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "The presentation, to be carried to the verifier unchanged.",
/// "anyOf": [
/// {
/// "description": "A W3C Verifiable Presentation carrying `nonce` and `domain` as members its holder's Data Integrity proof signs.",
/// "type": "object",
/// "minProperties": 1
/// },
/// {
/// "description": "A compact SD-JWT presentation with a key-binding JWT carrying `nonce` and `aud`.",
/// "type": "string",
/// "maxLength": 65536,
/// "minLength": 1
/// }
/// ]
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(untagged)]
#[non_exhaustive]
pub enum ResponsePresentation {
Object(::serde_json::Map<::std::string::String, ::serde_json::Value>),
String(ResponsePresentationString),
}
impl ::std::convert::From<::serde_json::Map<::std::string::String, ::serde_json::Value>>
for ResponsePresentation
{
fn from(value: ::serde_json::Map<::std::string::String, ::serde_json::Value>) -> Self {
Self::Object(value)
}
}
impl ::std::convert::From<ResponsePresentationString> for ResponsePresentation {
fn from(value: ResponsePresentationString) -> Self {
Self::String(value)
}
}
///A compact SD-JWT presentation with a key-binding JWT carrying `nonce` and `aud`.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "A compact SD-JWT presentation with a key-binding JWT carrying `nonce` and `aud`.",
/// "type": "string",
/// "maxLength": 65536,
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct ResponsePresentationString(::std::string::String);
impl ::std::ops::Deref for ResponsePresentationString {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<ResponsePresentationString> for ::std::string::String {
fn from(value: ResponsePresentationString) -> Self {
value.0
}
}
impl ::std::str::FromStr for ResponsePresentationString {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 65536usize {
return Err("longer than 65536 characters".into());
}
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for ResponsePresentationString {
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 ResponsePresentationString {
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 ResponsePresentationString {
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 ResponsePresentationString {
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 {
audience: ::std::result::Result<super::PayloadAudience, ::std::string::String>,
claims: ::std::result::Result<Vec<super::PayloadClaimsItem>, ::std::string::String>,
ext: ::std::result::Result<::std::option::Option<super::Ext>, ::std::string::String>,
id: ::std::result::Result<super::PayloadId, ::std::string::String>,
nonce: ::std::result::Result<super::PayloadNonce, ::std::string::String>,
purpose: ::std::result::Result<
::std::option::Option<super::PayloadPurpose>,
::std::string::String,
>,
}
impl ::std::default::Default for Payload {
fn default() -> Self {
Self {
audience: Err("no value supplied for audience".to_string()),
claims: Err("no value supplied for claims".to_string()),
ext: Ok(Default::default()),
id: Err("no value supplied for id".to_string()),
nonce: Err("no value supplied for nonce".to_string()),
purpose: Ok(Default::default()),
}
}
}
impl Payload {
pub fn audience<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::PayloadAudience>,
T::Error: ::std::fmt::Display,
{
self.audience = value
.try_into()
.map_err(|e| format!("error converting supplied value for audience: {e}"));
self
}
pub fn claims<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<Vec<super::PayloadClaimsItem>>,
T::Error: ::std::fmt::Display,
{
self.claims = value
.try_into()
.map_err(|e| format!("error converting supplied value for claims: {e}"));
self
}
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
}
pub fn nonce<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::PayloadNonce>,
T::Error: ::std::fmt::Display,
{
self.nonce = value
.try_into()
.map_err(|e| format!("error converting supplied value for nonce: {e}"));
self
}
pub fn purpose<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::PayloadPurpose>>,
T::Error: ::std::fmt::Display,
{
self.purpose = value
.try_into()
.map_err(|e| format!("error converting supplied value for purpose: {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 {
audience: value.audience?,
claims: value.claims?,
ext: value.ext?,
id: value.id?,
nonce: value.nonce?,
purpose: value.purpose?,
})
}
}
impl ::std::convert::From<super::Payload> for Payload {
fn from(value: super::Payload) -> Self {
Self {
audience: Ok(value.audience),
claims: Ok(value.claims),
ext: Ok(value.ext),
id: Ok(value.id),
nonce: Ok(value.nonce),
purpose: Ok(value.purpose),
}
}
}
#[derive(Clone, Debug)]
pub struct Response {
disclosed: ::std::result::Result<Vec<super::ResponseDisclosedItem>, ::std::string::String>,
ext: ::std::result::Result<::std::option::Option<super::Ext>, ::std::string::String>,
presentation: ::std::result::Result<super::ResponsePresentation, ::std::string::String>,
}
impl ::std::default::Default for Response {
fn default() -> Self {
Self {
disclosed: Err("no value supplied for disclosed".to_string()),
ext: Ok(Default::default()),
presentation: Err("no value supplied for presentation".to_string()),
}
}
}
impl Response {
pub fn disclosed<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<Vec<super::ResponseDisclosedItem>>,
T::Error: ::std::fmt::Display,
{
self.disclosed = value
.try_into()
.map_err(|e| format!("error converting supplied value for disclosed: {e}"));
self
}
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 presentation<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ResponsePresentation>,
T::Error: ::std::fmt::Display,
{
self.presentation = value
.try_into()
.map_err(|e| format!("error converting supplied value for presentation: {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 {
disclosed: value.disclosed?,
ext: value.ext?,
presentation: value.presentation?,
})
}
}
impl ::std::convert::From<super::Response> for Response {
fn from(value: super::Response) -> Self {
Self {
disclosed: Ok(value.disclosed),
ext: Ok(value.ext),
presentation: Ok(value.presentation),
}
}
}
}
impl crate::Payload for Payload {
const TYPE_URI: &'static str = "https://trusttasks.org/spec/vault/credentials/present/0.1";
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(
"{\n \"$defs\": {\n \"Ext\": {\n \"additionalProperties\": true,\n \"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.\",\n \"minProperties\": 1,\n \"propertyNames\": {\n \"pattern\": \"^[a-z][a-z0-9-]*(\\\\.[a-z0-9-]+)+$\"\n },\n \"title\": \"Ext\",\n \"type\": \"object\"\n },\n \"Response\": {\n \"$anchor\": \"response\",\n \"additionalProperties\": false,\n \"properties\": {\n \"disclosed\": {\n \"description\": \"The names of the subject claims the presentation discloses.\",\n \"items\": {\n \"maxLength\": 128,\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"maxItems\": 256,\n \"type\": \"array\",\n \"uniqueItems\": true\n },\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\",\n \"description\": \"Ecosystem-defined extension members per SPEC.md §4.5.1.\"\n },\n \"presentation\": {\n \"anyOf\": [\n {\n \"description\": \"A W3C Verifiable Presentation carrying `nonce` and `domain` as members its holder's Data Integrity proof signs.\",\n \"minProperties\": 1,\n \"type\": \"object\"\n },\n {\n \"description\": \"A compact SD-JWT presentation with a key-binding JWT carrying `nonce` and `aud`.\",\n \"maxLength\": 65536,\n \"minLength\": 1,\n \"type\": \"string\"\n }\n ],\n \"description\": \"The presentation, to be carried to the verifier unchanged.\"\n }\n },\n \"required\": [\n \"presentation\",\n \"disclosed\"\n ],\n \"title\": \"Vault Credentials Present — response payload\",\n \"type\": \"object\"\n }\n },\n \"$id\": \"https://trusttasks.org/spec/vault/credentials/present/0.1\",\n \"$schema\": \"https://json-schema.org/draft/2020-12/schema\",\n \"additionalProperties\": false,\n \"description\": \"Present one stored credential to a verifier the consumer names, bound to that verifier and a nonce it chose, disclosing only the named claims.\",\n \"properties\": {\n \"audience\": {\n \"description\": \"The verifier the presentation is for: the `domain` of a Data Integrity presentation, the `aud` of an SD-JWT key-binding JWT.\",\n \"maxLength\": 512,\n \"minLength\": 1,\n \"pattern\": \"^\\\\S+$\",\n \"type\": \"string\"\n },\n \"claims\": {\n \"description\": \"The names of the subject claims to disclose. Nothing outside them is disclosed; a credential that cannot disclose less than all its claims is refused unless they are all named.\",\n \"items\": {\n \"maxLength\": 128,\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"maxItems\": 64,\n \"minItems\": 1,\n \"type\": \"array\",\n \"uniqueItems\": true\n },\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\",\n \"description\": \"Ecosystem-defined extension members per SPEC.md §4.5.1.\"\n },\n \"id\": {\n \"description\": \"Local handle from a query descriptor. Opaque; consumers must not derive or guess one.\",\n \"maxLength\": 256,\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"nonce\": {\n \"description\": \"The value the verifier binds the presentation to: the `nonce` of a Data Integrity presentation or of an SD-JWT key-binding JWT.\",\n \"maxLength\": 256,\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"purpose\": {\n \"description\": \"Optional: why the holder is presenting, recorded with the maintainer's record of the disclosure. Never sent to the verifier.\",\n \"maxLength\": 256,\n \"minLength\": 1,\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"id\",\n \"audience\",\n \"nonce\",\n \"claims\"\n ],\n \"title\": \"Vault Credentials — Present\",\n \"type\": \"object\"\n}\n",
);
}
impl crate::Payload for Response {
const TYPE_URI: &'static str =
"https://trusttasks.org/spec/vault/credentials/present/0.1#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(
"{\n \"$defs\": {\n \"Ext\": {\n \"additionalProperties\": true,\n \"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.\",\n \"minProperties\": 1,\n \"propertyNames\": {\n \"pattern\": \"^[a-z][a-z0-9-]*(\\\\.[a-z0-9-]+)+$\"\n },\n \"title\": \"Ext\",\n \"type\": \"object\"\n },\n \"Response\": {\n \"$anchor\": \"response\",\n \"additionalProperties\": false,\n \"properties\": {\n \"disclosed\": {\n \"description\": \"The names of the subject claims the presentation discloses.\",\n \"items\": {\n \"maxLength\": 128,\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"maxItems\": 256,\n \"type\": \"array\",\n \"uniqueItems\": true\n },\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\",\n \"description\": \"Ecosystem-defined extension members per SPEC.md §4.5.1.\"\n },\n \"presentation\": {\n \"anyOf\": [\n {\n \"description\": \"A W3C Verifiable Presentation carrying `nonce` and `domain` as members its holder's Data Integrity proof signs.\",\n \"minProperties\": 1,\n \"type\": \"object\"\n },\n {\n \"description\": \"A compact SD-JWT presentation with a key-binding JWT carrying `nonce` and `aud`.\",\n \"maxLength\": 65536,\n \"minLength\": 1,\n \"type\": \"string\"\n }\n ],\n \"description\": \"The presentation, to be carried to the verifier unchanged.\"\n }\n },\n \"required\": [\n \"presentation\",\n \"disclosed\"\n ],\n \"title\": \"Vault Credentials Present — response payload\",\n \"type\": \"object\"\n }\n },\n \"$ref\": \"#/$defs/Response\",\n \"$schema\": \"https://json-schema.org/draft/2020-12/schema\"\n}\n",
);
}
impl crate::RequestPayload for Payload {
type Response = Response;
}
/// 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_PRESENTABLE,
error_codes::FORMAT_UNSUPPORTED,
error_codes::CLAIM_NOT_HELD,
error_codes::WOULD_OVER_DISCLOSE,
];
/// 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 {
/// `vault/credentials/present:notFound`
///
/// The maintainer holds no credential under this identifier that this consumer may present, or holds no key for its subject that this consumer may use. Deliberately conflates the cases — see Custody scope.
///
/// Declared `retryable: false`.
pub const NOT_FOUND: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "vault/credentials/present:notFound",
retryable: false,
details_schema: ::core::option::Option::None,
};
/// `vault/credentials/present:notPresentable`
///
/// The credential is revoked, suspended, outside its validity period, archived or deleted.
///
/// Declared `retryable: false`.
pub const NOT_PRESENTABLE: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "vault/credentials/present:notPresentable",
retryable: false,
details_schema: ::core::option::Option::None,
};
/// `vault/credentials/present:formatUnsupported`
///
/// The maintainer cannot present a credential of this format to a named verifier.
///
/// Declared `retryable: false`.
pub const FORMAT_UNSUPPORTED: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "vault/credentials/present:formatUnsupported",
retryable: false,
details_schema: ::core::option::Option::None,
};
/// `vault/credentials/present:claimNotHeld`
///
/// `claims` names a claim the credential does not carry.
///
/// Declared `retryable: false`.
/// Declares a `detailsSchema` for the error's `details` member.
pub const CLAIM_NOT_HELD: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "vault/credentials/present:claimNotHeld",
retryable: false,
details_schema: ::core::option::Option::Some(
"{\"additionalProperties\":false,\"properties\":{\"claims\":{\"items\":{\"maxLength\":128,\"type\":\"string\"},\"maxItems\":64,\"type\":\"array\"}},\"required\":[\"claims\"],\"type\":\"object\"}",
),
};
/// `vault/credentials/present:wouldOverDisclose`
///
/// Every presentation of the credential discloses claims `claims` does not name — all of them, for a credential without selective disclosure. `details.undisclosed` lists those claims.
///
/// Declared `retryable: false`.
/// Declares a `detailsSchema` for the error's `details` member.
pub const WOULD_OVER_DISCLOSE: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "vault/credentials/present:wouldOverDisclose",
retryable: false,
details_schema: ::core::option::Option::Some(
"{\"additionalProperties\":false,\"properties\":{\"undisclosed\":{\"items\":{\"maxLength\":128,\"type\":\"string\"},\"maxItems\":256,\"type\":\"array\"}},\"required\":[\"undisclosed\"],\"type\":\"object\"}",
),
};
}