//! Generated by `trust-tasks-codegen` — do not edit by hand.
//!
//! Spec slug: `vta/passkey-vms/enroll-submit`. 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())
})
}
}
///`PasskeyVerificationMethod`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "PasskeyVerificationMethod",
/// "type": "object",
/// "required": [
/// "controller",
/// "id",
/// "publicKeyMultibase",
/// "type",
/// "webauthnCredentialId"
/// ],
/// "properties": {
/// "controller": {
/// "description": "The DID this verificationMethod is published on (the DID being augmented).",
/// "type": "string",
/// "minLength": 1
/// },
/// "id": {
/// "description": "The verificationMethod id as it appears in the DID document: `<did>#passkey-<base64url(sha256(credentialId))>`. The fragment is content-derived so a verifier can locate this VM by recomputing `sha256(credential.id)`.",
/// "type": "string",
/// "minLength": 1
/// },
/// "label": {
/// "description": "Optional operator-supplied human-readable label (e.g. \"MacBook Touch ID\"). Informational; not authoritative and not a security input.",
/// "type": "string",
/// "maxLength": 128,
/// "minLength": 1
/// },
/// "publicKeyMultibase": {
/// "description": "W3C Multikey (multibase) encoding of the WebAuthn credential public key. This is the value a verifier validates a WebAuthn assertion against. Re-derived server-side from the attestation at enrolment — never trusted from the browser (see vta/passkey-vms/enroll-submit).",
/// "type": "string",
/// "minLength": 1
/// },
/// "type": {
/// "description": "Always `Multikey`. The WebAuthn public key is published in W3C Multikey form so DID resolvers and verifiers need no WebAuthn-specific knowledge to consume it.",
/// "type": "string",
/// "const": "Multikey"
/// },
/// "webauthnCredentialId": {
/// "description": "The WebAuthn `credential.id` (base64url, no padding). Lets a verifier recompute `sha256(credentialId)` and match the assertion to this VM's `id` fragment.",
/// "type": "string",
/// "minLength": 1
/// },
/// "webauthnTransports": {
/// "description": "Transport hints reported by the authenticator (e.g. `internal`, `hybrid`, `usb`, `nfc`, `ble`). Advisory only — verifiers MUST NOT make trust decisions based on transport hints.",
/// "type": "array",
/// "items": {
/// "type": "string"
/// },
/// "uniqueItems": true
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct PasskeyVerificationMethod {
///The DID this verificationMethod is published on (the DID being augmented).
pub controller: PasskeyVerificationMethodController,
///The verificationMethod id as it appears in the DID document: `<did>#passkey-<base64url(sha256(credentialId))>`. The fragment is content-derived so a verifier can locate this VM by recomputing `sha256(credential.id)`.
pub id: PasskeyVerificationMethodId,
///Optional operator-supplied human-readable label (e.g. "MacBook Touch ID"). Informational; not authoritative and not a security input.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub label: ::std::option::Option<PasskeyVerificationMethodLabel>,
///W3C Multikey (multibase) encoding of the WebAuthn credential public key. This is the value a verifier validates a WebAuthn assertion against. Re-derived server-side from the attestation at enrolment — never trusted from the browser (see vta/passkey-vms/enroll-submit).
#[serde(rename = "publicKeyMultibase")]
pub public_key_multibase: PasskeyVerificationMethodPublicKeyMultibase,
///Always `Multikey`. The WebAuthn public key is published in W3C Multikey form so DID resolvers and verifiers need no WebAuthn-specific knowledge to consume it.
#[serde(rename = "type")]
pub type_: ::std::string::String,
///The WebAuthn `credential.id` (base64url, no padding). Lets a verifier recompute `sha256(credentialId)` and match the assertion to this VM's `id` fragment.
#[serde(rename = "webauthnCredentialId")]
pub webauthn_credential_id: PasskeyVerificationMethodWebauthnCredentialId,
///Transport hints reported by the authenticator (e.g. `internal`, `hybrid`, `usb`, `nfc`, `ble`). Advisory only — verifiers MUST NOT make trust decisions based on transport hints.
#[serde(
rename = "webauthnTransports",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub webauthn_transports: ::std::option::Option<Vec<::std::string::String>>,
}
impl PasskeyVerificationMethod {
pub fn builder() -> builder::PasskeyVerificationMethod {
Default::default()
}
}
///The DID this verificationMethod is published on (the DID being augmented).
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "The DID this verificationMethod is published on (the DID being augmented).",
/// "type": "string",
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct PasskeyVerificationMethodController(::std::string::String);
impl ::std::ops::Deref for PasskeyVerificationMethodController {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<PasskeyVerificationMethodController> for ::std::string::String {
fn from(value: PasskeyVerificationMethodController) -> Self {
value.0
}
}
impl ::std::str::FromStr for PasskeyVerificationMethodController {
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 PasskeyVerificationMethodController {
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 PasskeyVerificationMethodController {
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 PasskeyVerificationMethodController {
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 PasskeyVerificationMethodController {
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 verificationMethod id as it appears in the DID document: `<did>#passkey-<base64url(sha256(credentialId))>`. The fragment is content-derived so a verifier can locate this VM by recomputing `sha256(credential.id)`.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "The verificationMethod id as it appears in the DID document: `<did>#passkey-<base64url(sha256(credentialId))>`. The fragment is content-derived so a verifier can locate this VM by recomputing `sha256(credential.id)`.",
/// "type": "string",
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct PasskeyVerificationMethodId(::std::string::String);
impl ::std::ops::Deref for PasskeyVerificationMethodId {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<PasskeyVerificationMethodId> for ::std::string::String {
fn from(value: PasskeyVerificationMethodId) -> Self {
value.0
}
}
impl ::std::str::FromStr for PasskeyVerificationMethodId {
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 PasskeyVerificationMethodId {
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 PasskeyVerificationMethodId {
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 PasskeyVerificationMethodId {
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 PasskeyVerificationMethodId {
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())
})
}
}
///Optional operator-supplied human-readable label (e.g. "MacBook Touch ID"). Informational; not authoritative and not a security input.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "Optional operator-supplied human-readable label (e.g. \"MacBook Touch ID\"). Informational; not authoritative and not a security input.",
/// "type": "string",
/// "maxLength": 128,
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct PasskeyVerificationMethodLabel(::std::string::String);
impl ::std::ops::Deref for PasskeyVerificationMethodLabel {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<PasskeyVerificationMethodLabel> for ::std::string::String {
fn from(value: PasskeyVerificationMethodLabel) -> Self {
value.0
}
}
impl ::std::str::FromStr for PasskeyVerificationMethodLabel {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 128usize {
return Err("longer than 128 characters".into());
}
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for PasskeyVerificationMethodLabel {
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 PasskeyVerificationMethodLabel {
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 PasskeyVerificationMethodLabel {
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 PasskeyVerificationMethodLabel {
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())
})
}
}
///W3C Multikey (multibase) encoding of the WebAuthn credential public key. This is the value a verifier validates a WebAuthn assertion against. Re-derived server-side from the attestation at enrolment — never trusted from the browser (see vta/passkey-vms/enroll-submit).
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "W3C Multikey (multibase) encoding of the WebAuthn credential public key. This is the value a verifier validates a WebAuthn assertion against. Re-derived server-side from the attestation at enrolment — never trusted from the browser (see vta/passkey-vms/enroll-submit).",
/// "type": "string",
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct PasskeyVerificationMethodPublicKeyMultibase(::std::string::String);
impl ::std::ops::Deref for PasskeyVerificationMethodPublicKeyMultibase {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<PasskeyVerificationMethodPublicKeyMultibase> for ::std::string::String {
fn from(value: PasskeyVerificationMethodPublicKeyMultibase) -> Self {
value.0
}
}
impl ::std::str::FromStr for PasskeyVerificationMethodPublicKeyMultibase {
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 PasskeyVerificationMethodPublicKeyMultibase {
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 PasskeyVerificationMethodPublicKeyMultibase
{
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 PasskeyVerificationMethodPublicKeyMultibase
{
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 PasskeyVerificationMethodPublicKeyMultibase {
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 WebAuthn `credential.id` (base64url, no padding). Lets a verifier recompute `sha256(credentialId)` and match the assertion to this VM's `id` fragment.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "The WebAuthn `credential.id` (base64url, no padding). Lets a verifier recompute `sha256(credentialId)` and match the assertion to this VM's `id` fragment.",
/// "type": "string",
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct PasskeyVerificationMethodWebauthnCredentialId(::std::string::String);
impl ::std::ops::Deref for PasskeyVerificationMethodWebauthnCredentialId {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<PasskeyVerificationMethodWebauthnCredentialId> for ::std::string::String {
fn from(value: PasskeyVerificationMethodWebauthnCredentialId) -> Self {
value.0
}
}
impl ::std::str::FromStr for PasskeyVerificationMethodWebauthnCredentialId {
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 PasskeyVerificationMethodWebauthnCredentialId {
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 PasskeyVerificationMethodWebauthnCredentialId
{
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 PasskeyVerificationMethodWebauthnCredentialId
{
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 PasskeyVerificationMethodWebauthnCredentialId {
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())
})
}
}
///Finalise passkey enrolment by submitting the WebAuthn registration result for a ceremony opened by vta/passkey-vms/enroll-challenge. The VTA re-derives the Multikey from attestationObject.authData and rejects on mismatch with the browser-claimed publicKeyMultibase — the browser's value is NOT trusted as authoritative. On success the VTA appends the verificationMethod to the DID document via a WebVH log entry. All byte-valued fields are base64url-encoded (no padding).
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "$id": "https://trusttasks.org/spec/vta/passkey-vms/enroll-submit/0.1",
/// "title": "Payload",
/// "description": "Finalise passkey enrolment by submitting the WebAuthn registration result for a ceremony opened by vta/passkey-vms/enroll-challenge. The VTA re-derives the Multikey from attestationObject.authData and rejects on mismatch with the browser-claimed publicKeyMultibase — the browser's value is NOT trusted as authoritative. On success the VTA appends the verificationMethod to the DID document via a WebVH log entry. All byte-valued fields are base64url-encoded (no padding).",
/// "type": "object",
/// "required": [
/// "attestationObject",
/// "authenticatorData",
/// "ceremonyId",
/// "clientDataJson",
/// "coseAlgorithm",
/// "credentialId",
/// "did",
/// "publicKeyMultibase"
/// ],
/// "properties": {
/// "attestationObject": {
/// "description": "Raw WebAuthn `attestationObject` — base64url-encoded CBOR. The VTA parses `authData` from this to re-derive the authoritative public key.",
/// "type": "string",
/// "minLength": 1
/// },
/// "authenticatorData": {
/// "description": "Raw WebAuthn `authenticatorData` (base64url, no padding).",
/// "type": "string",
/// "minLength": 1
/// },
/// "ceremonyId": {
/// "description": "The `ceremonyId` returned by vta/passkey-vms/enroll-challenge. Single-use; consumed by this submission.",
/// "type": "string",
/// "minLength": 1
/// },
/// "clientDataJson": {
/// "description": "Raw WebAuthn `clientDataJSON` (base64url, no padding). Bound to the ceremony `challenge` during WebAuthn verification.",
/// "type": "string",
/// "minLength": 1
/// },
/// "coseAlgorithm": {
/// "description": "COSE algorithm identifier of the credential key (e.g. -7 for ES256, -8 for EdDSA). Must be an algorithm the VTA can convert to a Multikey.",
/// "type": "integer"
/// },
/// "credentialId": {
/// "description": "WebAuthn `credential.id` (base64url, no padding). The published verificationMethod `id` fragment is derived as `passkey-<base64url(sha256(credentialId))>`.",
/// "type": "string",
/// "minLength": 1
/// },
/// "did": {
/// "description": "The DID the new verificationMethod is to be added to. MUST match the DID bound to `ceremonyId` at challenge time — a mismatch is rejected as a cross-DID replay.",
/// "type": "string",
/// "minLength": 1
/// },
/// "ext": {
/// "description": "Ecosystem-defined extension members per SPEC.md §4.5.1.",
/// "$ref": "#/definitions/Ext"
/// },
/// "label": {
/// "description": "Optional operator-supplied label (e.g. \"MacBook Touch ID\"), carried through to the published verificationMethod.",
/// "type": "string",
/// "maxLength": 128,
/// "minLength": 1
/// },
/// "publicKeyMultibase": {
/// "description": "Browser-computed W3C Multikey for the credential public key. ADVISORY: the VTA re-derives the Multikey from `attestationObject.authData` and rejects this submission if the values differ (anti-tamper gate). The re-derived key — not this one — is what gets published.",
/// "type": "string",
/// "minLength": 1
/// },
/// "transports": {
/// "description": "Transport hints reported by the authenticator (e.g. `internal`, `hybrid`). Advisory; carried through to the published verificationMethod's `webauthnTransports`.",
/// "type": "array",
/// "items": {
/// "type": "string"
/// },
/// "uniqueItems": true
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct Payload {
///Raw WebAuthn `attestationObject` — base64url-encoded CBOR. The VTA parses `authData` from this to re-derive the authoritative public key.
#[serde(rename = "attestationObject")]
pub attestation_object: PayloadAttestationObject,
///Raw WebAuthn `authenticatorData` (base64url, no padding).
#[serde(rename = "authenticatorData")]
pub authenticator_data: PayloadAuthenticatorData,
///The `ceremonyId` returned by vta/passkey-vms/enroll-challenge. Single-use; consumed by this submission.
#[serde(rename = "ceremonyId")]
pub ceremony_id: PayloadCeremonyId,
///Raw WebAuthn `clientDataJSON` (base64url, no padding). Bound to the ceremony `challenge` during WebAuthn verification.
#[serde(rename = "clientDataJson")]
pub client_data_json: PayloadClientDataJson,
///COSE algorithm identifier of the credential key (e.g. -7 for ES256, -8 for EdDSA). Must be an algorithm the VTA can convert to a Multikey.
#[serde(rename = "coseAlgorithm")]
pub cose_algorithm: i64,
///WebAuthn `credential.id` (base64url, no padding). The published verificationMethod `id` fragment is derived as `passkey-<base64url(sha256(credentialId))>`.
#[serde(rename = "credentialId")]
pub credential_id: PayloadCredentialId,
///The DID the new verificationMethod is to be added to. MUST match the DID bound to `ceremonyId` at challenge time — a mismatch is rejected as a cross-DID replay.
pub did: PayloadDid,
///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>,
///Optional operator-supplied label (e.g. "MacBook Touch ID"), carried through to the published verificationMethod.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub label: ::std::option::Option<PayloadLabel>,
///Browser-computed W3C Multikey for the credential public key. ADVISORY: the VTA re-derives the Multikey from `attestationObject.authData` and rejects this submission if the values differ (anti-tamper gate). The re-derived key — not this one — is what gets published.
#[serde(rename = "publicKeyMultibase")]
pub public_key_multibase: PayloadPublicKeyMultibase,
///Transport hints reported by the authenticator (e.g. `internal`, `hybrid`). Advisory; carried through to the published verificationMethod's `webauthnTransports`.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub transports: ::std::option::Option<Vec<::std::string::String>>,
}
impl Payload {
pub fn builder() -> builder::Payload {
Default::default()
}
}
///Raw WebAuthn `attestationObject` — base64url-encoded CBOR. The VTA parses `authData` from this to re-derive the authoritative public key.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "Raw WebAuthn `attestationObject` — base64url-encoded CBOR. The VTA parses `authData` from this to re-derive the authoritative public key.",
/// "type": "string",
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct PayloadAttestationObject(::std::string::String);
impl ::std::ops::Deref for PayloadAttestationObject {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<PayloadAttestationObject> for ::std::string::String {
fn from(value: PayloadAttestationObject) -> Self {
value.0
}
}
impl ::std::str::FromStr for PayloadAttestationObject {
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 PayloadAttestationObject {
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 PayloadAttestationObject {
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 PayloadAttestationObject {
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 PayloadAttestationObject {
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())
})
}
}
///Raw WebAuthn `authenticatorData` (base64url, no padding).
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "Raw WebAuthn `authenticatorData` (base64url, no padding).",
/// "type": "string",
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct PayloadAuthenticatorData(::std::string::String);
impl ::std::ops::Deref for PayloadAuthenticatorData {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<PayloadAuthenticatorData> for ::std::string::String {
fn from(value: PayloadAuthenticatorData) -> Self {
value.0
}
}
impl ::std::str::FromStr for PayloadAuthenticatorData {
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 PayloadAuthenticatorData {
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 PayloadAuthenticatorData {
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 PayloadAuthenticatorData {
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 PayloadAuthenticatorData {
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 `ceremonyId` returned by vta/passkey-vms/enroll-challenge. Single-use; consumed by this submission.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "The `ceremonyId` returned by vta/passkey-vms/enroll-challenge. Single-use; consumed by this submission.",
/// "type": "string",
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct PayloadCeremonyId(::std::string::String);
impl ::std::ops::Deref for PayloadCeremonyId {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<PayloadCeremonyId> for ::std::string::String {
fn from(value: PayloadCeremonyId) -> Self {
value.0
}
}
impl ::std::str::FromStr for PayloadCeremonyId {
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 PayloadCeremonyId {
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 PayloadCeremonyId {
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 PayloadCeremonyId {
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 PayloadCeremonyId {
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())
})
}
}
///Raw WebAuthn `clientDataJSON` (base64url, no padding). Bound to the ceremony `challenge` during WebAuthn verification.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "Raw WebAuthn `clientDataJSON` (base64url, no padding). Bound to the ceremony `challenge` during WebAuthn verification.",
/// "type": "string",
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct PayloadClientDataJson(::std::string::String);
impl ::std::ops::Deref for PayloadClientDataJson {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<PayloadClientDataJson> for ::std::string::String {
fn from(value: PayloadClientDataJson) -> Self {
value.0
}
}
impl ::std::str::FromStr for PayloadClientDataJson {
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 PayloadClientDataJson {
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 PayloadClientDataJson {
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 PayloadClientDataJson {
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 PayloadClientDataJson {
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())
})
}
}
///WebAuthn `credential.id` (base64url, no padding). The published verificationMethod `id` fragment is derived as `passkey-<base64url(sha256(credentialId))>`.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "WebAuthn `credential.id` (base64url, no padding). The published verificationMethod `id` fragment is derived as `passkey-<base64url(sha256(credentialId))>`.",
/// "type": "string",
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct PayloadCredentialId(::std::string::String);
impl ::std::ops::Deref for PayloadCredentialId {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<PayloadCredentialId> for ::std::string::String {
fn from(value: PayloadCredentialId) -> Self {
value.0
}
}
impl ::std::str::FromStr for PayloadCredentialId {
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 PayloadCredentialId {
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 PayloadCredentialId {
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 PayloadCredentialId {
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 PayloadCredentialId {
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 DID the new verificationMethod is to be added to. MUST match the DID bound to `ceremonyId` at challenge time — a mismatch is rejected as a cross-DID replay.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "The DID the new verificationMethod is to be added to. MUST match the DID bound to `ceremonyId` at challenge time — a mismatch is rejected as a cross-DID replay.",
/// "type": "string",
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct PayloadDid(::std::string::String);
impl ::std::ops::Deref for PayloadDid {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<PayloadDid> for ::std::string::String {
fn from(value: PayloadDid) -> Self {
value.0
}
}
impl ::std::str::FromStr for PayloadDid {
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 PayloadDid {
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 PayloadDid {
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 PayloadDid {
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 PayloadDid {
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())
})
}
}
///Optional operator-supplied label (e.g. "MacBook Touch ID"), carried through to the published verificationMethod.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "Optional operator-supplied label (e.g. \"MacBook Touch ID\"), carried through to the published verificationMethod.",
/// "type": "string",
/// "maxLength": 128,
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct PayloadLabel(::std::string::String);
impl ::std::ops::Deref for PayloadLabel {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<PayloadLabel> for ::std::string::String {
fn from(value: PayloadLabel) -> Self {
value.0
}
}
impl ::std::str::FromStr for PayloadLabel {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 128usize {
return Err("longer than 128 characters".into());
}
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for PayloadLabel {
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 PayloadLabel {
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 PayloadLabel {
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 PayloadLabel {
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())
})
}
}
///Browser-computed W3C Multikey for the credential public key. ADVISORY: the VTA re-derives the Multikey from `attestationObject.authData` and rejects this submission if the values differ (anti-tamper gate). The re-derived key — not this one — is what gets published.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "Browser-computed W3C Multikey for the credential public key. ADVISORY: the VTA re-derives the Multikey from `attestationObject.authData` and rejects this submission if the values differ (anti-tamper gate). The re-derived key — not this one — is what gets published.",
/// "type": "string",
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct PayloadPublicKeyMultibase(::std::string::String);
impl ::std::ops::Deref for PayloadPublicKeyMultibase {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<PayloadPublicKeyMultibase> for ::std::string::String {
fn from(value: PayloadPublicKeyMultibase) -> Self {
value.0
}
}
impl ::std::str::FromStr for PayloadPublicKeyMultibase {
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 PayloadPublicKeyMultibase {
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 PayloadPublicKeyMultibase {
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 PayloadPublicKeyMultibase {
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 PayloadPublicKeyMultibase {
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())
})
}
}
///Successful enrolment. The verificationMethod has already been appended to the DID document via a WebVH log entry at the returned version.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "Response",
/// "description": "Successful enrolment. The verificationMethod has already been appended to the DID document via a WebVH log entry at the returned version.",
/// "type": "object",
/// "required": [
/// "verificationMethod",
/// "webvhVersion"
/// ],
/// "properties": {
/// "ext": {
/// "description": "Ecosystem-defined extension members per SPEC.md §4.5.1.",
/// "$ref": "#/definitions/Ext"
/// },
/// "verificationMethod": {
/// "description": "The verificationMethod entry exactly as it now appears in the DID document. `publicKeyMultibase` here is the server-re-derived key, which is authoritative.",
/// "$ref": "#/definitions/PasskeyVerificationMethod"
/// },
/// "webvhVersion": {
/// "description": "The WebVH log-entry version that recorded the change (e.g. \"3-Qm…\").",
/// "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 {
///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>,
///The verificationMethod entry exactly as it now appears in the DID document. `publicKeyMultibase` here is the server-re-derived key, which is authoritative.
#[serde(rename = "verificationMethod")]
pub verification_method: PasskeyVerificationMethod,
///The WebVH log-entry version that recorded the change (e.g. "3-Qm…").
#[serde(rename = "webvhVersion")]
pub webvh_version: ResponseWebvhVersion,
}
impl Response {
pub fn builder() -> builder::Response {
Default::default()
}
}
///The WebVH log-entry version that recorded the change (e.g. "3-Qm…").
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "The WebVH log-entry version that recorded the change (e.g. \"3-Qm…\").",
/// "type": "string",
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct ResponseWebvhVersion(::std::string::String);
impl ::std::ops::Deref for ResponseWebvhVersion {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<ResponseWebvhVersion> for ::std::string::String {
fn from(value: ResponseWebvhVersion) -> Self {
value.0
}
}
impl ::std::str::FromStr for ResponseWebvhVersion {
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 ResponseWebvhVersion {
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 ResponseWebvhVersion {
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 ResponseWebvhVersion {
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 ResponseWebvhVersion {
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 PasskeyVerificationMethod {
controller: ::std::result::Result<
super::PasskeyVerificationMethodController,
::std::string::String,
>,
id: ::std::result::Result<super::PasskeyVerificationMethodId, ::std::string::String>,
label: ::std::result::Result<
::std::option::Option<super::PasskeyVerificationMethodLabel>,
::std::string::String,
>,
public_key_multibase: ::std::result::Result<
super::PasskeyVerificationMethodPublicKeyMultibase,
::std::string::String,
>,
type_: ::std::result::Result<::std::string::String, ::std::string::String>,
webauthn_credential_id: ::std::result::Result<
super::PasskeyVerificationMethodWebauthnCredentialId,
::std::string::String,
>,
webauthn_transports: ::std::result::Result<
::std::option::Option<Vec<::std::string::String>>,
::std::string::String,
>,
}
impl ::std::default::Default for PasskeyVerificationMethod {
fn default() -> Self {
Self {
controller: Err("no value supplied for controller".to_string()),
id: Err("no value supplied for id".to_string()),
label: Ok(Default::default()),
public_key_multibase: Err("no value supplied for public_key_multibase".to_string()),
type_: Err("no value supplied for type_".to_string()),
webauthn_credential_id: Err(
"no value supplied for webauthn_credential_id".to_string()
),
webauthn_transports: Ok(Default::default()),
}
}
}
impl PasskeyVerificationMethod {
pub fn controller<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::PasskeyVerificationMethodController>,
T::Error: ::std::fmt::Display,
{
self.controller = value
.try_into()
.map_err(|e| format!("error converting supplied value for controller: {e}"));
self
}
pub fn id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::PasskeyVerificationMethodId>,
T::Error: ::std::fmt::Display,
{
self.id = value
.try_into()
.map_err(|e| format!("error converting supplied value for id: {e}"));
self
}
pub fn label<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::option::Option<super::PasskeyVerificationMethodLabel>,
>,
T::Error: ::std::fmt::Display,
{
self.label = value
.try_into()
.map_err(|e| format!("error converting supplied value for label: {e}"));
self
}
pub fn public_key_multibase<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::PasskeyVerificationMethodPublicKeyMultibase>,
T::Error: ::std::fmt::Display,
{
self.public_key_multibase = value.try_into().map_err(|e| {
format!("error converting supplied value for public_key_multibase: {e}")
});
self
}
pub fn type_<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::string::String>,
T::Error: ::std::fmt::Display,
{
self.type_ = value
.try_into()
.map_err(|e| format!("error converting supplied value for type_: {e}"));
self
}
pub fn webauthn_credential_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::PasskeyVerificationMethodWebauthnCredentialId>,
T::Error: ::std::fmt::Display,
{
self.webauthn_credential_id = value.try_into().map_err(|e| {
format!("error converting supplied value for webauthn_credential_id: {e}")
});
self
}
pub fn webauthn_transports<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<Vec<::std::string::String>>>,
T::Error: ::std::fmt::Display,
{
self.webauthn_transports = value.try_into().map_err(|e| {
format!("error converting supplied value for webauthn_transports: {e}")
});
self
}
}
impl ::std::convert::TryFrom<PasskeyVerificationMethod> for super::PasskeyVerificationMethod {
type Error = super::error::ConversionError;
fn try_from(
value: PasskeyVerificationMethod,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
controller: value.controller?,
id: value.id?,
label: value.label?,
public_key_multibase: value.public_key_multibase?,
type_: value.type_?,
webauthn_credential_id: value.webauthn_credential_id?,
webauthn_transports: value.webauthn_transports?,
})
}
}
impl ::std::convert::From<super::PasskeyVerificationMethod> for PasskeyVerificationMethod {
fn from(value: super::PasskeyVerificationMethod) -> Self {
Self {
controller: Ok(value.controller),
id: Ok(value.id),
label: Ok(value.label),
public_key_multibase: Ok(value.public_key_multibase),
type_: Ok(value.type_),
webauthn_credential_id: Ok(value.webauthn_credential_id),
webauthn_transports: Ok(value.webauthn_transports),
}
}
}
#[derive(Clone, Debug)]
pub struct Payload {
attestation_object:
::std::result::Result<super::PayloadAttestationObject, ::std::string::String>,
authenticator_data:
::std::result::Result<super::PayloadAuthenticatorData, ::std::string::String>,
ceremony_id: ::std::result::Result<super::PayloadCeremonyId, ::std::string::String>,
client_data_json:
::std::result::Result<super::PayloadClientDataJson, ::std::string::String>,
cose_algorithm: ::std::result::Result<i64, ::std::string::String>,
credential_id: ::std::result::Result<super::PayloadCredentialId, ::std::string::String>,
did: ::std::result::Result<super::PayloadDid, ::std::string::String>,
ext: ::std::result::Result<::std::option::Option<super::Ext>, ::std::string::String>,
label: ::std::result::Result<
::std::option::Option<super::PayloadLabel>,
::std::string::String,
>,
public_key_multibase:
::std::result::Result<super::PayloadPublicKeyMultibase, ::std::string::String>,
transports: ::std::result::Result<
::std::option::Option<Vec<::std::string::String>>,
::std::string::String,
>,
}
impl ::std::default::Default for Payload {
fn default() -> Self {
Self {
attestation_object: Err("no value supplied for attestation_object".to_string()),
authenticator_data: Err("no value supplied for authenticator_data".to_string()),
ceremony_id: Err("no value supplied for ceremony_id".to_string()),
client_data_json: Err("no value supplied for client_data_json".to_string()),
cose_algorithm: Err("no value supplied for cose_algorithm".to_string()),
credential_id: Err("no value supplied for credential_id".to_string()),
did: Err("no value supplied for did".to_string()),
ext: Ok(Default::default()),
label: Ok(Default::default()),
public_key_multibase: Err("no value supplied for public_key_multibase".to_string()),
transports: Ok(Default::default()),
}
}
}
impl Payload {
pub fn attestation_object<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::PayloadAttestationObject>,
T::Error: ::std::fmt::Display,
{
self.attestation_object = value.try_into().map_err(|e| {
format!("error converting supplied value for attestation_object: {e}")
});
self
}
pub fn authenticator_data<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::PayloadAuthenticatorData>,
T::Error: ::std::fmt::Display,
{
self.authenticator_data = value.try_into().map_err(|e| {
format!("error converting supplied value for authenticator_data: {e}")
});
self
}
pub fn ceremony_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::PayloadCeremonyId>,
T::Error: ::std::fmt::Display,
{
self.ceremony_id = value
.try_into()
.map_err(|e| format!("error converting supplied value for ceremony_id: {e}"));
self
}
pub fn client_data_json<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::PayloadClientDataJson>,
T::Error: ::std::fmt::Display,
{
self.client_data_json = value
.try_into()
.map_err(|e| format!("error converting supplied value for client_data_json: {e}"));
self
}
pub fn cose_algorithm<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<i64>,
T::Error: ::std::fmt::Display,
{
self.cose_algorithm = value
.try_into()
.map_err(|e| format!("error converting supplied value for cose_algorithm: {e}"));
self
}
pub fn credential_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::PayloadCredentialId>,
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 did<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::PayloadDid>,
T::Error: ::std::fmt::Display,
{
self.did = value
.try_into()
.map_err(|e| format!("error converting supplied value for did: {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 label<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::PayloadLabel>>,
T::Error: ::std::fmt::Display,
{
self.label = value
.try_into()
.map_err(|e| format!("error converting supplied value for label: {e}"));
self
}
pub fn public_key_multibase<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::PayloadPublicKeyMultibase>,
T::Error: ::std::fmt::Display,
{
self.public_key_multibase = value.try_into().map_err(|e| {
format!("error converting supplied value for public_key_multibase: {e}")
});
self
}
pub fn transports<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<Vec<::std::string::String>>>,
T::Error: ::std::fmt::Display,
{
self.transports = value
.try_into()
.map_err(|e| format!("error converting supplied value for transports: {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 {
attestation_object: value.attestation_object?,
authenticator_data: value.authenticator_data?,
ceremony_id: value.ceremony_id?,
client_data_json: value.client_data_json?,
cose_algorithm: value.cose_algorithm?,
credential_id: value.credential_id?,
did: value.did?,
ext: value.ext?,
label: value.label?,
public_key_multibase: value.public_key_multibase?,
transports: value.transports?,
})
}
}
impl ::std::convert::From<super::Payload> for Payload {
fn from(value: super::Payload) -> Self {
Self {
attestation_object: Ok(value.attestation_object),
authenticator_data: Ok(value.authenticator_data),
ceremony_id: Ok(value.ceremony_id),
client_data_json: Ok(value.client_data_json),
cose_algorithm: Ok(value.cose_algorithm),
credential_id: Ok(value.credential_id),
did: Ok(value.did),
ext: Ok(value.ext),
label: Ok(value.label),
public_key_multibase: Ok(value.public_key_multibase),
transports: Ok(value.transports),
}
}
}
#[derive(Clone, Debug)]
pub struct Response {
ext: ::std::result::Result<::std::option::Option<super::Ext>, ::std::string::String>,
verification_method:
::std::result::Result<super::PasskeyVerificationMethod, ::std::string::String>,
webvh_version: ::std::result::Result<super::ResponseWebvhVersion, ::std::string::String>,
}
impl ::std::default::Default for Response {
fn default() -> Self {
Self {
ext: Ok(Default::default()),
verification_method: Err("no value supplied for verification_method".to_string()),
webvh_version: Err("no value supplied for webvh_version".to_string()),
}
}
}
impl Response {
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 verification_method<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::PasskeyVerificationMethod>,
T::Error: ::std::fmt::Display,
{
self.verification_method = value.try_into().map_err(|e| {
format!("error converting supplied value for verification_method: {e}")
});
self
}
pub fn webvh_version<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ResponseWebvhVersion>,
T::Error: ::std::fmt::Display,
{
self.webvh_version = value
.try_into()
.map_err(|e| format!("error converting supplied value for webvh_version: {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 {
ext: value.ext?,
verification_method: value.verification_method?,
webvh_version: value.webvh_version?,
})
}
}
impl ::std::convert::From<super::Response> for Response {
fn from(value: super::Response) -> Self {
Self {
ext: Ok(value.ext),
verification_method: Ok(value.verification_method),
webvh_version: Ok(value.webvh_version),
}
}
}
}
impl crate::Payload for Payload {
const TYPE_URI: &'static str = "https://trusttasks.org/spec/vta/passkey-vms/enroll-submit/0.1";
const IS_PROOF_REQUIRED: bool = true;
const IS_ISSUED_AT_REQUIRED: bool = true;
const IS_RECIPIENT_REQUIRED: bool = true;
const PAYLOAD_SCHEMA: Option<&'static str> = Some(
"{\n \"$defs\": {\n \"Ext\": {\n \"additionalProperties\": true,\n \"description\": \"Vendor-namespaced extension object per SPEC.md §4.5.1. Each immediate key MUST be a reverse-DNS namespace; structure under each namespace is opaque to the framework.\",\n \"minProperties\": 1,\n \"propertyNames\": {\n \"pattern\": \"^[a-z][a-z0-9-]*(\\\\.[a-z0-9-]+)+$\"\n },\n \"title\": \"Ext\",\n \"type\": \"object\"\n },\n \"PasskeyVerificationMethod\": {\n \"additionalProperties\": false,\n \"properties\": {\n \"controller\": {\n \"description\": \"The DID this verificationMethod is published on (the DID being augmented).\",\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"id\": {\n \"description\": \"The verificationMethod id as it appears in the DID document: `<did>#passkey-<base64url(sha256(credentialId))>`. The fragment is content-derived so a verifier can locate this VM by recomputing `sha256(credential.id)`.\",\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"label\": {\n \"description\": \"Optional operator-supplied human-readable label (e.g. \\\"MacBook Touch ID\\\"). Informational; not authoritative and not a security input.\",\n \"maxLength\": 128,\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"publicKeyMultibase\": {\n \"description\": \"W3C Multikey (multibase) encoding of the WebAuthn credential public key. This is the value a verifier validates a WebAuthn assertion against. Re-derived server-side from the attestation at enrolment — never trusted from the browser (see vta/passkey-vms/enroll-submit).\",\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"type\": {\n \"const\": \"Multikey\",\n \"description\": \"Always `Multikey`. The WebAuthn public key is published in W3C Multikey form so DID resolvers and verifiers need no WebAuthn-specific knowledge to consume it.\",\n \"type\": \"string\"\n },\n \"webauthnCredentialId\": {\n \"description\": \"The WebAuthn `credential.id` (base64url, no padding). Lets a verifier recompute `sha256(credentialId)` and match the assertion to this VM's `id` fragment.\",\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"webauthnTransports\": {\n \"description\": \"Transport hints reported by the authenticator (e.g. `internal`, `hybrid`, `usb`, `nfc`, `ble`). Advisory only — verifiers MUST NOT make trust decisions based on transport hints.\",\n \"items\": {\n \"type\": \"string\"\n },\n \"type\": \"array\",\n \"uniqueItems\": true\n }\n },\n \"required\": [\n \"id\",\n \"type\",\n \"controller\",\n \"publicKeyMultibase\",\n \"webauthnCredentialId\"\n ],\n \"title\": \"PasskeyVerificationMethod\",\n \"type\": \"object\"\n },\n \"Response\": {\n \"$anchor\": \"response\",\n \"additionalProperties\": false,\n \"description\": \"Successful enrolment. The verificationMethod has already been appended to the DID document via a WebVH log entry at the returned version.\",\n \"properties\": {\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\",\n \"description\": \"Ecosystem-defined extension members per SPEC.md §4.5.1.\"\n },\n \"verificationMethod\": {\n \"$ref\": \"#/$defs/PasskeyVerificationMethod\",\n \"description\": \"The verificationMethod entry exactly as it now appears in the DID document. `publicKeyMultibase` here is the server-re-derived key, which is authoritative.\"\n },\n \"webvhVersion\": {\n \"description\": \"The WebVH log-entry version that recorded the change (e.g. \\\"3-Qm…\\\").\",\n \"minLength\": 1,\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"verificationMethod\",\n \"webvhVersion\"\n ],\n \"title\": \"VTA Passkey-VM Enroll Submit — response payload\",\n \"type\": \"object\"\n }\n },\n \"$id\": \"https://trusttasks.org/spec/vta/passkey-vms/enroll-submit/0.1\",\n \"$schema\": \"https://json-schema.org/draft/2020-12/schema\",\n \"additionalProperties\": false,\n \"description\": \"Finalise passkey enrolment by submitting the WebAuthn registration result for a ceremony opened by vta/passkey-vms/enroll-challenge. The VTA re-derives the Multikey from attestationObject.authData and rejects on mismatch with the browser-claimed publicKeyMultibase — the browser's value is NOT trusted as authoritative. On success the VTA appends the verificationMethod to the DID document via a WebVH log entry. All byte-valued fields are base64url-encoded (no padding).\",\n \"properties\": {\n \"attestationObject\": {\n \"description\": \"Raw WebAuthn `attestationObject` — base64url-encoded CBOR. The VTA parses `authData` from this to re-derive the authoritative public key.\",\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"authenticatorData\": {\n \"description\": \"Raw WebAuthn `authenticatorData` (base64url, no padding).\",\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"ceremonyId\": {\n \"description\": \"The `ceremonyId` returned by vta/passkey-vms/enroll-challenge. Single-use; consumed by this submission.\",\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"clientDataJson\": {\n \"description\": \"Raw WebAuthn `clientDataJSON` (base64url, no padding). Bound to the ceremony `challenge` during WebAuthn verification.\",\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"coseAlgorithm\": {\n \"description\": \"COSE algorithm identifier of the credential key (e.g. -7 for ES256, -8 for EdDSA). Must be an algorithm the VTA can convert to a Multikey.\",\n \"type\": \"integer\"\n },\n \"credentialId\": {\n \"description\": \"WebAuthn `credential.id` (base64url, no padding). The published verificationMethod `id` fragment is derived as `passkey-<base64url(sha256(credentialId))>`.\",\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"did\": {\n \"description\": \"The DID the new verificationMethod is to be added to. MUST match the DID bound to `ceremonyId` at challenge time — a mismatch is rejected as a cross-DID replay.\",\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 \"label\": {\n \"description\": \"Optional operator-supplied label (e.g. \\\"MacBook Touch ID\\\"), carried through to the published verificationMethod.\",\n \"maxLength\": 128,\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"publicKeyMultibase\": {\n \"description\": \"Browser-computed W3C Multikey for the credential public key. ADVISORY: the VTA re-derives the Multikey from `attestationObject.authData` and rejects this submission if the values differ (anti-tamper gate). The re-derived key — not this one — is what gets published.\",\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"transports\": {\n \"description\": \"Transport hints reported by the authenticator (e.g. `internal`, `hybrid`). Advisory; carried through to the published verificationMethod's `webauthnTransports`.\",\n \"items\": {\n \"type\": \"string\"\n },\n \"type\": \"array\",\n \"uniqueItems\": true\n }\n },\n \"required\": [\n \"did\",\n \"ceremonyId\",\n \"credentialId\",\n \"publicKeyMultibase\",\n \"coseAlgorithm\",\n \"attestationObject\",\n \"clientDataJson\",\n \"authenticatorData\"\n ],\n \"title\": \"VTA Passkey-VM Enroll Submit — payload\",\n \"type\": \"object\"\n}\n",
);
}
impl crate::Payload for Response {
const TYPE_URI: &'static str =
"https://trusttasks.org/spec/vta/passkey-vms/enroll-submit/0.1#response";
const IS_PROOF_REQUIRED: bool = true;
const IS_ISSUED_AT_REQUIRED: bool = true;
const IS_RECIPIENT_REQUIRED: bool = true;
const PAYLOAD_SCHEMA: Option<&'static str> = Some(
"{\n \"$defs\": {\n \"Ext\": {\n \"additionalProperties\": true,\n \"description\": \"Vendor-namespaced extension object per SPEC.md §4.5.1. Each immediate key MUST be a reverse-DNS namespace; structure under each namespace is opaque to the framework.\",\n \"minProperties\": 1,\n \"propertyNames\": {\n \"pattern\": \"^[a-z][a-z0-9-]*(\\\\.[a-z0-9-]+)+$\"\n },\n \"title\": \"Ext\",\n \"type\": \"object\"\n },\n \"PasskeyVerificationMethod\": {\n \"additionalProperties\": false,\n \"properties\": {\n \"controller\": {\n \"description\": \"The DID this verificationMethod is published on (the DID being augmented).\",\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"id\": {\n \"description\": \"The verificationMethod id as it appears in the DID document: `<did>#passkey-<base64url(sha256(credentialId))>`. The fragment is content-derived so a verifier can locate this VM by recomputing `sha256(credential.id)`.\",\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"label\": {\n \"description\": \"Optional operator-supplied human-readable label (e.g. \\\"MacBook Touch ID\\\"). Informational; not authoritative and not a security input.\",\n \"maxLength\": 128,\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"publicKeyMultibase\": {\n \"description\": \"W3C Multikey (multibase) encoding of the WebAuthn credential public key. This is the value a verifier validates a WebAuthn assertion against. Re-derived server-side from the attestation at enrolment — never trusted from the browser (see vta/passkey-vms/enroll-submit).\",\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"type\": {\n \"const\": \"Multikey\",\n \"description\": \"Always `Multikey`. The WebAuthn public key is published in W3C Multikey form so DID resolvers and verifiers need no WebAuthn-specific knowledge to consume it.\",\n \"type\": \"string\"\n },\n \"webauthnCredentialId\": {\n \"description\": \"The WebAuthn `credential.id` (base64url, no padding). Lets a verifier recompute `sha256(credentialId)` and match the assertion to this VM's `id` fragment.\",\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"webauthnTransports\": {\n \"description\": \"Transport hints reported by the authenticator (e.g. `internal`, `hybrid`, `usb`, `nfc`, `ble`). Advisory only — verifiers MUST NOT make trust decisions based on transport hints.\",\n \"items\": {\n \"type\": \"string\"\n },\n \"type\": \"array\",\n \"uniqueItems\": true\n }\n },\n \"required\": [\n \"id\",\n \"type\",\n \"controller\",\n \"publicKeyMultibase\",\n \"webauthnCredentialId\"\n ],\n \"title\": \"PasskeyVerificationMethod\",\n \"type\": \"object\"\n },\n \"Response\": {\n \"$anchor\": \"response\",\n \"additionalProperties\": false,\n \"description\": \"Successful enrolment. The verificationMethod has already been appended to the DID document via a WebVH log entry at the returned version.\",\n \"properties\": {\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\",\n \"description\": \"Ecosystem-defined extension members per SPEC.md §4.5.1.\"\n },\n \"verificationMethod\": {\n \"$ref\": \"#/$defs/PasskeyVerificationMethod\",\n \"description\": \"The verificationMethod entry exactly as it now appears in the DID document. `publicKeyMultibase` here is the server-re-derived key, which is authoritative.\"\n },\n \"webvhVersion\": {\n \"description\": \"The WebVH log-entry version that recorded the change (e.g. \\\"3-Qm…\\\").\",\n \"minLength\": 1,\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"verificationMethod\",\n \"webvhVersion\"\n ],\n \"title\": \"VTA Passkey-VM Enroll Submit — 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::UNKNOWN_CEREMONY,
error_codes::CEREMONY_DID_MISMATCH,
error_codes::INVALID_ATTESTATION,
error_codes::PUBLIC_KEY_MISMATCH,
error_codes::ALREADY_ENROLLED,
];
/// 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 {
/// `vta/passkey-vms/enroll-submit:unknownCeremony`
///
/// The `ceremonyId` is unknown, has expired, or has already been consumed. Re-running this submission will not succeed; the producer must obtain a fresh challenge.
///
/// Declared `retryable: false`.
pub const UNKNOWN_CEREMONY: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "vta/passkey-vms/enroll-submit:unknownCeremony",
retryable: false,
};
/// `vta/passkey-vms/enroll-submit:ceremonyDidMismatch`
///
/// The submitted `did` does not match the DID bound to the ceremony at challenge time — a cross-DID replay.
///
/// Declared `retryable: false`.
pub const CEREMONY_DID_MISMATCH: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "vta/passkey-vms/enroll-submit:ceremonyDidMismatch",
retryable: false,
};
/// `vta/passkey-vms/enroll-submit:invalidAttestation`
///
/// The WebAuthn attestation could not be parsed or verified, or its credential key could not be converted to a Multikey.
///
/// Declared `retryable: false`.
pub const INVALID_ATTESTATION: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "vta/passkey-vms/enroll-submit:invalidAttestation",
retryable: false,
};
/// `vta/passkey-vms/enroll-submit:publicKeyMismatch`
///
/// The browser-supplied `publicKeyMultibase` does not match the key the VTA re-derived from `attestationObject.authData`. The browser tampered with (or miscomputed) the public key; the submission is rejected.
///
/// Declared `retryable: false`.
pub const PUBLIC_KEY_MISMATCH: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "vta/passkey-vms/enroll-submit:publicKeyMismatch",
retryable: false,
};
/// `vta/passkey-vms/enroll-submit:alreadyEnrolled`
///
/// A passkey with this `credentialId` is already enrolled on the DID (the derived verificationMethod fragment already exists).
///
/// Declared `retryable: false`.
pub const ALREADY_ENROLLED: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "vta/passkey-vms/enroll-submit:alreadyEnrolled",
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 request_example_1() {
const JSON: &str = "{\n \"id\": \"2b8d3e5c-9a43-4c12-be41-5d1f3a9c77e3\",\n \"type\": \"https://trusttasks.org/spec/vta/passkey-vms/enroll-submit/0.1\",\n \"issuer\": \"did:web:admin.example\",\n \"recipient\": \"did:web:vta.example\",\n \"issuedAt\": \"2026-05-16T10:00:30Z\",\n \"threadId\": \"0d6b1c3a-7e21-4a90-9c2f-3b9d1e7a55c1\",\n \"payload\": {\n \"did\": \"did:webvh:QmcExampleScid:example.com\",\n \"ceremonyId\": \"cer_8Q1m2n3o4p5q6r7s\",\n \"credentialId\": \"AQIDBAUGBwgJCgsMDQ4PEA\",\n \"publicKeyMultibase\": \"z6MkhaXgBZDvotDkL5257faiztiGiC2QtKLGpbnnEGta2doK\",\n \"coseAlgorithm\": -7,\n \"attestationObject\": \"o2NmbXRkbm9uZWdhdHRTdG10oGhhdXRoRGF0YVjF...\",\n \"clientDataJson\": \"eyJ0eXBlIjoid2ViYXV0aG4uY3JlYXRlIiwiY2hhbGxlbmdlIjoiazlYeTJaIn0\",\n \"authenticatorData\": \"SZYN5YgOjGh0NBcPZHZgW4_krrmihjLHmVzzuoMdl2MFAAAAAA\",\n \"transports\": [\"internal\", \"hybrid\"],\n \"label\": \"MacBook Touch ID\"\n },\n \"proof\": {\n \"type\": \"DataIntegrityProof\",\n \"cryptosuite\": \"eddsa-jcs-2022\",\n \"verificationMethod\": \"did:web:admin.example#key-1\",\n \"created\": \"2026-05-16T10:00:30Z\",\n \"proofPurpose\": \"assertionMethod\",\n \"proofValue\": \"z3kg...\"\n }\n}\n";
let doc: crate::TrustTask<super::Payload> =
serde_json::from_str(JSON).expect("deserialize request 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, "request example failed round-trip");
}
#[test]
fn response_example_1() {
const JSON: &str = "{\n \"id\": \"3c9e4f6d-0b54-4d23-cf52-6e2g4b0d88f4\",\n \"type\": \"https://trusttasks.org/spec/vta/passkey-vms/enroll-submit/0.1#response\",\n \"threadId\": \"0d6b1c3a-7e21-4a90-9c2f-3b9d1e7a55c1\",\n \"issuer\": \"did:web:vta.example\",\n \"recipient\": \"did:web:admin.example\",\n \"issuedAt\": \"2026-05-16T10:00:31Z\",\n \"payload\": {\n \"verificationMethod\": {\n \"id\": \"did:webvh:QmcExampleScid:example.com#passkey-3q2r1s0tUvWxYz\",\n \"type\": \"Multikey\",\n \"controller\": \"did:webvh:QmcExampleScid:example.com\",\n \"publicKeyMultibase\": \"z6MkhaXgBZDvotDkL5257faiztiGiC2QtKLGpbnnEGta2doK\",\n \"webauthnCredentialId\": \"AQIDBAUGBwgJCgsMDQ4PEA\",\n \"webauthnTransports\": [\"internal\", \"hybrid\"],\n \"label\": \"MacBook Touch ID\"\n },\n \"webvhVersion\": \"3-QmExampleLogEntryHash\"\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 `ceremonyId` — submission must reference the open ceremony.",
"{\n \"attestationObject\": \"o2NmbXRkbm9uZQ\",\n \"authenticatorData\": \"SZYN5YgOjGh0NBcPZHZgW4\",\n \"clientDataJson\": \"eyJ0eXBlIjoid2ViYXV0aG4uY3JlYXRlIn0\",\n \"coseAlgorithm\": -7,\n \"credentialId\": \"AQIDBAUGBwgJCgsMDQ4PEA\",\n \"did\": \"did:webvh:QmcExampleScid:example.com\",\n \"publicKeyMultibase\": \"z6MkhaXgBZDvotDkL5257faiztiGiC2QtKLGpbnnEGta2doK\"\n}",
),
(
"`coseAlgorithm` must be an integer (COSE algorithm id), not a string.",
"{\n \"attestationObject\": \"o2NmbXRkbm9uZQ\",\n \"authenticatorData\": \"SZYN5YgOjGh0NBcPZHZgW4\",\n \"ceremonyId\": \"cer_8Q1m2n3o4p5q6r7s\",\n \"clientDataJson\": \"eyJ0eXBlIjoid2ViYXV0aG4uY3JlYXRlIn0\",\n \"coseAlgorithm\": \"ES256\",\n \"credentialId\": \"AQIDBAUGBwgJCgsMDQ4PEA\",\n \"did\": \"did:webvh:QmcExampleScid:example.com\",\n \"publicKeyMultibase\": \"z6MkhaXgBZDvotDkL5257faiztiGiC2QtKLGpbnnEGta2doK\"\n}",
),
(
"Unknown top-level payload member (additionalProperties: false catches `webvhVersion` — that is a response field, never sent in the request).",
"{\n \"attestationObject\": \"o2NmbXRkbm9uZQ\",\n \"authenticatorData\": \"SZYN5YgOjGh0NBcPZHZgW4\",\n \"ceremonyId\": \"cer_8Q1m2n3o4p5q6r7s\",\n \"clientDataJson\": \"eyJ0eXBlIjoid2ViYXV0aG4uY3JlYXRlIn0\",\n \"coseAlgorithm\": -7,\n \"credentialId\": \"AQIDBAUGBwgJCgsMDQ4PEA\",\n \"did\": \"did:webvh:QmcExampleScid:example.com\",\n \"publicKeyMultibase\": \"z6MkhaXgBZDvotDkL5257faiztiGiC2QtKLGpbnnEGta2doK\",\n \"webvhVersion\": \"3-QmExample\"\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
);
}
}
}