//! Generated by `trust-tasks-codegen` — do not edit by hand.
//!
//! Spec slug: `auth/passkey/admin-list`. 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())
})
}
}
///The administrator's view of one credential: an identifier, a label, two instants and the signature counter. Never key material, never the credential public key, never attestation.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "ListedCredential",
/// "description": "The administrator's view of one credential: an identifier, a label, two instants and the signature counter. Never key material, never the credential public key, never attestation.",
/// "type": "object",
/// "required": [
/// "credentialId",
/// "registeredAt"
/// ],
/// "properties": {
/// "credentialId": {
/// "description": "Durable identifier of the credential, as auth/passkey/revoke/start takes it. Opaque to the producer: echoed verbatim, never parsed.",
/// "type": "string",
/// "minLength": 1
/// },
/// "deviceLabel": {
/// "description": "Label captured at enrolment. Untrusted free text; absent when none was given. Consumers MUST NOT synthesize one.",
/// "type": "string",
/// "maxLength": 256
/// },
/// "lastUsedAt": {
/// "description": "When the credential last completed an assertion. Absent if it never has, or if the consumer does not track use.",
/// "type": "string",
/// "format": "date-time"
/// },
/// "registeredAt": {
/// "description": "When the credential was bound to the subject.",
/// "type": "string",
/// "format": "date-time"
/// },
/// "signCount": {
/// "description": "The WebAuthn signature counter the consumer last recorded for the credential. Absent when the consumer does not track it. Zero is a real value: many platform authenticators never increment the counter.",
/// "type": "integer",
/// "minimum": 0.0
/// }
/// },
/// "additionalProperties": false,
/// "$anchor": "listedCredential"
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct ListedCredential {
///Durable identifier of the credential, as auth/passkey/revoke/start takes it. Opaque to the producer: echoed verbatim, never parsed.
#[serde(rename = "credentialId")]
pub credential_id: ListedCredentialCredentialId,
///Label captured at enrolment. Untrusted free text; absent when none was given. Consumers MUST NOT synthesize one.
#[serde(
rename = "deviceLabel",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub device_label: ::std::option::Option<ListedCredentialDeviceLabel>,
///When the credential last completed an assertion. Absent if it never has, or if the consumer does not track use.
#[serde(
rename = "lastUsedAt",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub last_used_at: ::std::option::Option<::chrono::DateTime<::chrono::offset::Utc>>,
///When the credential was bound to the subject.
#[serde(rename = "registeredAt")]
pub registered_at: ::chrono::DateTime<::chrono::offset::Utc>,
///The WebAuthn signature counter the consumer last recorded for the credential. Absent when the consumer does not track it. Zero is a real value: many platform authenticators never increment the counter.
#[serde(
rename = "signCount",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub sign_count: ::std::option::Option<u64>,
}
impl ListedCredential {
pub fn builder() -> builder::ListedCredential {
Default::default()
}
}
///Durable identifier of the credential, as auth/passkey/revoke/start takes it. Opaque to the producer: echoed verbatim, never parsed.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "Durable identifier of the credential, as auth/passkey/revoke/start takes it. Opaque to the producer: echoed verbatim, never parsed.",
/// "type": "string",
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct ListedCredentialCredentialId(::std::string::String);
impl ::std::ops::Deref for ListedCredentialCredentialId {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<ListedCredentialCredentialId> for ::std::string::String {
fn from(value: ListedCredentialCredentialId) -> Self {
value.0
}
}
impl ::std::str::FromStr for ListedCredentialCredentialId {
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 ListedCredentialCredentialId {
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 ListedCredentialCredentialId {
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 ListedCredentialCredentialId {
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 ListedCredentialCredentialId {
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())
})
}
}
///Label captured at enrolment. Untrusted free text; absent when none was given. Consumers MUST NOT synthesize one.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "Label captured at enrolment. Untrusted free text; absent when none was given. Consumers MUST NOT synthesize one.",
/// "type": "string",
/// "maxLength": 256
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct ListedCredentialDeviceLabel(::std::string::String);
impl ::std::ops::Deref for ListedCredentialDeviceLabel {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<ListedCredentialDeviceLabel> for ::std::string::String {
fn from(value: ListedCredentialDeviceLabel) -> Self {
value.0
}
}
impl ::std::str::FromStr for ListedCredentialDeviceLabel {
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 ListedCredentialDeviceLabel {
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 ListedCredentialDeviceLabel {
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 ListedCredentialDeviceLabel {
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 ListedCredentialDeviceLabel {
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 lists one subject's passkeys of one purpose — for example a member's step-up passkeys — as non-secret metadata, so they can tell which to revoke. The owner's own listing is auth/passkey/list, which takes no subject; this task exists because a subject in that payload is refused by design.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "$id": "https://trusttasks.org/spec/auth/passkey/admin-list/0.1",
/// "title": "Payload",
/// "description": "An administrator lists one subject's passkeys of one purpose — for example a member's step-up passkeys — as non-secret metadata, so they can tell which to revoke. The owner's own listing is auth/passkey/list, which takes no subject; this task exists because a subject in that payload is refused by design.",
/// "type": "object",
/// "required": [
/// "purpose",
/// "subject"
/// ],
/// "properties": {
/// "ext": {
/// "description": "Ecosystem-defined extension members per SPEC.md §4.5.1.",
/// "$ref": "#/definitions/Ext"
/// },
/// "purpose": {
/// "description": "Which credentials to list: `session` (sign-in) or `stepUp` (the step-up-only passkeys of auth/passkey/enroll/invite 0.2). REQUIRED, with no default, so an administrator reads exactly the inventory they asked for and a consumer can refuse one it does not disclose to administrators.",
/// "type": "string",
/// "enum": [
/// "session",
/// "stepUp"
/// ]
/// },
/// "subject": {
/// "description": "The VID whose credentials are listed. A request, never a grant: the consumer authorises the producer over this subject from its own state.",
/// "type": "string",
/// "minLength": 1
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct Payload {
///Ecosystem-defined extension members per SPEC.md §4.5.1.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub ext: ::std::option::Option<Ext>,
///Which credentials to list: `session` (sign-in) or `stepUp` (the step-up-only passkeys of auth/passkey/enroll/invite 0.2). REQUIRED, with no default, so an administrator reads exactly the inventory they asked for and a consumer can refuse one it does not disclose to administrators.
pub purpose: PayloadPurpose,
///The VID whose credentials are listed. A request, never a grant: the consumer authorises the producer over this subject from its own state.
pub subject: PayloadSubject,
}
impl Payload {
pub fn builder() -> builder::Payload {
Default::default()
}
}
///Which credentials to list: `session` (sign-in) or `stepUp` (the step-up-only passkeys of auth/passkey/enroll/invite 0.2). REQUIRED, with no default, so an administrator reads exactly the inventory they asked for and a consumer can refuse one it does not disclose to administrators.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "Which credentials to list: `session` (sign-in) or `stepUp` (the step-up-only passkeys of auth/passkey/enroll/invite 0.2). REQUIRED, with no default, so an administrator reads exactly the inventory they asked for and a consumer can refuse one it does not disclose to administrators.",
/// "type": "string",
/// "enum": [
/// "session",
/// "stepUp"
/// ]
///}
/// ```
/// </details>
#[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()
}
}
///The VID whose credentials are listed. A request, never a grant: the consumer authorises the producer over this subject from its own state.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "The VID whose credentials are listed. A request, never a grant: the consumer authorises the producer over this subject from its own state.",
/// "type": "string",
/// "minLength": 1
///}
/// ```
/// </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() < 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())
})
}
}
///Carried in a Trust Task document whose type is https://trusttasks.org/spec/auth/passkey/admin-list/0.1#response.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "Response",
/// "description": "Carried in a Trust Task document whose type is https://trusttasks.org/spec/auth/passkey/admin-list/0.1#response.",
/// "type": "object",
/// "required": [
/// "credentials",
/// "purpose",
/// "subject"
/// ],
/// "properties": {
/// "credentials": {
/// "description": "Every credential of that purpose currently bound to the subject, newest registeredAt first. MAY be empty: a member holding none is not an error.",
/// "type": "array",
/// "items": {
/// "$ref": "#/definitions/ListedCredential"
/// }
/// },
/// "ext": {
/// "description": "Ecosystem-defined extension members per SPEC.md §4.5.1.",
/// "$ref": "#/definitions/Ext"
/// },
/// "purpose": {
/// "description": "Echo of payload.purpose.",
/// "type": "string",
/// "enum": [
/// "session",
/// "stepUp"
/// ]
/// },
/// "subject": {
/// "description": "Echo of payload.subject.",
/// "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 {
///Every credential of that purpose currently bound to the subject, newest registeredAt first. MAY be empty: a member holding none is not an error.
pub credentials: ::std::vec::Vec<ListedCredential>,
///Ecosystem-defined extension members per SPEC.md §4.5.1.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub ext: ::std::option::Option<Ext>,
///Echo of payload.purpose.
pub purpose: ResponsePurpose,
///Echo of payload.subject.
pub subject: ResponseSubject,
}
impl Response {
pub fn builder() -> builder::Response {
Default::default()
}
}
///Echo of payload.purpose.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "Echo of payload.purpose.",
/// "type": "string",
/// "enum": [
/// "session",
/// "stepUp"
/// ]
///}
/// ```
/// </details>
#[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()
}
}
///Echo of payload.subject.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "Echo of payload.subject.",
/// "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())
})
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct ListedCredential {
credential_id:
::std::result::Result<super::ListedCredentialCredentialId, ::std::string::String>,
device_label: ::std::result::Result<
::std::option::Option<super::ListedCredentialDeviceLabel>,
::std::string::String,
>,
last_used_at: ::std::result::Result<
::std::option::Option<::chrono::DateTime<::chrono::offset::Utc>>,
::std::string::String,
>,
registered_at:
::std::result::Result<::chrono::DateTime<::chrono::offset::Utc>, ::std::string::String>,
sign_count: ::std::result::Result<::std::option::Option<u64>, ::std::string::String>,
}
impl ::std::default::Default for ListedCredential {
fn default() -> Self {
Self {
credential_id: Err("no value supplied for credential_id".to_string()),
device_label: Ok(Default::default()),
last_used_at: Ok(Default::default()),
registered_at: Err("no value supplied for registered_at".to_string()),
sign_count: Ok(Default::default()),
}
}
}
impl ListedCredential {
pub fn credential_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ListedCredentialCredentialId>,
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 device_label<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::ListedCredentialDeviceLabel>>,
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 last_used_at<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.last_used_at = value
.try_into()
.map_err(|e| format!("error converting supplied value for last_used_at: {e}"));
self
}
pub fn registered_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>,
T::Error: ::std::fmt::Display,
{
self.registered_at = value
.try_into()
.map_err(|e| format!("error converting supplied value for registered_at: {e}"));
self
}
pub fn sign_count<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<u64>>,
T::Error: ::std::fmt::Display,
{
self.sign_count = value
.try_into()
.map_err(|e| format!("error converting supplied value for sign_count: {e}"));
self
}
}
impl ::std::convert::TryFrom<ListedCredential> for super::ListedCredential {
type Error = super::error::ConversionError;
fn try_from(
value: ListedCredential,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
credential_id: value.credential_id?,
device_label: value.device_label?,
last_used_at: value.last_used_at?,
registered_at: value.registered_at?,
sign_count: value.sign_count?,
})
}
}
impl ::std::convert::From<super::ListedCredential> for ListedCredential {
fn from(value: super::ListedCredential) -> Self {
Self {
credential_id: Ok(value.credential_id),
device_label: Ok(value.device_label),
last_used_at: Ok(value.last_used_at),
registered_at: Ok(value.registered_at),
sign_count: Ok(value.sign_count),
}
}
}
#[derive(Clone, Debug)]
pub struct Payload {
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 {
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 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 {
ext: value.ext?,
purpose: value.purpose?,
subject: value.subject?,
})
}
}
impl ::std::convert::From<super::Payload> for Payload {
fn from(value: super::Payload) -> Self {
Self {
ext: Ok(value.ext),
purpose: Ok(value.purpose),
subject: Ok(value.subject),
}
}
}
#[derive(Clone, Debug)]
pub struct Response {
credentials:
::std::result::Result<::std::vec::Vec<super::ListedCredential>, ::std::string::String>,
ext: ::std::result::Result<::std::option::Option<super::Ext>, ::std::string::String>,
purpose: ::std::result::Result<super::ResponsePurpose, ::std::string::String>,
subject: ::std::result::Result<super::ResponseSubject, ::std::string::String>,
}
impl ::std::default::Default for Response {
fn default() -> Self {
Self {
credentials: Err("no value supplied for credentials".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 Response {
pub fn credentials<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::ListedCredential>>,
T::Error: ::std::fmt::Display,
{
self.credentials = value
.try_into()
.map_err(|e| format!("error converting supplied value for credentials: {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::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<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 {
credentials: value.credentials?,
ext: value.ext?,
purpose: value.purpose?,
subject: value.subject?,
})
}
}
impl ::std::convert::From<super::Response> for Response {
fn from(value: super::Response) -> Self {
Self {
credentials: Ok(value.credentials),
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/passkey/admin-list/0.1";
const IS_PROOF_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 \"ListedCredential\": {\n \"$anchor\": \"listedCredential\",\n \"additionalProperties\": false,\n \"description\": \"The administrator's view of one credential: an identifier, a label, two instants and the signature counter. Never key material, never the credential public key, never attestation.\",\n \"properties\": {\n \"credentialId\": {\n \"description\": \"Durable identifier of the credential, as auth/passkey/revoke/start takes it. Opaque to the producer: echoed verbatim, never parsed.\",\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"deviceLabel\": {\n \"description\": \"Label captured at enrolment. Untrusted free text; absent when none was given. Consumers MUST NOT synthesize one.\",\n \"maxLength\": 256,\n \"type\": \"string\"\n },\n \"lastUsedAt\": {\n \"description\": \"When the credential last completed an assertion. Absent if it never has, or if the consumer does not track use.\",\n \"format\": \"date-time\",\n \"type\": \"string\"\n },\n \"registeredAt\": {\n \"description\": \"When the credential was bound to the subject.\",\n \"format\": \"date-time\",\n \"type\": \"string\"\n },\n \"signCount\": {\n \"description\": \"The WebAuthn signature counter the consumer last recorded for the credential. Absent when the consumer does not track it. Zero is a real value: many platform authenticators never increment the counter.\",\n \"minimum\": 0,\n \"type\": \"integer\"\n }\n },\n \"required\": [\n \"credentialId\",\n \"registeredAt\"\n ],\n \"title\": \"ListedCredential\",\n \"type\": \"object\"\n },\n \"Response\": {\n \"$anchor\": \"response\",\n \"additionalProperties\": false,\n \"description\": \"Carried in a Trust Task document whose type is https://trusttasks.org/spec/auth/passkey/admin-list/0.1#response.\",\n \"properties\": {\n \"credentials\": {\n \"description\": \"Every credential of that purpose currently bound to the subject, newest registeredAt first. MAY be empty: a member holding none is not an error.\",\n \"items\": {\n \"$ref\": \"#/$defs/ListedCredential\"\n },\n \"type\": \"array\"\n },\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\",\n \"description\": \"Ecosystem-defined extension members per SPEC.md §4.5.1.\"\n },\n \"purpose\": {\n \"description\": \"Echo of payload.purpose.\",\n \"enum\": [\n \"session\",\n \"stepUp\"\n ],\n \"type\": \"string\"\n },\n \"subject\": {\n \"description\": \"Echo of payload.subject.\",\n \"minLength\": 1,\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"subject\",\n \"purpose\",\n \"credentials\"\n ],\n \"title\": \"Auth Passkey Admin List — response payload\",\n \"type\": \"object\"\n }\n },\n \"$id\": \"https://trusttasks.org/spec/auth/passkey/admin-list/0.1\",\n \"$schema\": \"https://json-schema.org/draft/2020-12/schema\",\n \"additionalProperties\": false,\n \"description\": \"An administrator lists one subject's passkeys of one purpose — for example a member's step-up passkeys — as non-secret metadata, so they can tell which to revoke. The owner's own listing is auth/passkey/list, which takes no subject; this task exists because a subject in that payload is refused by design.\",\n \"properties\": {\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\",\n \"description\": \"Ecosystem-defined extension members per SPEC.md §4.5.1.\"\n },\n \"purpose\": {\n \"description\": \"Which credentials to list: `session` (sign-in) or `stepUp` (the step-up-only passkeys of auth/passkey/enroll/invite 0.2). REQUIRED, with no default, so an administrator reads exactly the inventory they asked for and a consumer can refuse one it does not disclose to administrators.\",\n \"enum\": [\n \"session\",\n \"stepUp\"\n ],\n \"type\": \"string\"\n },\n \"subject\": {\n \"description\": \"The VID whose credentials are listed. A request, never a grant: the consumer authorises the producer over this subject from its own state.\",\n \"minLength\": 1,\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"subject\",\n \"purpose\"\n ],\n \"title\": \"Auth — Passkey Admin List\",\n \"type\": \"object\"\n}\n",
);
}
impl crate::Payload for Response {
const TYPE_URI: &'static str =
"https://trusttasks.org/spec/auth/passkey/admin-list/0.1#response";
const IS_PROOF_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 \"ListedCredential\": {\n \"$anchor\": \"listedCredential\",\n \"additionalProperties\": false,\n \"description\": \"The administrator's view of one credential: an identifier, a label, two instants and the signature counter. Never key material, never the credential public key, never attestation.\",\n \"properties\": {\n \"credentialId\": {\n \"description\": \"Durable identifier of the credential, as auth/passkey/revoke/start takes it. Opaque to the producer: echoed verbatim, never parsed.\",\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"deviceLabel\": {\n \"description\": \"Label captured at enrolment. Untrusted free text; absent when none was given. Consumers MUST NOT synthesize one.\",\n \"maxLength\": 256,\n \"type\": \"string\"\n },\n \"lastUsedAt\": {\n \"description\": \"When the credential last completed an assertion. Absent if it never has, or if the consumer does not track use.\",\n \"format\": \"date-time\",\n \"type\": \"string\"\n },\n \"registeredAt\": {\n \"description\": \"When the credential was bound to the subject.\",\n \"format\": \"date-time\",\n \"type\": \"string\"\n },\n \"signCount\": {\n \"description\": \"The WebAuthn signature counter the consumer last recorded for the credential. Absent when the consumer does not track it. Zero is a real value: many platform authenticators never increment the counter.\",\n \"minimum\": 0,\n \"type\": \"integer\"\n }\n },\n \"required\": [\n \"credentialId\",\n \"registeredAt\"\n ],\n \"title\": \"ListedCredential\",\n \"type\": \"object\"\n },\n \"Response\": {\n \"$anchor\": \"response\",\n \"additionalProperties\": false,\n \"description\": \"Carried in a Trust Task document whose type is https://trusttasks.org/spec/auth/passkey/admin-list/0.1#response.\",\n \"properties\": {\n \"credentials\": {\n \"description\": \"Every credential of that purpose currently bound to the subject, newest registeredAt first. MAY be empty: a member holding none is not an error.\",\n \"items\": {\n \"$ref\": \"#/$defs/ListedCredential\"\n },\n \"type\": \"array\"\n },\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\",\n \"description\": \"Ecosystem-defined extension members per SPEC.md §4.5.1.\"\n },\n \"purpose\": {\n \"description\": \"Echo of payload.purpose.\",\n \"enum\": [\n \"session\",\n \"stepUp\"\n ],\n \"type\": \"string\"\n },\n \"subject\": {\n \"description\": \"Echo of payload.subject.\",\n \"minLength\": 1,\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"subject\",\n \"purpose\",\n \"credentials\"\n ],\n \"title\": \"Auth Passkey Admin List — response payload\",\n \"type\": \"object\"\n }\n },\n \"$ref\": \"#/$defs/Response\",\n \"$schema\": \"https://json-schema.org/draft/2020-12/schema\"\n}\n",
);
}
impl crate::RequestPayload for Payload {
type Response = Response;
}
/// The extended error codes this specification declares (SPEC §7.3 item 9,
/// §8.5), in declaration order. Empty when it declares none.
pub const ERROR_CODES: &[crate::DeclaredErrorCode] = &[
error_codes::NOT_ADMINISTRATOR,
error_codes::SUBJECT_NOT_MEMBER,
error_codes::SUBJECT_UNKNOWN,
error_codes::PURPOSE_NOT_SUPPORTED,
];
/// 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/admin-list:notAdministrator`
///
/// The producer holds no administrator standing at the consumer. Returned before `payload.subject` is looked at, so it reveals nothing about the subject.
///
/// Declared `retryable: false`.
pub const NOT_ADMINISTRATOR: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "auth/passkey/admin-list:notAdministrator",
retryable: false,
};
/// `auth/passkey/admin-list:subjectNotMember`
///
/// The subject is within the administrator's authority and known to the consumer, but is not a current member — they have left, been removed, or not yet been admitted. Their credentials answer nothing, so none are listed.
///
/// Declared `retryable: false`.
pub const SUBJECT_NOT_MEMBER: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "auth/passkey/admin-list:subjectNotMember",
retryable: false,
};
/// `auth/passkey/admin-list:subjectUnknown`
///
/// No subject by that identifier is within the administrator's authority. Returned identically for a subject the consumer has never heard of and for one outside the administrator's authority, so the code cannot be used to probe who is a member elsewhere.
///
/// Declared `retryable: false`.
pub const SUBJECT_UNKNOWN: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "auth/passkey/admin-list:subjectUnknown",
retryable: false,
};
/// `auth/passkey/admin-list:purposeNotSupported`
///
/// The consumer does not disclose credentials of this purpose to administrators — for example it issues no step-up credentials, or keeps session credentials to their owner's own auth/passkey/list.
///
/// Declared `retryable: false`.
pub const PURPOSE_NOT_SUPPORTED: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "auth/passkey/admin-list:purposeNotSupported",
retryable: false,
};
}
#[cfg(test)]
mod conformance {
//! Round-trip tests harvested from the spec's `spec.md`,
//! plus a `rejects_invalid_examples` test for any fixtures
//! in `payload.invalid-examples.json` (validate feature).
#[test]
fn response_example_1() {
const JSON: &str = "{\n \"id\": \"urn:uuid:9e4b2c1a-7d3f-4a6e-8b05-1c2d3e4f5a62\",\n \"type\": \"https://trusttasks.org/spec/auth/passkey/admin-list/0.1#response\",\n \"threadId\": \"urn:uuid:9e4b2c1a-7d3f-4a6e-8b05-1c2d3e4f5a61\",\n \"issuer\": \"did:webvh:QmVtcScid7:acme-vtc.example\",\n \"recipient\": \"did:webvh:QmDanaScid8:acme-vtc.example:dana\",\n \"issuedAt\": \"2026-09-27T09:00:01Z\",\n \"payload\": {\n \"subject\": \"did:webvh:QmCarolScid3:acme-vtc.example:carol\",\n \"purpose\": \"stepUp\",\n \"credentials\": [\n {\n \"credentialId\": \"c3RlcHVwLWNyZWQtY2Fyb2wtMg\",\n \"deviceLabel\": \"Carol's spare key\",\n \"registeredAt\": \"2026-09-26T16:20:00Z\",\n \"signCount\": 0\n },\n {\n \"credentialId\": \"c3RlcHVwLWNyZWQtY2Fyb2w\",\n \"deviceLabel\": \"Carol's laptop\",\n \"registeredAt\": \"2026-09-25T10:04:00Z\",\n \"lastUsedAt\": \"2026-09-26T21:47:12Z\",\n \"signCount\": 14\n }\n ]\n }\n}\n";
let doc: crate::TrustTask<super::Response> =
serde_json::from_str(JSON).expect("deserialize response example");
let rendered = serde_json::to_value(&doc).expect("re-serialize");
let expected: serde_json::Value = serde_json::from_str(JSON).expect("re-parse expected");
assert_eq!(rendered, expected, "response example failed round-trip");
}
#[test]
fn response_example_2() {
const JSON: &str = "{\n \"id\": \"urn:uuid:9e4b2c1a-7d3f-4a6e-8b05-1c2d3e4f5a63\",\n \"type\": \"https://trusttasks.org/spec/auth/passkey/admin-list/0.1#response\",\n \"threadId\": \"urn:uuid:9e4b2c1a-7d3f-4a6e-8b05-1c2d3e4f5a61\",\n \"issuer\": \"did:webvh:QmVtcScid7:acme-vtc.example\",\n \"recipient\": \"did:webvh:QmDanaScid8:acme-vtc.example:dana\",\n \"issuedAt\": \"2026-09-27T09:00:01Z\",\n \"payload\": {\n \"subject\": \"did:webvh:QmCarolScid3:acme-vtc.example:carol\",\n \"purpose\": \"stepUp\",\n \"credentials\": []\n }\n}\n";
let doc: crate::TrustTask<super::Response> =
serde_json::from_str(JSON).expect("deserialize response example");
let rendered = serde_json::to_value(&doc).expect("re-serialize");
let expected: serde_json::Value = serde_json::from_str(JSON).expect("re-parse expected");
assert_eq!(rendered, expected, "response example failed round-trip");
}
/// Each fixture in `payload.invalid-examples.json` MUST be
/// rejected by at least one of: serde deserialization, or
/// JSON-Schema validation under the `validate` feature. The
/// fixture file documents the producer-side bug class that
/// each payload exemplifies; this generated test pins it.
#[cfg(feature = "validate")]
#[test]
fn rejects_invalid_examples() {
use crate::validate::ValidatedPayload;
let fixtures: &[(&str, &str)] = &[
(
"Missing subject — an administrator lists one named subject; the owner's own listing is auth/passkey/list.",
"{\n \"purpose\": \"stepUp\"\n}",
),
(
"Missing purpose — there is no default, so the inventory read is always the one asked for.",
"{\n \"subject\": \"did:webvh:QmCarolScid3:acme-vtc.example:carol\"\n}",
),
("Empty subject.", "{\n \"purpose\": \"stepUp\",\n \"subject\": \"\"\n}"),
(
"Unknown purpose.",
"{\n \"purpose\": \"recovery\",\n \"subject\": \"did:webvh:QmCarolScid3:acme-vtc.example:carol\"\n}",
),
(
"Several subjects — one subject per request, each authorised on its own.",
"{\n \"purpose\": \"stepUp\",\n \"subject\": [\n \"did:webvh:QmCarolScid3:acme-vtc.example:carol\",\n \"did:webvh:QmErinScid4:acme-vtc.example:erin\"\n ]\n}",
),
(
"Unknown top-level member.",
"{\n \"includePublicKeys\": true,\n \"purpose\": \"stepUp\",\n \"subject\": \"did:webvh:QmCarolScid3:acme-vtc.example:carol\"\n}",
),
(
"Bare/unnamespaced ext key.",
"{\n \"ext\": {\n \"bare-key\": {\n \"anything\": \"here\"\n }\n },\n \"purpose\": \"stepUp\",\n \"subject\": \"did:webvh:QmCarolScid3:acme-vtc.example:carol\"\n}",
),
];
for (i, (note, raw)) in fixtures.iter().enumerate() {
let value: serde_json::Value = match serde_json::from_str(raw) {
Ok(v) => v,
Err(_) => continue,
};
let serde_ok = serde_json::from_value::<super::Payload>(value.clone()).is_ok();
let schema_ok = super::Payload::validate_value(&value).is_ok();
assert!(
!(serde_ok && schema_ok),
"invalid-example #{} ({:?}) was accepted by both serde and JSON Schema; \
the fixture's stated failure class is no longer caught:\n{}",
i + 1,
note,
raw
);
}
}
}