//! Generated by `trust-tasks-codegen` — do not edit by hand.
//!
//! Spec slug: `auth/passkey/enroll/finish`. Version: `0.2`.
#[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())
}
}
}
///The credential the client returns from `navigator.credentials.get`. Binary fields are base64url-encoded.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "AuthenticatorAssertionResponse (login)",
/// "description": "The credential the client returns from `navigator.credentials.get`. Binary fields are base64url-encoded.",
/// "type": "object",
/// "required": [
/// "id",
/// "rawId",
/// "response",
/// "type"
/// ],
/// "properties": {
/// "authenticatorAttachment": {
/// "enum": [
/// "platform",
/// "cross-platform"
/// ]
/// },
/// "clientExtensionResults": {
/// "type": "object"
/// },
/// "id": {
/// "type": "string"
/// },
/// "rawId": {
/// "type": "string"
/// },
/// "response": {
/// "type": "object",
/// "required": [
/// "authenticatorData",
/// "clientDataJSON",
/// "signature"
/// ],
/// "properties": {
/// "authenticatorData": {
/// "type": "string"
/// },
/// "clientDataJSON": {
/// "type": "string"
/// },
/// "signature": {
/// "type": "string"
/// },
/// "userHandle": {
/// "type": [
/// "string",
/// "null"
/// ]
/// }
/// },
/// "additionalProperties": false
/// },
/// "type": {
/// "const": "public-key"
/// }
/// },
/// "additionalProperties": false,
/// "$anchor": "assertionResponse"
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
pub struct AssertionResponse {
#[serde(
rename = "authenticatorAttachment",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub authenticator_attachment: ::std::option::Option<AssertionResponseAuthenticatorAttachment>,
#[serde(
rename = "clientExtensionResults",
default,
skip_serializing_if = "::serde_json::Map::is_empty"
)]
pub client_extension_results: ::serde_json::Map<::std::string::String, ::serde_json::Value>,
pub id: ::std::string::String,
#[serde(rename = "rawId")]
pub raw_id: ::std::string::String,
pub response: AssertionResponseResponse,
#[serde(rename = "type")]
pub type_: ::serde_json::Value,
}
///`AssertionResponseAuthenticatorAttachment`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "enum": [
/// "platform",
/// "cross-platform"
/// ]
///}
/// ```
/// </details>
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd,
)]
pub enum AssertionResponseAuthenticatorAttachment {
#[serde(rename = "platform")]
Platform,
#[serde(rename = "cross-platform")]
CrossPlatform,
}
impl ::std::fmt::Display for AssertionResponseAuthenticatorAttachment {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Platform => f.write_str("platform"),
Self::CrossPlatform => f.write_str("cross-platform"),
}
}
}
impl ::std::str::FromStr for AssertionResponseAuthenticatorAttachment {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"platform" => Ok(Self::Platform),
"cross-platform" => Ok(Self::CrossPlatform),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for AssertionResponseAuthenticatorAttachment {
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 AssertionResponseAuthenticatorAttachment {
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 AssertionResponseAuthenticatorAttachment {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///`AssertionResponseResponse`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "type": "object",
/// "required": [
/// "authenticatorData",
/// "clientDataJSON",
/// "signature"
/// ],
/// "properties": {
/// "authenticatorData": {
/// "type": "string"
/// },
/// "clientDataJSON": {
/// "type": "string"
/// },
/// "signature": {
/// "type": "string"
/// },
/// "userHandle": {
/// "type": [
/// "string",
/// "null"
/// ]
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
pub struct AssertionResponseResponse {
#[serde(rename = "authenticatorData")]
pub authenticator_data: ::std::string::String,
#[serde(rename = "clientDataJSON")]
pub client_data_json: ::std::string::String,
pub signature: ::std::string::String,
#[serde(
rename = "userHandle",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub user_handle: ::std::option::Option<::std::string::String>,
}
///The credential the client returns from `navigator.credentials.create`. Binary fields are base64url-encoded.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "AuthenticatorAttestationResponse (registration)",
/// "description": "The credential the client returns from `navigator.credentials.create`. Binary fields are base64url-encoded.",
/// "type": "object",
/// "required": [
/// "id",
/// "rawId",
/// "response",
/// "type"
/// ],
/// "properties": {
/// "authenticatorAttachment": {
/// "enum": [
/// "platform",
/// "cross-platform"
/// ]
/// },
/// "clientExtensionResults": {
/// "type": "object"
/// },
/// "id": {
/// "type": "string"
/// },
/// "rawId": {
/// "type": "string"
/// },
/// "response": {
/// "type": "object",
/// "required": [
/// "attestationObject",
/// "clientDataJSON"
/// ],
/// "properties": {
/// "attestationObject": {
/// "type": "string"
/// },
/// "clientDataJSON": {
/// "type": "string"
/// },
/// "transports": {
/// "type": "array",
/// "items": {
/// "type": "string"
/// }
/// }
/// },
/// "additionalProperties": false
/// },
/// "type": {
/// "const": "public-key"
/// }
/// },
/// "additionalProperties": false,
/// "$anchor": "attestationResponse"
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
pub struct AttestationResponse {
#[serde(
rename = "authenticatorAttachment",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub authenticator_attachment: ::std::option::Option<AttestationResponseAuthenticatorAttachment>,
#[serde(
rename = "clientExtensionResults",
default,
skip_serializing_if = "::serde_json::Map::is_empty"
)]
pub client_extension_results: ::serde_json::Map<::std::string::String, ::serde_json::Value>,
pub id: ::std::string::String,
#[serde(rename = "rawId")]
pub raw_id: ::std::string::String,
pub response: AttestationResponseResponse,
#[serde(rename = "type")]
pub type_: ::serde_json::Value,
}
///`AttestationResponseAuthenticatorAttachment`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "enum": [
/// "platform",
/// "cross-platform"
/// ]
///}
/// ```
/// </details>
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd,
)]
pub enum AttestationResponseAuthenticatorAttachment {
#[serde(rename = "platform")]
Platform,
#[serde(rename = "cross-platform")]
CrossPlatform,
}
impl ::std::fmt::Display for AttestationResponseAuthenticatorAttachment {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Platform => f.write_str("platform"),
Self::CrossPlatform => f.write_str("cross-platform"),
}
}
}
impl ::std::str::FromStr for AttestationResponseAuthenticatorAttachment {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"platform" => Ok(Self::Platform),
"cross-platform" => Ok(Self::CrossPlatform),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for AttestationResponseAuthenticatorAttachment {
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 AttestationResponseAuthenticatorAttachment
{
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 AttestationResponseAuthenticatorAttachment {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///`AttestationResponseResponse`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "type": "object",
/// "required": [
/// "attestationObject",
/// "clientDataJSON"
/// ],
/// "properties": {
/// "attestationObject": {
/// "type": "string"
/// },
/// "clientDataJSON": {
/// "type": "string"
/// },
/// "transports": {
/// "type": "array",
/// "items": {
/// "type": "string"
/// }
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
pub struct AttestationResponseResponse {
#[serde(rename = "attestationObject")]
pub attestation_object: ::std::string::String,
#[serde(rename = "clientDataJSON")]
pub client_data_json: ::std::string::String,
#[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")]
pub transports: ::std::vec::Vec<::std::string::String>,
}
///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())
})
}
}
///Submit the WebAuthn attestation that completes a passkey-enrollment ceremony. On success the auth service binds the credential to the subject's VID.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "$id": "https://trusttasks.org/spec/auth/passkey/enroll/finish/0.2",
/// "title": "Payload",
/// "description": "Submit the WebAuthn attestation that completes a passkey-enrollment ceremony. On success the auth service binds the credential to the subject's VID.",
/// "type": "object",
/// "required": [
/// "credential",
/// "enrollmentId"
/// ],
/// "properties": {
/// "credential": {
/// "description": "AuthenticatorAttestationResponse as returned by `navigator.credentials.create`. Binary fields base64url-encoded.",
/// "$ref": "#/definitions/AttestationResponse"
/// },
/// "deviceLabel": {
/// "description": "Final operator-facing label for the credential. Overrides any label passed at start.",
/// "type": "string"
/// },
/// "enrollmentId": {
/// "description": "The enrollmentId issued by the matching `auth/passkey/enroll/start` response. Echoed verbatim.",
/// "type": "string",
/// "minLength": 1
/// },
/// "ext": {
/// "description": "Ecosystem-defined extension members per SPEC.md §4.5.1.",
/// "$ref": "#/definitions/Ext"
/// },
/// "uvCredential": {
/// "description": "New in 0.2. AuthenticatorAssertionResponse over the uvOptions returned by start, proving a human with an already-enrolled authenticator authorized adding this one. REQUIRED whenever start returned uvOptions; omitted otherwise. A consumer that issued uvOptions MUST reject a finish that lacks this member — the re-authentication requirement is the consumer's, so treating a missing assertion as consent would let a producer decline it unilaterally.",
/// "$ref": "#/definitions/AssertionResponse"
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
pub struct Payload {
///AuthenticatorAttestationResponse as returned by `navigator.credentials.create`. Binary fields base64url-encoded.
pub credential: AttestationResponse,
///Final operator-facing label for the credential. Overrides any label passed at start.
#[serde(
rename = "deviceLabel",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub device_label: ::std::option::Option<::std::string::String>,
///The enrollmentId issued by the matching `auth/passkey/enroll/start` response. Echoed verbatim.
#[serde(rename = "enrollmentId")]
pub enrollment_id: PayloadEnrollmentId,
///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>,
///New in 0.2. AuthenticatorAssertionResponse over the uvOptions returned by start, proving a human with an already-enrolled authenticator authorized adding this one. REQUIRED whenever start returned uvOptions; omitted otherwise. A consumer that issued uvOptions MUST reject a finish that lacks this member — the re-authentication requirement is the consumer's, so treating a missing assertion as consent would let a producer decline it unilaterally.
#[serde(
rename = "uvCredential",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub uv_credential: ::std::option::Option<AssertionResponse>,
}
///The enrollmentId issued by the matching `auth/passkey/enroll/start` response. Echoed verbatim.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "The enrollmentId issued by the matching `auth/passkey/enroll/start` response. Echoed verbatim.",
/// "type": "string",
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct PayloadEnrollmentId(::std::string::String);
impl ::std::ops::Deref for PayloadEnrollmentId {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<PayloadEnrollmentId> for ::std::string::String {
fn from(value: PayloadEnrollmentId) -> Self {
value.0
}
}
impl ::std::str::FromStr for PayloadEnrollmentId {
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 PayloadEnrollmentId {
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 PayloadEnrollmentId {
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 PayloadEnrollmentId {
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 PayloadEnrollmentId {
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())
})
}
}
///Acknowledgement of the registered credential. Carried in a Trust Task document whose type is https://trusttasks.org/spec/auth/passkey/enroll/finish/0.2#response.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "Response",
/// "description": "Acknowledgement of the registered credential. Carried in a Trust Task document whose type is https://trusttasks.org/spec/auth/passkey/enroll/finish/0.2#response.",
/// "type": "object",
/// "required": [
/// "credentialId",
/// "registeredAt",
/// "subject"
/// ],
/// "properties": {
/// "credentialId": {
/// "description": "base64url-encoded WebAuthn credential id, durable identifier for later management.",
/// "type": "string"
/// },
/// "deviceLabel": {
/// "description": "The label persisted with the credential.",
/// "type": "string"
/// },
/// "ext": {
/// "description": "Ecosystem-defined extension members per SPEC.md §4.5.1.",
/// "$ref": "#/definitions/Ext"
/// },
/// "registeredAt": {
/// "type": "string",
/// "format": "date-time"
/// },
/// "subject": {
/// "description": "The VID the credential is now bound to. Echoed for symmetry with finish-time error responses.",
/// "type": "string"
/// }
/// },
/// "additionalProperties": false,
/// "$anchor": "response"
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
pub struct Response {
///base64url-encoded WebAuthn credential id, durable identifier for later management.
#[serde(rename = "credentialId")]
pub credential_id: ::std::string::String,
///The label persisted with the credential.
#[serde(
rename = "deviceLabel",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub device_label: ::std::option::Option<::std::string::String>,
///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>,
#[serde(rename = "registeredAt")]
pub registered_at: ::chrono::DateTime<::chrono::offset::Utc>,
///The VID the credential is now bound to. Echoed for symmetry with finish-time error responses.
pub subject: ::std::string::String,
}
impl crate::Payload for Payload {
const TYPE_URI: &'static str = "https://trusttasks.org/spec/auth/passkey/enroll/finish/0.2";
const IS_PROOF_REQUIRED: bool = true;
const IS_RECIPIENT_REQUIRED: bool = true;
}
impl crate::Payload for Response {
const TYPE_URI: &'static str =
"https://trusttasks.org/spec/auth/passkey/enroll/finish/0.2#response";
const IS_PROOF_REQUIRED: bool = true;
const IS_RECIPIENT_REQUIRED: bool = true;
}
#[cfg(feature = "validate")]
impl crate::validate::ValidatedPayload for Payload {
const SCHEMA_JSON: &'static str = "{\n \"$defs\": {\n \"AssertionResponse\": {\n \"$anchor\": \"assertionResponse\",\n \"additionalProperties\": false,\n \"description\": \"The credential the client returns from `navigator.credentials.get`. Binary fields are base64url-encoded.\",\n \"properties\": {\n \"authenticatorAttachment\": {\n \"enum\": [\n \"platform\",\n \"cross-platform\"\n ]\n },\n \"clientExtensionResults\": {\n \"type\": \"object\"\n },\n \"id\": {\n \"type\": \"string\"\n },\n \"rawId\": {\n \"type\": \"string\"\n },\n \"response\": {\n \"additionalProperties\": false,\n \"properties\": {\n \"authenticatorData\": {\n \"type\": \"string\"\n },\n \"clientDataJSON\": {\n \"type\": \"string\"\n },\n \"signature\": {\n \"type\": \"string\"\n },\n \"userHandle\": {\n \"type\": [\n \"string\",\n \"null\"\n ]\n }\n },\n \"required\": [\n \"clientDataJSON\",\n \"authenticatorData\",\n \"signature\"\n ],\n \"type\": \"object\"\n },\n \"type\": {\n \"const\": \"public-key\"\n }\n },\n \"required\": [\n \"id\",\n \"rawId\",\n \"type\",\n \"response\"\n ],\n \"title\": \"AuthenticatorAssertionResponse (login)\",\n \"type\": \"object\"\n },\n \"AttestationResponse\": {\n \"$anchor\": \"attestationResponse\",\n \"additionalProperties\": false,\n \"description\": \"The credential the client returns from `navigator.credentials.create`. Binary fields are base64url-encoded.\",\n \"properties\": {\n \"authenticatorAttachment\": {\n \"enum\": [\n \"platform\",\n \"cross-platform\"\n ]\n },\n \"clientExtensionResults\": {\n \"type\": \"object\"\n },\n \"id\": {\n \"type\": \"string\"\n },\n \"rawId\": {\n \"type\": \"string\"\n },\n \"response\": {\n \"additionalProperties\": false,\n \"properties\": {\n \"attestationObject\": {\n \"type\": \"string\"\n },\n \"clientDataJSON\": {\n \"type\": \"string\"\n },\n \"transports\": {\n \"items\": {\n \"type\": \"string\"\n },\n \"type\": \"array\"\n }\n },\n \"required\": [\n \"clientDataJSON\",\n \"attestationObject\"\n ],\n \"type\": \"object\"\n },\n \"type\": {\n \"const\": \"public-key\"\n }\n },\n \"required\": [\n \"id\",\n \"rawId\",\n \"type\",\n \"response\"\n ],\n \"title\": \"AuthenticatorAttestationResponse (registration)\",\n \"type\": \"object\"\n },\n \"Ext\": {\n \"additionalProperties\": true,\n \"description\": \"Vendor-namespaced extension object per SPEC.md §4.5.1. Each immediate key MUST be a reverse-DNS namespace; structure under each namespace is opaque to the framework.\",\n \"minProperties\": 1,\n \"propertyNames\": {\n \"pattern\": \"^[a-z][a-z0-9-]*(\\\\.[a-z0-9-]+)+$\"\n },\n \"title\": \"Ext\",\n \"type\": \"object\"\n },\n \"Response\": {\n \"$anchor\": \"response\",\n \"additionalProperties\": false,\n \"description\": \"Acknowledgement of the registered credential. Carried in a Trust Task document whose type is https://trusttasks.org/spec/auth/passkey/enroll/finish/0.2#response.\",\n \"properties\": {\n \"credentialId\": {\n \"description\": \"base64url-encoded WebAuthn credential id, durable identifier for later management.\",\n \"type\": \"string\"\n },\n \"deviceLabel\": {\n \"description\": \"The label persisted with the credential.\",\n \"type\": \"string\"\n },\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\",\n \"description\": \"Ecosystem-defined extension members per SPEC.md §4.5.1.\"\n },\n \"registeredAt\": {\n \"format\": \"date-time\",\n \"type\": \"string\"\n },\n \"subject\": {\n \"description\": \"The VID the credential is now bound to. Echoed for symmetry with finish-time error responses.\",\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"credentialId\",\n \"subject\",\n \"registeredAt\"\n ],\n \"title\": \"Auth Passkey Enroll Finish — response payload\",\n \"type\": \"object\"\n }\n },\n \"$id\": \"https://trusttasks.org/spec/auth/passkey/enroll/finish/0.2\",\n \"$schema\": \"https://json-schema.org/draft/2020-12/schema\",\n \"additionalProperties\": false,\n \"description\": \"Submit the WebAuthn attestation that completes a passkey-enrollment ceremony. On success the auth service binds the credential to the subject's VID.\",\n \"properties\": {\n \"credential\": {\n \"$ref\": \"#/$defs/AttestationResponse\",\n \"description\": \"AuthenticatorAttestationResponse as returned by `navigator.credentials.create`. Binary fields base64url-encoded.\"\n },\n \"deviceLabel\": {\n \"description\": \"Final operator-facing label for the credential. Overrides any label passed at start.\",\n \"type\": \"string\"\n },\n \"enrollmentId\": {\n \"description\": \"The enrollmentId issued by the matching `auth/passkey/enroll/start` response. Echoed verbatim.\",\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\",\n \"description\": \"Ecosystem-defined extension members per SPEC.md §4.5.1.\"\n },\n \"uvCredential\": {\n \"$ref\": \"#/$defs/AssertionResponse\",\n \"description\": \"New in 0.2. AuthenticatorAssertionResponse over the uvOptions returned by start, proving a human with an already-enrolled authenticator authorized adding this one. REQUIRED whenever start returned uvOptions; omitted otherwise. A consumer that issued uvOptions MUST reject a finish that lacks this member — the re-authentication requirement is the consumer's, so treating a missing assertion as consent would let a producer decline it unilaterally.\"\n }\n },\n \"required\": [\n \"enrollmentId\",\n \"credential\"\n ],\n \"title\": \"Auth — Passkey Enroll (finish)\",\n \"type\": \"object\"\n}\n";
}
#[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\": \"77777777-aaaa-bbbb-cccc-888888888888\",\n \"type\": \"https://trusttasks.org/spec/auth/passkey/enroll/finish/0.2#response\",\n \"threadId\": \"55555555-eeee-ffff-aaaa-666666666666\",\n \"issuer\": \"did:web:auth.example\",\n \"recipient\": \"did:web:alice.example\",\n \"issuedAt\": \"2026-05-23T12:01:01Z\",\n \"payload\": {\n \"credentialId\": \"Y3JlZF8xYTJiM2M\",\n \"subject\": \"did:web:alice.example\",\n \"deviceLabel\": \"Alice's MacBook Pro\",\n \"registeredAt\": \"2026-05-23T12:01:01Z\"\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 required enrollmentId.",
"{\n \"credential\": {\n \"id\": \"x\",\n \"rawId\": \"x\",\n \"response\": {\n \"attestationObject\": \"x\",\n \"clientDataJSON\": \"x\"\n },\n \"type\": \"public-key\"\n }\n}",
),
(
"Missing required credential.",
"{\n \"enrollmentId\": \"enr_1a2b3c4d5e6f7890\"\n}",
),
(
"credential.type is not the WebAuthn-required const.",
"{\n \"credential\": {\n \"id\": \"x\",\n \"rawId\": \"x\",\n \"response\": {\n \"attestationObject\": \"x\",\n \"clientDataJSON\": \"x\"\n },\n \"type\": \"totp\"\n },\n \"enrollmentId\": \"enr_1a2b3c4d5e6f7890\"\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
);
}
}
}