//! Generated by `trust-tasks-codegen` — do not edit by hand.
//!
//! Spec slug: `persona/disclosure/present`. Version: `1.0`.
#[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())
})
}
}
///Produce the signed disclosure a preview described. Consumes a previewId, which is what makes the two calls uncollapsible.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "$id": "https://trusttasks.org/spec/persona/disclosure/present/1.0",
/// "title": "Payload",
/// "description": "Produce the signed disclosure a preview described. Consumes a previewId, which is what makes the two calls uncollapsible.",
/// "type": "object",
/// "required": [
/// "contextId",
/// "previewId"
/// ],
/// "properties": {
/// "challenge": {
/// "description": "The verifier's nonce, bound into the proof for freshness so the artifact cannot be replayed to another verifier or at another time.",
/// "type": "string",
/// "maxLength": 512
/// },
/// "contextId": {
/// "type": "string",
/// "minLength": 1
/// },
/// "ext": {
/// "$ref": "#/definitions/Ext"
/// },
/// "mint": {
/// "description": "Optionally mint a durable, revocable self-issued credential instead of an ephemeral artifact. Off by default: a presented disclosure is read once and revoking it afterwards is meaningless, so status machinery would be maintenance with no benefit. A holder who wants a counterparty to be able to re-verify — and themselves to be able to revoke — asks for it here and takes on a credential they must now maintain.",
/// "type": "object",
/// "properties": {
/// "durable": {
/// "default": false,
/// "type": "boolean"
/// },
/// "validUntil": {
/// "type": "string",
/// "format": "date-time"
/// }
/// },
/// "additionalProperties": false
/// },
/// "previewId": {
/// "description": "From a prior preview. Single-use: presenting consumes it. A producer that wants to disclose twice previews twice, which is correct — the second disclosure is a second decision.",
/// "$ref": "#/definitions/Ulid"
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct Payload {
///The verifier's nonce, bound into the proof for freshness so the artifact cannot be replayed to another verifier or at another time.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub challenge: ::std::option::Option<PayloadChallenge>,
#[serde(rename = "contextId")]
pub context_id: PayloadContextId,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub ext: ::std::option::Option<Ext>,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub mint: ::std::option::Option<PayloadMint>,
///From a prior preview. Single-use: presenting consumes it. A producer that wants to disclose twice previews twice, which is correct — the second disclosure is a second decision.
#[serde(rename = "previewId")]
pub preview_id: Ulid,
}
impl Payload {
pub fn builder() -> builder::Payload {
Default::default()
}
}
///The verifier's nonce, bound into the proof for freshness so the artifact cannot be replayed to another verifier or at another time.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "The verifier's nonce, bound into the proof for freshness so the artifact cannot be replayed to another verifier or at another time.",
/// "type": "string",
/// "maxLength": 512
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct PayloadChallenge(::std::string::String);
impl ::std::ops::Deref for PayloadChallenge {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<PayloadChallenge> for ::std::string::String {
fn from(value: PayloadChallenge) -> Self {
value.0
}
}
impl ::std::str::FromStr for PayloadChallenge {
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());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for PayloadChallenge {
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 PayloadChallenge {
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 PayloadChallenge {
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 PayloadChallenge {
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())
})
}
}
///`PayloadContextId`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "type": "string",
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct PayloadContextId(::std::string::String);
impl ::std::ops::Deref for PayloadContextId {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<PayloadContextId> for ::std::string::String {
fn from(value: PayloadContextId) -> Self {
value.0
}
}
impl ::std::str::FromStr for PayloadContextId {
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 PayloadContextId {
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 PayloadContextId {
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 PayloadContextId {
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 PayloadContextId {
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())
})
}
}
///Optionally mint a durable, revocable self-issued credential instead of an ephemeral artifact. Off by default: a presented disclosure is read once and revoking it afterwards is meaningless, so status machinery would be maintenance with no benefit. A holder who wants a counterparty to be able to re-verify — and themselves to be able to revoke — asks for it here and takes on a credential they must now maintain.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "Optionally mint a durable, revocable self-issued credential instead of an ephemeral artifact. Off by default: a presented disclosure is read once and revoking it afterwards is meaningless, so status machinery would be maintenance with no benefit. A holder who wants a counterparty to be able to re-verify — and themselves to be able to revoke — asks for it here and takes on a credential they must now maintain.",
/// "type": "object",
/// "properties": {
/// "durable": {
/// "default": false,
/// "type": "boolean"
/// },
/// "validUntil": {
/// "type": "string",
/// "format": "date-time"
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct PayloadMint {
#[serde(default)]
pub durable: bool,
#[serde(
rename = "validUntil",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub valid_until: ::std::option::Option<::chrono::DateTime<::chrono::offset::Utc>>,
}
impl ::std::default::Default for PayloadMint {
fn default() -> Self {
Self {
durable: Default::default(),
valid_until: Default::default(),
}
}
}
impl PayloadMint {
pub fn builder() -> builder::PayloadMint {
Default::default()
}
}
///Success response to persona/disclosure/present. Type https://trusttasks.org/spec/persona/disclosure/present/1.0#response.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "Response",
/// "description": "Success response to persona/disclosure/present. Type https://trusttasks.org/spec/persona/disclosure/present/1.0#response.",
/// "type": "object",
/// "required": [
/// "artifact",
/// "disclosedAt",
/// "disclosureId",
/// "subject"
/// ],
/// "properties": {
/// "artifact": {
/// "description": "The signed disclosure, in the renderer's format. Opaque to this task: the maintainer signs it, the producer relays it, and neither the schema nor the maintainer reinterprets it once formed.",
/// "type": "string"
/// },
/// "credentialId": {
/// "description": "Present only when a durable credential was minted. It is in the holder's own vault, appears in their credential list, and can be revoked — which is the obligation they took on by asking for it.",
/// "type": "string",
/// "minLength": 1
/// },
/// "disclosedAt": {
/// "type": "string",
/// "format": "date-time"
/// },
/// "disclosureId": {
/// "description": "Names the append-only record this disclosure wrote, so the holder can find it again in their history.",
/// "$ref": "#/definitions/Ulid"
/// },
/// "ext": {
/// "$ref": "#/definitions/Ext"
/// },
/// "subject": {
/// "description": "The identifier the artifact was issued under — pairwise by default, so this disclosure cannot be joined to another by subject alone.",
/// "type": "string",
/// "minLength": 1
/// }
/// },
/// "additionalProperties": false,
/// "$anchor": "response"
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct Response {
///The signed disclosure, in the renderer's format. Opaque to this task: the maintainer signs it, the producer relays it, and neither the schema nor the maintainer reinterprets it once formed.
pub artifact: ::std::string::String,
///Present only when a durable credential was minted. It is in the holder's own vault, appears in their credential list, and can be revoked — which is the obligation they took on by asking for it.
#[serde(
rename = "credentialId",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub credential_id: ::std::option::Option<ResponseCredentialId>,
#[serde(rename = "disclosedAt")]
pub disclosed_at: ::chrono::DateTime<::chrono::offset::Utc>,
///Names the append-only record this disclosure wrote, so the holder can find it again in their history.
#[serde(rename = "disclosureId")]
pub disclosure_id: Ulid,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub ext: ::std::option::Option<Ext>,
///The identifier the artifact was issued under — pairwise by default, so this disclosure cannot be joined to another by subject alone.
pub subject: ResponseSubject,
}
impl Response {
pub fn builder() -> builder::Response {
Default::default()
}
}
///Present only when a durable credential was minted. It is in the holder's own vault, appears in their credential list, and can be revoked — which is the obligation they took on by asking for it.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "Present only when a durable credential was minted. It is in the holder's own vault, appears in their credential list, and can be revoked — which is the obligation they took on by asking for it.",
/// "type": "string",
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct ResponseCredentialId(::std::string::String);
impl ::std::ops::Deref for ResponseCredentialId {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<ResponseCredentialId> for ::std::string::String {
fn from(value: ResponseCredentialId) -> Self {
value.0
}
}
impl ::std::str::FromStr for ResponseCredentialId {
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 ResponseCredentialId {
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 ResponseCredentialId {
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 ResponseCredentialId {
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 ResponseCredentialId {
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 identifier the artifact was issued under — pairwise by default, so this disclosure cannot be joined to another by subject alone.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "The identifier the artifact was issued under — pairwise by default, so this disclosure cannot be joined to another by subject alone.",
/// "type": "string",
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct ResponseSubject(::std::string::String);
impl ::std::ops::Deref for ResponseSubject {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<ResponseSubject> for ::std::string::String {
fn from(value: ResponseSubject) -> Self {
value.0
}
}
impl ::std::str::FromStr for ResponseSubject {
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 ResponseSubject {
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 ResponseSubject {
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 ResponseSubject {
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 ResponseSubject {
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())
})
}
}
///A ULID in Crockford base32, uppercase. Used for `attributeId` and `profileId`. Chosen over a UUID because the leading 48 bits are a timestamp, so a key-ordered scan of the store is also creation-ordered and a `list` needs no secondary sort. Server-assigned on create; a producer MAY supply one to make a create idempotent, and a maintainer MUST reject a supplied value that already exists rather than silently overwriting.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "Ulid",
/// "description": "A ULID in Crockford base32, uppercase. Used for `attributeId` and `profileId`. Chosen over a UUID because the leading 48 bits are a timestamp, so a key-ordered scan of the store is also creation-ordered and a `list` needs no secondary sort. Server-assigned on create; a producer MAY supply one to make a create idempotent, and a maintainer MUST reject a supplied value that already exists rather than silently overwriting.",
/// "type": "string",
/// "pattern": "^[0-9A-HJKMNP-TV-Z]{26}$"
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct Ulid(::std::string::String);
impl ::std::ops::Deref for Ulid {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<Ulid> for ::std::string::String {
fn from(value: Ulid) -> Self {
value.0
}
}
impl ::std::str::FromStr for Ulid {
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("^[0-9A-HJKMNP-TV-Z]{26}$").unwrap()
});
if PATTERN.find(value).is_none() {
return Err("doesn't match pattern \"^[0-9A-HJKMNP-TV-Z]{26}$\"".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for Ulid {
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 Ulid {
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 Ulid {
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 Ulid {
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 {
challenge: ::std::result::Result<
::std::option::Option<super::PayloadChallenge>,
::std::string::String,
>,
context_id: ::std::result::Result<super::PayloadContextId, ::std::string::String>,
ext: ::std::result::Result<::std::option::Option<super::Ext>, ::std::string::String>,
mint:
::std::result::Result<::std::option::Option<super::PayloadMint>, ::std::string::String>,
preview_id: ::std::result::Result<super::Ulid, ::std::string::String>,
}
impl ::std::default::Default for Payload {
fn default() -> Self {
Self {
challenge: Ok(Default::default()),
context_id: Err("no value supplied for context_id".to_string()),
ext: Ok(Default::default()),
mint: Ok(Default::default()),
preview_id: Err("no value supplied for preview_id".to_string()),
}
}
}
impl Payload {
pub fn challenge<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::PayloadChallenge>>,
T::Error: ::std::fmt::Display,
{
self.challenge = value
.try_into()
.map_err(|e| format!("error converting supplied value for challenge: {e}"));
self
}
pub fn context_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::PayloadContextId>,
T::Error: ::std::fmt::Display,
{
self.context_id = value
.try_into()
.map_err(|e| format!("error converting supplied value for context_id: {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 mint<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::PayloadMint>>,
T::Error: ::std::fmt::Display,
{
self.mint = value
.try_into()
.map_err(|e| format!("error converting supplied value for mint: {e}"));
self
}
pub fn preview_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::Ulid>,
T::Error: ::std::fmt::Display,
{
self.preview_id = value
.try_into()
.map_err(|e| format!("error converting supplied value for preview_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 {
challenge: value.challenge?,
context_id: value.context_id?,
ext: value.ext?,
mint: value.mint?,
preview_id: value.preview_id?,
})
}
}
impl ::std::convert::From<super::Payload> for Payload {
fn from(value: super::Payload) -> Self {
Self {
challenge: Ok(value.challenge),
context_id: Ok(value.context_id),
ext: Ok(value.ext),
mint: Ok(value.mint),
preview_id: Ok(value.preview_id),
}
}
}
#[derive(Clone, Debug)]
pub struct PayloadMint {
durable: ::std::result::Result<bool, ::std::string::String>,
valid_until: ::std::result::Result<
::std::option::Option<::chrono::DateTime<::chrono::offset::Utc>>,
::std::string::String,
>,
}
impl ::std::default::Default for PayloadMint {
fn default() -> Self {
Self {
durable: Ok(Default::default()),
valid_until: Ok(Default::default()),
}
}
}
impl PayloadMint {
pub fn durable<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<bool>,
T::Error: ::std::fmt::Display,
{
self.durable = value
.try_into()
.map_err(|e| format!("error converting supplied value for durable: {e}"));
self
}
pub fn valid_until<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::option::Option<::chrono::DateTime<::chrono::offset::Utc>>,
>,
T::Error: ::std::fmt::Display,
{
self.valid_until = value
.try_into()
.map_err(|e| format!("error converting supplied value for valid_until: {e}"));
self
}
}
impl ::std::convert::TryFrom<PayloadMint> for super::PayloadMint {
type Error = super::error::ConversionError;
fn try_from(
value: PayloadMint,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
durable: value.durable?,
valid_until: value.valid_until?,
})
}
}
impl ::std::convert::From<super::PayloadMint> for PayloadMint {
fn from(value: super::PayloadMint) -> Self {
Self {
durable: Ok(value.durable),
valid_until: Ok(value.valid_until),
}
}
}
#[derive(Clone, Debug)]
pub struct Response {
artifact: ::std::result::Result<::std::string::String, ::std::string::String>,
credential_id: ::std::result::Result<
::std::option::Option<super::ResponseCredentialId>,
::std::string::String,
>,
disclosed_at:
::std::result::Result<::chrono::DateTime<::chrono::offset::Utc>, ::std::string::String>,
disclosure_id: ::std::result::Result<super::Ulid, ::std::string::String>,
ext: ::std::result::Result<::std::option::Option<super::Ext>, ::std::string::String>,
subject: ::std::result::Result<super::ResponseSubject, ::std::string::String>,
}
impl ::std::default::Default for Response {
fn default() -> Self {
Self {
artifact: Err("no value supplied for artifact".to_string()),
credential_id: Ok(Default::default()),
disclosed_at: Err("no value supplied for disclosed_at".to_string()),
disclosure_id: Err("no value supplied for disclosure_id".to_string()),
ext: Ok(Default::default()),
subject: Err("no value supplied for subject".to_string()),
}
}
}
impl Response {
pub fn artifact<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::string::String>,
T::Error: ::std::fmt::Display,
{
self.artifact = value
.try_into()
.map_err(|e| format!("error converting supplied value for artifact: {e}"));
self
}
pub fn credential_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::ResponseCredentialId>>,
T::Error: ::std::fmt::Display,
{
self.credential_id = value
.try_into()
.map_err(|e| format!("error converting supplied value for credential_id: {e}"));
self
}
pub fn disclosed_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>,
T::Error: ::std::fmt::Display,
{
self.disclosed_at = value
.try_into()
.map_err(|e| format!("error converting supplied value for disclosed_at: {e}"));
self
}
pub fn disclosure_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::Ulid>,
T::Error: ::std::fmt::Display,
{
self.disclosure_id = value
.try_into()
.map_err(|e| format!("error converting supplied value for disclosure_id: {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 subject<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ResponseSubject>,
T::Error: ::std::fmt::Display,
{
self.subject = value
.try_into()
.map_err(|e| format!("error converting supplied value for subject: {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 {
artifact: value.artifact?,
credential_id: value.credential_id?,
disclosed_at: value.disclosed_at?,
disclosure_id: value.disclosure_id?,
ext: value.ext?,
subject: value.subject?,
})
}
}
impl ::std::convert::From<super::Response> for Response {
fn from(value: super::Response) -> Self {
Self {
artifact: Ok(value.artifact),
credential_id: Ok(value.credential_id),
disclosed_at: Ok(value.disclosed_at),
disclosure_id: Ok(value.disclosure_id),
ext: Ok(value.ext),
subject: Ok(value.subject),
}
}
}
}
impl crate::Payload for Payload {
const TYPE_URI: &'static str = "https://trusttasks.org/spec/persona/disclosure/present/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(
"{\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 \"description\": \"Success response to persona/disclosure/present. Type https://trusttasks.org/spec/persona/disclosure/present/1.0#response.\",\n \"properties\": {\n \"artifact\": {\n \"description\": \"The signed disclosure, in the renderer's format. Opaque to this task: the maintainer signs it, the producer relays it, and neither the schema nor the maintainer reinterprets it once formed.\",\n \"type\": \"string\"\n },\n \"credentialId\": {\n \"description\": \"Present only when a durable credential was minted. It is in the holder's own vault, appears in their credential list, and can be revoked — which is the obligation they took on by asking for it.\",\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"disclosedAt\": {\n \"format\": \"date-time\",\n \"type\": \"string\"\n },\n \"disclosureId\": {\n \"$ref\": \"#/$defs/Ulid\",\n \"description\": \"Names the append-only record this disclosure wrote, so the holder can find it again in their history.\"\n },\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\"\n },\n \"subject\": {\n \"description\": \"The identifier the artifact was issued under — pairwise by default, so this disclosure cannot be joined to another by subject alone.\",\n \"minLength\": 1,\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"disclosureId\",\n \"artifact\",\n \"subject\",\n \"disclosedAt\"\n ],\n \"title\": \"Persona Disclosure Present — response payload\",\n \"type\": \"object\"\n },\n \"Ulid\": {\n \"description\": \"A ULID in Crockford base32, uppercase. Used for `attributeId` and `profileId`. Chosen over a UUID because the leading 48 bits are a timestamp, so a key-ordered scan of the store is also creation-ordered and a `list` needs no secondary sort. Server-assigned on create; a producer MAY supply one to make a create idempotent, and a maintainer MUST reject a supplied value that already exists rather than silently overwriting.\",\n \"pattern\": \"^[0-9A-HJKMNP-TV-Z]{26}$\",\n \"title\": \"Ulid\",\n \"type\": \"string\"\n }\n },\n \"$id\": \"https://trusttasks.org/spec/persona/disclosure/present/1.0\",\n \"$schema\": \"https://json-schema.org/draft/2020-12/schema\",\n \"additionalProperties\": false,\n \"description\": \"Produce the signed disclosure a preview described. Consumes a previewId, which is what makes the two calls uncollapsible.\",\n \"properties\": {\n \"challenge\": {\n \"description\": \"The verifier's nonce, bound into the proof for freshness so the artifact cannot be replayed to another verifier or at another time.\",\n \"maxLength\": 512,\n \"type\": \"string\"\n },\n \"contextId\": {\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\"\n },\n \"mint\": {\n \"additionalProperties\": false,\n \"description\": \"Optionally mint a durable, revocable self-issued credential instead of an ephemeral artifact. Off by default: a presented disclosure is read once and revoking it afterwards is meaningless, so status machinery would be maintenance with no benefit. A holder who wants a counterparty to be able to re-verify — and themselves to be able to revoke — asks for it here and takes on a credential they must now maintain.\",\n \"properties\": {\n \"durable\": {\n \"default\": false,\n \"type\": \"boolean\"\n },\n \"validUntil\": {\n \"format\": \"date-time\",\n \"type\": \"string\"\n }\n },\n \"type\": \"object\"\n },\n \"previewId\": {\n \"$ref\": \"#/$defs/Ulid\",\n \"description\": \"From a prior preview. Single-use: presenting consumes it. A producer that wants to disclose twice previews twice, which is correct — the second disclosure is a second decision.\"\n }\n },\n \"required\": [\n \"contextId\",\n \"previewId\"\n ],\n \"title\": \"Persona Disclosure Present — payload\",\n \"type\": \"object\"\n}\n",
);
}
impl crate::Payload for Response {
const TYPE_URI: &'static str =
"https://trusttasks.org/spec/persona/disclosure/present/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(
"{\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 \"description\": \"Success response to persona/disclosure/present. Type https://trusttasks.org/spec/persona/disclosure/present/1.0#response.\",\n \"properties\": {\n \"artifact\": {\n \"description\": \"The signed disclosure, in the renderer's format. Opaque to this task: the maintainer signs it, the producer relays it, and neither the schema nor the maintainer reinterprets it once formed.\",\n \"type\": \"string\"\n },\n \"credentialId\": {\n \"description\": \"Present only when a durable credential was minted. It is in the holder's own vault, appears in their credential list, and can be revoked — which is the obligation they took on by asking for it.\",\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"disclosedAt\": {\n \"format\": \"date-time\",\n \"type\": \"string\"\n },\n \"disclosureId\": {\n \"$ref\": \"#/$defs/Ulid\",\n \"description\": \"Names the append-only record this disclosure wrote, so the holder can find it again in their history.\"\n },\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\"\n },\n \"subject\": {\n \"description\": \"The identifier the artifact was issued under — pairwise by default, so this disclosure cannot be joined to another by subject alone.\",\n \"minLength\": 1,\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"disclosureId\",\n \"artifact\",\n \"subject\",\n \"disclosedAt\"\n ],\n \"title\": \"Persona Disclosure Present — response payload\",\n \"type\": \"object\"\n },\n \"Ulid\": {\n \"description\": \"A ULID in Crockford base32, uppercase. Used for `attributeId` and `profileId`. Chosen over a UUID because the leading 48 bits are a timestamp, so a key-ordered scan of the store is also creation-ordered and a `list` needs no secondary sort. Server-assigned on create; a producer MAY supply one to make a create idempotent, and a maintainer MUST reject a supplied value that already exists rather than silently overwriting.\",\n \"pattern\": \"^[0-9A-HJKMNP-TV-Z]{26}$\",\n \"title\": \"Ulid\",\n \"type\": \"string\"\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::PREVIEW_NOT_FOUND,
error_codes::STALE_CLAIM,
error_codes::STEP_UP_REQUIRED,
];
/// 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 {
/// `persona/disclosure/present:previewNotFound`
///
/// The previewId is unknown, already consumed, or expired. A producer previews again rather than retrying; the second preview is a second decision, which is the intent.
///
/// Declared `retryable: false`.
pub const PREVIEW_NOT_FOUND: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "persona/disclosure/present:previewNotFound",
retryable: false,
};
/// `persona/disclosure/present:staleClaim`
///
/// A claim in the preview could not be re-derived at signing time. The disclosure is refused whole rather than issued short, because a verifier receiving fewer claims than were approved cannot tell that from a holder who approved fewer.
///
/// Declared `retryable: false`.
pub const STALE_CLAIM: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "persona/disclosure/present:staleClaim",
retryable: false,
};
/// `persona/disclosure/present:stepUpRequired`
///
/// A claim in the preview requires a fresh step-up approval (`release` is `stepUp`) and the maintainer holds none bound to this previewId. Retryable once such an approval is obtained — the preview is not consumed, since refusing for want of an approval must not cost the holder the decision they already made.
///
/// Declared `retryable: true`.
pub const STEP_UP_REQUIRED: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "persona/disclosure/present:stepUpRequired",
retryable: true,
};
}