//! Generated by `trust-tasks-codegen` — do not edit by hand.
//!
//! Spec slug: `auth/passkey/enroll/invite`. Version: `0.2`.
#![allow(deprecated)]
/// Why this specification version is deprecated (SPEC "Superseded and
/// Withdrawn Versions"), or `None` while it is current.
pub const DEPRECATION: Option<&str> = Some("superseded by auth/passkey/enroll/invite/0.3");
#[allow(unused_imports)]
use serde::{Deserialize, Serialize};
/// Error types.
pub mod error {
/// Error from a `TryFrom` or `FromStr` implementation.
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl ::std::fmt::Debug for ConversionError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
fn from(value: &'static str) -> Self {
Self(value.into())
}
}
impl From<String> for ConversionError {
fn from(value: String) -> Self {
Self(value.into())
}
}
}
///Vendor-namespaced extension object per SPEC.md §4.5.1. Each immediate key MUST be a reverse-DNS namespace; structure under each namespace is opaque to the framework.
///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(transparent)]
pub struct Ext(pub ::std::collections::HashMap<ExtKey, ::serde_json::Value>);
impl ::std::ops::Deref for Ext {
type Target = ::std::collections::HashMap<ExtKey, ::serde_json::Value>;
fn deref(&self) -> &::std::collections::HashMap<ExtKey, ::serde_json::Value> {
&self.0
}
}
impl ::std::convert::From<Ext> for ::std::collections::HashMap<ExtKey, ::serde_json::Value> {
fn from(value: Ext) -> Self {
value.0
}
}
impl ::std::convert::From<::std::collections::HashMap<ExtKey, ::serde_json::Value>> for Ext {
fn from(value: ::std::collections::HashMap<ExtKey, ::serde_json::Value>) -> Self {
Self(value)
}
}
///`ExtKey`
///
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct ExtKey(::std::string::String);
impl ::std::ops::Deref for ExtKey {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<ExtKey> for ::std::string::String {
fn from(value: ExtKey) -> Self {
value.0
}
}
impl ::std::str::FromStr for ExtKey {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
static PATTERN: ::std::sync::LazyLock<::regress::Regex> =
::std::sync::LazyLock::new(|| {
::regress::Regex::new("^[a-z][a-z0-9-]*(\\.[a-z0-9-]+)+$").unwrap()
});
if PATTERN.find(value).is_none() {
return Err("doesn't match pattern \"^[a-z][a-z0-9-]*(\\.[a-z0-9-]+)+$\"".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for ExtKey {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for ExtKey {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for ExtKey {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for ExtKey {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///An administrator issues a single-use invite, redeemed with a separately delivered claim code, that binds a passkey to a subject who cannot yet authorise the binding themselves: their first passkey, or — for `purpose: stepUp` — a step-up-only passkey that never opens a session.
///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
#[deprecated(note = "superseded by auth/passkey/enroll/invite/0.3")]
pub struct Payload {
///Suggested label for the credential. Used as a default; the invitee MAY override during redemption.
#[serde(
rename = "deviceLabel",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub device_label: ::std::option::Option<PayloadDeviceLabel>,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub ext: ::std::option::Option<Ext>,
///What the redeemed credential may authenticate. `session` (the default, and 0.1's only behaviour): it signs the subject in, with the role and scopes the invite carries. `stepUp`: it is accepted only as the user-verification evidence of a step-up bound to one operation (auth/step-up/approve-response `evidence.kind: webauthn`), never to open or elevate a session; `role` and `scopes` MUST then be absent.
#[serde(default = "defaults::payload_purpose")]
pub purpose: PayloadPurpose,
///Role the invitee receives on successful enrollment. Consumer-defined vocabulary; if absent the consumer applies its default role.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub role: ::std::option::Option<::std::string::String>,
///Optional scopes to attach on enrollment.
#[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")]
pub scopes: ::std::vec::Vec<PayloadScopesItem>,
///The VID the invitee will enroll. The admin asserts this binding; the redemption ceremony verifies the invitee controls a passkey and holds the claim code, but does NOT independently verify the subject — trust flows from the admin. For `purpose: stepUp` the consumer MUST already recognise the subject (a member, say).
pub subject: PayloadSubject,
///Seconds the invite remains valid. Consumers SHOULD pick 15 min – 24 h, and MAY cap it lower; longer windows widen the attack surface.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub ttl: ::std::option::Option<::std::num::NonZeroU64>,
}
impl Payload {
pub fn builder() -> builder::Payload {
Default::default()
}
}
///Suggested label for the credential. Used as a default; the invitee MAY override during redemption.
///
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct PayloadDeviceLabel(::std::string::String);
impl ::std::ops::Deref for PayloadDeviceLabel {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<PayloadDeviceLabel> for ::std::string::String {
fn from(value: PayloadDeviceLabel) -> Self {
value.0
}
}
impl ::std::str::FromStr for PayloadDeviceLabel {
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());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for PayloadDeviceLabel {
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 PayloadDeviceLabel {
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 PayloadDeviceLabel {
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 PayloadDeviceLabel {
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 redeemed credential may authenticate. `session` (the default, and 0.1's only behaviour): it signs the subject in, with the role and scopes the invite carries. `stepUp`: it is accepted only as the user-verification evidence of a step-up bound to one operation (auth/step-up/approve-response `evidence.kind: webauthn`), never to open or elevate a session; `role` and `scopes` MUST then be absent.
///
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd,
)]
#[non_exhaustive]
pub enum PayloadPurpose {
#[serde(rename = "session")]
Session,
#[serde(rename = "stepUp")]
StepUp,
}
impl ::std::fmt::Display for PayloadPurpose {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Session => f.write_str("session"),
Self::StepUp => f.write_str("stepUp"),
}
}
}
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 {
"session" => Ok(Self::Session),
"stepUp" => Ok(Self::StepUp),
_ => 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()
}
}
impl ::std::default::Default for PayloadPurpose {
fn default() -> Self {
PayloadPurpose::Session
}
}
///`PayloadScopesItem`
///
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct PayloadScopesItem(::std::string::String);
impl ::std::ops::Deref for PayloadScopesItem {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<PayloadScopesItem> for ::std::string::String {
fn from(value: PayloadScopesItem) -> Self {
value.0
}
}
impl ::std::str::FromStr for PayloadScopesItem {
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 PayloadScopesItem {
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 PayloadScopesItem {
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 PayloadScopesItem {
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 PayloadScopesItem {
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 VID the invitee will enroll. The admin asserts this binding; the redemption ceremony verifies the invitee controls a passkey and holds the claim code, but does NOT independently verify the subject — trust flows from the admin. For `purpose: stepUp` the consumer MUST already recognise the subject (a member, say).
///
#[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() < 1usize {
return Err("shorter than 1 characters".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())
})
}
}
///The issued invite. Carried in a Trust Task document whose type is https://trusttasks.org/spec/auth/passkey/enroll/invite/0.2#response.
///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
#[deprecated(note = "superseded by auth/passkey/enroll/invite/0.3")]
pub struct Response {
///A short code the invitee types at redemption, returned exactly once. The administrator delivers it over a different channel from `url`, so that intercepting one channel is not enough to redeem. The consumer stores only a slow hash of it.
#[serde(rename = "claimCode")]
pub claim_code: ResponseClaimCode,
#[serde(rename = "expiresAt")]
pub expires_at: ::chrono::DateTime<::chrono::offset::Utc>,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub ext: ::std::option::Option<Ext>,
pub invite: ResponseInvite,
///Echo of the purpose the redeemed credential will have.
pub purpose: ResponsePurpose,
///Echo of the invitee's VID.
pub subject: ::std::string::String,
}
impl Response {
pub fn builder() -> builder::Response {
Default::default()
}
}
///A short code the invitee types at redemption, returned exactly once. The administrator delivers it over a different channel from `url`, so that intercepting one channel is not enough to redeem. The consumer stores only a slow hash of it.
///
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct ResponseClaimCode(::std::string::String);
impl ::std::ops::Deref for ResponseClaimCode {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<ResponseClaimCode> for ::std::string::String {
fn from(value: ResponseClaimCode) -> Self {
value.0
}
}
impl ::std::str::FromStr for ResponseClaimCode {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 64usize {
return Err("longer than 64 characters".into());
}
if value.chars().count() < 8usize {
return Err("shorter than 8 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for ResponseClaimCode {
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 ResponseClaimCode {
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 ResponseClaimCode {
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 ResponseClaimCode {
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())
})
}
}
///`ResponseInvite`
///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct ResponseInvite {
///Opaque single-use invite token. The invitee presents it to the consumer during enrollment. ≥128 bits entropy.
pub token: ResponseInviteToken,
///Operator-shareable URL that, when opened in a WebAuthn-capable browser, drives the redemption ceremony (auth/passkey/enroll/redeem/start). Carries the token. MUST NOT carry the claim code.
pub url: ::std::string::String,
}
impl ResponseInvite {
pub fn builder() -> builder::ResponseInvite {
Default::default()
}
}
///Opaque single-use invite token. The invitee presents it to the consumer during enrollment. ≥128 bits entropy.
///
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct ResponseInviteToken(::std::string::String);
impl ::std::ops::Deref for ResponseInviteToken {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<ResponseInviteToken> for ::std::string::String {
fn from(value: ResponseInviteToken) -> Self {
value.0
}
}
impl ::std::str::FromStr for ResponseInviteToken {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() < 16usize {
return Err("shorter than 16 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for ResponseInviteToken {
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 ResponseInviteToken {
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 ResponseInviteToken {
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 ResponseInviteToken {
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())
})
}
}
///Echo of the purpose the redeemed credential will have.
///
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd,
)]
#[non_exhaustive]
pub enum ResponsePurpose {
#[serde(rename = "session")]
Session,
#[serde(rename = "stepUp")]
StepUp,
}
impl ::std::fmt::Display for ResponsePurpose {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Session => f.write_str("session"),
Self::StepUp => f.write_str("stepUp"),
}
}
}
impl ::std::str::FromStr for ResponsePurpose {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"session" => Ok(Self::Session),
"stepUp" => Ok(Self::StepUp),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for ResponsePurpose {
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 ResponsePurpose {
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 ResponsePurpose {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct Payload {
device_label: ::std::result::Result<
::std::option::Option<super::PayloadDeviceLabel>,
::std::string::String,
>,
ext: ::std::result::Result<::std::option::Option<super::Ext>, ::std::string::String>,
purpose: ::std::result::Result<super::PayloadPurpose, ::std::string::String>,
role: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
scopes:
::std::result::Result<::std::vec::Vec<super::PayloadScopesItem>, ::std::string::String>,
subject: ::std::result::Result<super::PayloadSubject, ::std::string::String>,
ttl: ::std::result::Result<
::std::option::Option<::std::num::NonZeroU64>,
::std::string::String,
>,
}
impl ::std::default::Default for Payload {
fn default() -> Self {
Self {
device_label: Ok(Default::default()),
ext: Ok(Default::default()),
purpose: Ok(super::defaults::payload_purpose()),
role: Ok(Default::default()),
scopes: Ok(Default::default()),
subject: Err("no value supplied for subject".to_string()),
ttl: Ok(Default::default()),
}
}
}
impl Payload {
pub fn device_label<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::PayloadDeviceLabel>>,
T::Error: ::std::fmt::Display,
{
self.device_label = value
.try_into()
.map_err(|e| format!("error converting supplied value for device_label: {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 role<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.role = value
.try_into()
.map_err(|e| format!("error converting supplied value for role: {e}"));
self
}
pub fn scopes<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::PayloadScopesItem>>,
T::Error: ::std::fmt::Display,
{
self.scopes = value
.try_into()
.map_err(|e| format!("error converting supplied value for scopes: {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
}
pub fn ttl<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::num::NonZeroU64>>,
T::Error: ::std::fmt::Display,
{
self.ttl = value
.try_into()
.map_err(|e| format!("error converting supplied value for ttl: {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 {
device_label: value.device_label?,
ext: value.ext?,
purpose: value.purpose?,
role: value.role?,
scopes: value.scopes?,
subject: value.subject?,
ttl: value.ttl?,
})
}
}
impl ::std::convert::From<super::Payload> for Payload {
fn from(value: super::Payload) -> Self {
Self {
device_label: Ok(value.device_label),
ext: Ok(value.ext),
purpose: Ok(value.purpose),
role: Ok(value.role),
scopes: Ok(value.scopes),
subject: Ok(value.subject),
ttl: Ok(value.ttl),
}
}
}
#[derive(Clone, Debug)]
pub struct Response {
claim_code: ::std::result::Result<super::ResponseClaimCode, ::std::string::String>,
expires_at:
::std::result::Result<::chrono::DateTime<::chrono::offset::Utc>, ::std::string::String>,
ext: ::std::result::Result<::std::option::Option<super::Ext>, ::std::string::String>,
invite: ::std::result::Result<super::ResponseInvite, ::std::string::String>,
purpose: ::std::result::Result<super::ResponsePurpose, ::std::string::String>,
subject: ::std::result::Result<::std::string::String, ::std::string::String>,
}
impl ::std::default::Default for Response {
fn default() -> Self {
Self {
claim_code: Err("no value supplied for claim_code".to_string()),
expires_at: Err("no value supplied for expires_at".to_string()),
ext: Ok(Default::default()),
invite: Err("no value supplied for invite".to_string()),
purpose: Err("no value supplied for purpose".to_string()),
subject: Err("no value supplied for subject".to_string()),
}
}
}
impl Response {
pub fn claim_code<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ResponseClaimCode>,
T::Error: ::std::fmt::Display,
{
self.claim_code = value
.try_into()
.map_err(|e| format!("error converting supplied value for claim_code: {e}"));
self
}
pub fn expires_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>,
T::Error: ::std::fmt::Display,
{
self.expires_at = value
.try_into()
.map_err(|e| format!("error converting supplied value for expires_at: {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 invite<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ResponseInvite>,
T::Error: ::std::fmt::Display,
{
self.invite = value
.try_into()
.map_err(|e| format!("error converting supplied value for invite: {e}"));
self
}
pub fn purpose<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ResponsePurpose>,
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<::std::string::String>,
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 {
claim_code: value.claim_code?,
expires_at: value.expires_at?,
ext: value.ext?,
invite: value.invite?,
purpose: value.purpose?,
subject: value.subject?,
})
}
}
impl ::std::convert::From<super::Response> for Response {
fn from(value: super::Response) -> Self {
Self {
claim_code: Ok(value.claim_code),
expires_at: Ok(value.expires_at),
ext: Ok(value.ext),
invite: Ok(value.invite),
purpose: Ok(value.purpose),
subject: Ok(value.subject),
}
}
}
#[derive(Clone, Debug)]
pub struct ResponseInvite {
token: ::std::result::Result<super::ResponseInviteToken, ::std::string::String>,
url: ::std::result::Result<::std::string::String, ::std::string::String>,
}
impl ::std::default::Default for ResponseInvite {
fn default() -> Self {
Self {
token: Err("no value supplied for token".to_string()),
url: Err("no value supplied for url".to_string()),
}
}
}
impl ResponseInvite {
pub fn token<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ResponseInviteToken>,
T::Error: ::std::fmt::Display,
{
self.token = value
.try_into()
.map_err(|e| format!("error converting supplied value for token: {e}"));
self
}
pub fn url<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::string::String>,
T::Error: ::std::fmt::Display,
{
self.url = value
.try_into()
.map_err(|e| format!("error converting supplied value for url: {e}"));
self
}
}
impl ::std::convert::TryFrom<ResponseInvite> for super::ResponseInvite {
type Error = super::error::ConversionError;
fn try_from(
value: ResponseInvite,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
token: value.token?,
url: value.url?,
})
}
}
impl ::std::convert::From<super::ResponseInvite> for ResponseInvite {
fn from(value: super::ResponseInvite) -> Self {
Self {
token: Ok(value.token),
url: Ok(value.url),
}
}
}
}
/// Generation of default values for serde.
pub mod defaults {
pub(super) fn payload_purpose() -> super::PayloadPurpose {
super::PayloadPurpose::Session
}
}
impl crate::Payload for Payload {
const TYPE_URI: &'static str = "https://trusttasks.org/spec/auth/passkey/enroll/invite/0.2";
const IS_PROOF_REQUIRED: bool = true;
const IS_ISSUED_AT_REQUIRED: bool = true;
const IS_RECIPIENT_REQUIRED: bool = true;
const PAYLOAD_SCHEMA: Option<&'static str> = Some(
"{\"$defs\":{\"Ext\":{\"additionalProperties\":true,\"description\":\"Vendor-namespaced extension object per SPEC.md §4.5.1. Each immediate key MUST be a reverse-DNS namespace; structure under each namespace is opaque to the framework.\",\"minProperties\":1,\"propertyNames\":{\"pattern\":\"^[a-z][a-z0-9-]*(\\\\.[a-z0-9-]+)+$\"},\"title\":\"Ext\",\"type\":\"object\"},\"Response\":{\"$anchor\":\"response\",\"additionalProperties\":false,\"description\":\"The issued invite. Carried in a Trust Task document whose type is https://trusttasks.org/spec/auth/passkey/enroll/invite/0.2#response.\",\"properties\":{\"claimCode\":{\"description\":\"A short code the invitee types at redemption, returned exactly once. The administrator delivers it over a different channel from `url`, so that intercepting one channel is not enough to redeem. The consumer stores only a slow hash of it.\",\"maxLength\":64,\"minLength\":8,\"type\":\"string\"},\"expiresAt\":{\"format\":\"date-time\",\"type\":\"string\"},\"ext\":{\"$ref\":\"#/$defs/Ext\"},\"invite\":{\"additionalProperties\":false,\"properties\":{\"token\":{\"description\":\"Opaque single-use invite token. The invitee presents it to the consumer during enrollment. ≥128 bits entropy.\",\"minLength\":16,\"type\":\"string\"},\"url\":{\"description\":\"Operator-shareable URL that, when opened in a WebAuthn-capable browser, drives the redemption ceremony (auth/passkey/enroll/redeem/start). Carries the token. MUST NOT carry the claim code.\",\"format\":\"uri\",\"type\":\"string\"}},\"required\":[\"token\",\"url\"],\"type\":\"object\"},\"purpose\":{\"description\":\"Echo of the purpose the redeemed credential will have.\",\"enum\":[\"session\",\"stepUp\"],\"type\":\"string\"},\"subject\":{\"description\":\"Echo of the invitee's VID.\",\"type\":\"string\"}},\"required\":[\"invite\",\"subject\",\"purpose\",\"expiresAt\",\"claimCode\"],\"title\":\"Auth Passkey Enroll Invite — response payload\",\"type\":\"object\"}},\"$id\":\"https://trusttasks.org/spec/auth/passkey/enroll/invite/0.2\",\"$schema\":\"https://json-schema.org/draft/2020-12/schema\",\"additionalProperties\":false,\"description\":\"An administrator issues a single-use invite, redeemed with a separately delivered claim code, that binds a passkey to a subject who cannot yet authorise the binding themselves: their first passkey, or — for `purpose: stepUp` — a step-up-only passkey that never opens a session.\",\"properties\":{\"deviceLabel\":{\"description\":\"Suggested label for the credential. Used as a default; the invitee MAY override during redemption.\",\"maxLength\":256,\"type\":\"string\"},\"ext\":{\"$ref\":\"#/$defs/Ext\"},\"purpose\":{\"default\":\"session\",\"description\":\"What the redeemed credential may authenticate. `session` (the default, and 0.1's only behaviour): it signs the subject in, with the role and scopes the invite carries. `stepUp`: it is accepted only as the user-verification evidence of a step-up bound to one operation (auth/step-up/approve-response `evidence.kind: webauthn`), never to open or elevate a session; `role` and `scopes` MUST then be absent.\",\"enum\":[\"session\",\"stepUp\"],\"type\":\"string\"},\"role\":{\"description\":\"Role the invitee receives on successful enrollment. Consumer-defined vocabulary; if absent the consumer applies its default role.\",\"type\":\"string\"},\"scopes\":{\"description\":\"Optional scopes to attach on enrollment.\",\"items\":{\"minLength\":1,\"type\":\"string\"},\"type\":\"array\"},\"subject\":{\"description\":\"The VID the invitee will enroll. The admin asserts this binding; the redemption ceremony verifies the invitee controls a passkey and holds the claim code, but does NOT independently verify the subject — trust flows from the admin. For `purpose: stepUp` the consumer MUST already recognise the subject (a member, say).\",\"minLength\":1,\"type\":\"string\"},\"ttl\":{\"description\":\"Seconds the invite remains valid. Consumers SHOULD pick 15 min – 24 h, and MAY cap it lower; longer windows widen the attack surface.\",\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"subject\"],\"title\":\"Auth — Passkey Enroll (invite)\",\"type\":\"object\"}\n",
);
}
impl crate::Payload for Response {
const TYPE_URI: &'static str =
"https://trusttasks.org/spec/auth/passkey/enroll/invite/0.2#response";
const IS_PROOF_REQUIRED: bool = true;
const IS_ISSUED_AT_REQUIRED: bool = true;
const IS_RECIPIENT_REQUIRED: bool = true;
const PAYLOAD_SCHEMA: Option<&'static str> = Some(
"{\"$defs\":{\"Ext\":{\"additionalProperties\":true,\"description\":\"Vendor-namespaced extension object per SPEC.md §4.5.1. Each immediate key MUST be a reverse-DNS namespace; structure under each namespace is opaque to the framework.\",\"minProperties\":1,\"propertyNames\":{\"pattern\":\"^[a-z][a-z0-9-]*(\\\\.[a-z0-9-]+)+$\"},\"title\":\"Ext\",\"type\":\"object\"},\"Response\":{\"$anchor\":\"response\",\"additionalProperties\":false,\"description\":\"The issued invite. Carried in a Trust Task document whose type is https://trusttasks.org/spec/auth/passkey/enroll/invite/0.2#response.\",\"properties\":{\"claimCode\":{\"description\":\"A short code the invitee types at redemption, returned exactly once. The administrator delivers it over a different channel from `url`, so that intercepting one channel is not enough to redeem. The consumer stores only a slow hash of it.\",\"maxLength\":64,\"minLength\":8,\"type\":\"string\"},\"expiresAt\":{\"format\":\"date-time\",\"type\":\"string\"},\"ext\":{\"$ref\":\"#/$defs/Ext\"},\"invite\":{\"additionalProperties\":false,\"properties\":{\"token\":{\"description\":\"Opaque single-use invite token. The invitee presents it to the consumer during enrollment. ≥128 bits entropy.\",\"minLength\":16,\"type\":\"string\"},\"url\":{\"description\":\"Operator-shareable URL that, when opened in a WebAuthn-capable browser, drives the redemption ceremony (auth/passkey/enroll/redeem/start). Carries the token. MUST NOT carry the claim code.\",\"format\":\"uri\",\"type\":\"string\"}},\"required\":[\"token\",\"url\"],\"type\":\"object\"},\"purpose\":{\"description\":\"Echo of the purpose the redeemed credential will have.\",\"enum\":[\"session\",\"stepUp\"],\"type\":\"string\"},\"subject\":{\"description\":\"Echo of the invitee's VID.\",\"type\":\"string\"}},\"required\":[\"invite\",\"subject\",\"purpose\",\"expiresAt\",\"claimCode\"],\"title\":\"Auth Passkey Enroll Invite — response payload\",\"type\":\"object\"}},\"$ref\":\"#/$defs/Response\",\"$schema\":\"https://json-schema.org/draft/2020-12/schema\"}\n",
);
}
impl crate::RequestPayload for Payload {
type Response = Response;
}
/// The earlier `MAJOR.MINOR` of this slug that this version declares it
/// extends (front matter `extends`, SPEC §5.2 "Declared extension"), or
/// `None`. Only the direct declaration; walk a chain with
/// [`crate::extension::extends_for`].
pub const EXTENDS: Option<&str> = None;
/// The extended error codes this specification declares (SPEC §7.3 item 9,
/// §8.5), in declaration order. Empty when it declares none.
pub const ERROR_CODES: &[crate::DeclaredErrorCode] = &[
error_codes::SUBJECT_ALREADY_ENROLLED,
error_codes::ROLE_NOT_PERMITTED,
error_codes::PURPOSE_NOT_SUPPORTED,
error_codes::SUBJECT_UNKNOWN,
];
/// 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 {
/// `auth/passkey/enroll/invite:subjectAlreadyEnrolled`
///
/// For `purpose: session`, the invitee VID already has a session credential on file. Use auth/passkey/enroll/start with the existing credential instead.
///
/// Declared `retryable: false`.
pub const SUBJECT_ALREADY_ENROLLED: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "auth/passkey/enroll/invite:subjectAlreadyEnrolled",
retryable: false,
details_schema: ::core::option::Option::None,
};
/// `auth/passkey/enroll/invite:roleNotPermitted`
///
/// The administrator's authority does not allow assigning the requested role, or issuing an invite of this purpose.
///
/// Declared `retryable: false`.
pub const ROLE_NOT_PERMITTED: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "auth/passkey/enroll/invite:roleNotPermitted",
retryable: false,
details_schema: ::core::option::Option::None,
};
/// `auth/passkey/enroll/invite:purposeNotSupported`
///
/// This auth service does not issue credentials of the requested purpose.
///
/// Declared `retryable: false`.
pub const PURPOSE_NOT_SUPPORTED: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "auth/passkey/enroll/invite:purposeNotSupported",
retryable: false,
details_schema: ::core::option::Option::None,
};
/// `auth/passkey/enroll/invite:subjectUnknown`
///
/// For `purpose: stepUp`, the auth service does not recognise the subject — it holds no standing a step-up could ever be asked of.
///
/// Declared `retryable: false`.
pub const SUBJECT_UNKNOWN: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "auth/passkey/enroll/invite:subjectUnknown",
retryable: false,
details_schema: ::core::option::Option::None,
};
}