//! Generated by `trust-tasks-codegen` — do not edit by hand.
//!
//! Spec slug: `auth/step-up/approver/attest`. 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())
})
}
}
///A step-up approver's signed statement: for one subject, at one relying party, over one challenge the relying party issued, for one purpose, bound to one value. Issued and proved by the approver's did:key and carried embedded, as an open object, in the document it backs; never sent on its own. The outer document members (id, type, issuer, recipient, issuedAt, expiresAt, proof) are owned by the framework — SPEC §6.3.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "$id": "https://trusttasks.org/spec/auth/step-up/approver/attest/0.1",
/// "title": "Payload",
/// "description": "A step-up approver's signed statement: for one subject, at one relying party, over one challenge the relying party issued, for one purpose, bound to one value. Issued and proved by the approver's did:key and carried embedded, as an open object, in the document it backs; never sent on its own. The outer document members (id, type, issuer, recipient, issuedAt, expiresAt, proof) are owned by the framework — SPEC §6.3.",
/// "type": "object",
/// "required": [
/// "audience",
/// "boundTo",
/// "challenge",
/// "purpose",
/// "subject"
/// ],
/// "properties": {
/// "audience": {
/// "description": "The relying party's DID. MUST equal the document's recipient and the verifier's own DID.",
/// "type": "string",
/// "maxLength": 2048,
/// "minLength": 5,
/// "pattern": "^did:"
/// },
/// "boundTo": {
/// "description": "The opaque value the statement is bound to, compared by equality with the relying party's pending record. For `stepUp`, the approve-request's `boundTo` (a salted DigestMultibase of the operation). For `decision`, the decision's `payloadDigest`. For `enrol`, the enrolment id — an enrollmentId, a claimId, or the terms digest auth/step-up/approver/enroll/0.1 defines.",
/// "type": "string",
/// "maxLength": 256,
/// "minLength": 1
/// },
/// "challenge": {
/// "description": "The relying party's challenge for this ceremony, copied verbatim: the approve-request's challenge for `stepUp`, the decision's `challenge` for `decision`, the enrolment start's challenge for `enrol`.",
/// "type": "string",
/// "maxLength": 512,
/// "minLength": 16
/// },
/// "ext": {
/// "$ref": "#/definitions/Ext"
/// },
/// "purpose": {
/// "description": "What the statement attests. `stepUp`: a re-authentication bound to one operation (carried in auth/step-up/approve-response/0.6). `decision`: the factor backing a consent decision (carried in task-consent/decision/0.2 `evidence`). `enrol`: proof of possession of the approver key at enrolment. Signed, so a statement made for one use is refused at another.",
/// "type": "string",
/// "enum": [
/// "stepUp",
/// "decision",
/// "enrol"
/// ]
/// },
/// "subject": {
/// "description": "The one subject DID the approver acts for. MUST equal the subject bound to the relying party's pending record, and MUST differ from the document's issuer.",
/// "type": "string",
/// "maxLength": 2048,
/// "minLength": 5,
/// "pattern": "^did:"
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct Payload {
///The relying party's DID. MUST equal the document's recipient and the verifier's own DID.
pub audience: PayloadAudience,
///The opaque value the statement is bound to, compared by equality with the relying party's pending record. For `stepUp`, the approve-request's `boundTo` (a salted DigestMultibase of the operation). For `decision`, the decision's `payloadDigest`. For `enrol`, the enrolment id — an enrollmentId, a claimId, or the terms digest auth/step-up/approver/enroll/0.1 defines.
#[serde(rename = "boundTo")]
pub bound_to: PayloadBoundTo,
///The relying party's challenge for this ceremony, copied verbatim: the approve-request's challenge for `stepUp`, the decision's `challenge` for `decision`, the enrolment start's challenge for `enrol`.
pub challenge: PayloadChallenge,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub ext: ::std::option::Option<Ext>,
///What the statement attests. `stepUp`: a re-authentication bound to one operation (carried in auth/step-up/approve-response/0.6). `decision`: the factor backing a consent decision (carried in task-consent/decision/0.2 `evidence`). `enrol`: proof of possession of the approver key at enrolment. Signed, so a statement made for one use is refused at another.
pub purpose: PayloadPurpose,
///The one subject DID the approver acts for. MUST equal the subject bound to the relying party's pending record, and MUST differ from the document's issuer.
pub subject: PayloadSubject,
}
impl Payload {
pub fn builder() -> builder::Payload {
Default::default()
}
}
///The relying party's DID. MUST equal the document's recipient and the verifier's own DID.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "The relying party's DID. MUST equal the document's recipient and the verifier's own DID.",
/// "type": "string",
/// "maxLength": 2048,
/// "minLength": 5,
/// "pattern": "^did:"
///}
/// ```
/// </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() > 2048usize {
return Err("longer than 2048 characters".into());
}
if value.chars().count() < 5usize {
return Err("shorter than 5 characters".into());
}
static PATTERN: ::std::sync::LazyLock<::regress::Regex> =
::std::sync::LazyLock::new(|| ::regress::Regex::new("^did:").unwrap());
if PATTERN.find(value).is_none() {
return Err("doesn't match pattern \"^did:\"".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())
})
}
}
///The opaque value the statement is bound to, compared by equality with the relying party's pending record. For `stepUp`, the approve-request's `boundTo` (a salted DigestMultibase of the operation). For `decision`, the decision's `payloadDigest`. For `enrol`, the enrolment id — an enrollmentId, a claimId, or the terms digest auth/step-up/approver/enroll/0.1 defines.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "The opaque value the statement is bound to, compared by equality with the relying party's pending record. For `stepUp`, the approve-request's `boundTo` (a salted DigestMultibase of the operation). For `decision`, the decision's `payloadDigest`. For `enrol`, the enrolment id — an enrollmentId, a claimId, or the terms digest auth/step-up/approver/enroll/0.1 defines.",
/// "type": "string",
/// "maxLength": 256,
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct PayloadBoundTo(::std::string::String);
impl ::std::ops::Deref for PayloadBoundTo {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<PayloadBoundTo> for ::std::string::String {
fn from(value: PayloadBoundTo) -> Self {
value.0
}
}
impl ::std::str::FromStr for PayloadBoundTo {
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 PayloadBoundTo {
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 PayloadBoundTo {
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 PayloadBoundTo {
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 PayloadBoundTo {
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 relying party's challenge for this ceremony, copied verbatim: the approve-request's challenge for `stepUp`, the decision's `challenge` for `decision`, the enrolment start's challenge for `enrol`.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "The relying party's challenge for this ceremony, copied verbatim: the approve-request's challenge for `stepUp`, the decision's `challenge` for `decision`, the enrolment start's challenge for `enrol`.",
/// "type": "string",
/// "maxLength": 512,
/// "minLength": 16
///}
/// ```
/// </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());
}
if value.chars().count() < 16usize {
return Err("shorter than 16 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())
})
}
}
///What the statement attests. `stepUp`: a re-authentication bound to one operation (carried in auth/step-up/approve-response/0.6). `decision`: the factor backing a consent decision (carried in task-consent/decision/0.2 `evidence`). `enrol`: proof of possession of the approver key at enrolment. Signed, so a statement made for one use is refused at another.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "What the statement attests. `stepUp`: a re-authentication bound to one operation (carried in auth/step-up/approve-response/0.6). `decision`: the factor backing a consent decision (carried in task-consent/decision/0.2 `evidence`). `enrol`: proof of possession of the approver key at enrolment. Signed, so a statement made for one use is refused at another.",
/// "type": "string",
/// "enum": [
/// "stepUp",
/// "decision",
/// "enrol"
/// ]
///}
/// ```
/// </details>
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd,
)]
#[non_exhaustive]
pub enum PayloadPurpose {
#[serde(rename = "stepUp")]
StepUp,
#[serde(rename = "decision")]
Decision,
#[serde(rename = "enrol")]
Enrol,
}
impl ::std::fmt::Display for PayloadPurpose {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::StepUp => f.write_str("stepUp"),
Self::Decision => f.write_str("decision"),
Self::Enrol => f.write_str("enrol"),
}
}
}
impl ::std::str::FromStr for PayloadPurpose {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"stepUp" => Ok(Self::StepUp),
"decision" => Ok(Self::Decision),
"enrol" => Ok(Self::Enrol),
_ => Err("invalid value".into()),
}
}
}
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()
}
}
///The one subject DID the approver acts for. MUST equal the subject bound to the relying party's pending record, and MUST differ from the document's issuer.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "The one subject DID the approver acts for. MUST equal the subject bound to the relying party's pending record, and MUST differ from the document's issuer.",
/// "type": "string",
/// "maxLength": 2048,
/// "minLength": 5,
/// "pattern": "^did:"
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct PayloadSubject(::std::string::String);
impl ::std::ops::Deref for PayloadSubject {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<PayloadSubject> for ::std::string::String {
fn from(value: PayloadSubject) -> Self {
value.0
}
}
impl ::std::str::FromStr for PayloadSubject {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 2048usize {
return Err("longer than 2048 characters".into());
}
if value.chars().count() < 5usize {
return Err("shorter than 5 characters".into());
}
static PATTERN: ::std::sync::LazyLock<::regress::Regex> =
::std::sync::LazyLock::new(|| ::regress::Regex::new("^did:").unwrap());
if PATTERN.find(value).is_none() {
return Err("doesn't match pattern \"^did:\"".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for PayloadSubject {
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 PayloadSubject {
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 PayloadSubject {
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 PayloadSubject {
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>,
bound_to: ::std::result::Result<super::PayloadBoundTo, ::std::string::String>,
challenge: ::std::result::Result<super::PayloadChallenge, ::std::string::String>,
ext: ::std::result::Result<::std::option::Option<super::Ext>, ::std::string::String>,
purpose: ::std::result::Result<super::PayloadPurpose, ::std::string::String>,
subject: ::std::result::Result<super::PayloadSubject, ::std::string::String>,
}
impl ::std::default::Default for Payload {
fn default() -> Self {
Self {
audience: Err("no value supplied for audience".to_string()),
bound_to: Err("no value supplied for bound_to".to_string()),
challenge: Err("no value supplied for challenge".to_string()),
ext: Ok(Default::default()),
purpose: Err("no value supplied for purpose".to_string()),
subject: Err("no value supplied for subject".to_string()),
}
}
}
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 bound_to<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::PayloadBoundTo>,
T::Error: ::std::fmt::Display,
{
self.bound_to = value
.try_into()
.map_err(|e| format!("error converting supplied value for bound_to: {e}"));
self
}
pub fn challenge<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<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 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 purpose<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::PayloadPurpose>,
T::Error: ::std::fmt::Display,
{
self.purpose = value
.try_into()
.map_err(|e| format!("error converting supplied value for purpose: {e}"));
self
}
pub fn subject<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::PayloadSubject>,
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<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?,
bound_to: value.bound_to?,
challenge: value.challenge?,
ext: value.ext?,
purpose: value.purpose?,
subject: value.subject?,
})
}
}
impl ::std::convert::From<super::Payload> for Payload {
fn from(value: super::Payload) -> Self {
Self {
audience: Ok(value.audience),
bound_to: Ok(value.bound_to),
challenge: Ok(value.challenge),
ext: Ok(value.ext),
purpose: Ok(value.purpose),
subject: Ok(value.subject),
}
}
}
}
impl crate::Payload for Payload {
const TYPE_URI: &'static str = "https://trusttasks.org/spec/auth/step-up/approver/attest/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 },\n \"$id\": \"https://trusttasks.org/spec/auth/step-up/approver/attest/0.1\",\n \"$schema\": \"https://json-schema.org/draft/2020-12/schema\",\n \"additionalProperties\": false,\n \"description\": \"A step-up approver's signed statement: for one subject, at one relying party, over one challenge the relying party issued, for one purpose, bound to one value. Issued and proved by the approver's did:key and carried embedded, as an open object, in the document it backs; never sent on its own. The outer document members (id, type, issuer, recipient, issuedAt, expiresAt, proof) are owned by the framework — SPEC §6.3.\",\n \"properties\": {\n \"audience\": {\n \"description\": \"The relying party's DID. MUST equal the document's recipient and the verifier's own DID.\",\n \"maxLength\": 2048,\n \"minLength\": 5,\n \"pattern\": \"^did:\",\n \"type\": \"string\"\n },\n \"boundTo\": {\n \"description\": \"The opaque value the statement is bound to, compared by equality with the relying party's pending record. For `stepUp`, the approve-request's `boundTo` (a salted DigestMultibase of the operation). For `decision`, the decision's `payloadDigest`. For `enrol`, the enrolment id — an enrollmentId, a claimId, or the terms digest auth/step-up/approver/enroll/0.1 defines.\",\n \"maxLength\": 256,\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"challenge\": {\n \"description\": \"The relying party's challenge for this ceremony, copied verbatim: the approve-request's challenge for `stepUp`, the decision's `challenge` for `decision`, the enrolment start's challenge for `enrol`.\",\n \"maxLength\": 512,\n \"minLength\": 16,\n \"type\": \"string\"\n },\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\"\n },\n \"purpose\": {\n \"description\": \"What the statement attests. `stepUp`: a re-authentication bound to one operation (carried in auth/step-up/approve-response/0.6). `decision`: the factor backing a consent decision (carried in task-consent/decision/0.2 `evidence`). `enrol`: proof of possession of the approver key at enrolment. Signed, so a statement made for one use is refused at another.\",\n \"enum\": [\n \"stepUp\",\n \"decision\",\n \"enrol\"\n ],\n \"type\": \"string\"\n },\n \"subject\": {\n \"description\": \"The one subject DID the approver acts for. MUST equal the subject bound to the relying party's pending record, and MUST differ from the document's issuer.\",\n \"maxLength\": 2048,\n \"minLength\": 5,\n \"pattern\": \"^did:\",\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"purpose\",\n \"subject\",\n \"audience\",\n \"challenge\",\n \"boundTo\"\n ],\n \"title\": \"Auth — Step-up Approver Attest — payload\",\n \"type\": \"object\"\n}\n",
);
}
/// 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] = &[];