From eb4ccf34a352ac36f31c842a43adb377f7324dd8 Mon Sep 17 00:00:00 2001 From: Nick Zana Date: Wed, 17 May 2023 23:17:07 -0400 Subject: [PATCH] ctap2-proto: Derive Serialize for authenticator::credential::get::Request --- .../ctap2-proto/src/authenticator/assertion/get.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/crates/ctap2-proto/src/authenticator/assertion/get.rs b/crates/ctap2-proto/src/authenticator/assertion/get.rs index 5ed231f..980b4b4 100644 --- a/crates/ctap2-proto/src/authenticator/assertion/get.rs +++ b/crates/ctap2-proto/src/authenticator/assertion/get.rs @@ -5,6 +5,9 @@ use std::{collections::BTreeMap, usize}; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; +#[cfg(feature = "serde")] +use serde_with::{serde_as, skip_serializing_none, Bytes}; + #[derive(Debug)] pub enum Error { OperationDenied, @@ -38,25 +41,34 @@ pub enum OptionKey { } /// Request parameters for [`Ctap2Device::get_assertion`] operation. +#[cfg_eval] #[derive(Debug, Clone, Copy)] +#[cfg_attr(feature = "serde", serde_as, skip_serializing_none, derive(Serialize))] pub struct Request<'a> { /// > relying party identifier + #[serde(rename = 0x01)] pub relying_party_id: &'a str, /// > Hash of the serialized client data collected by the host. + #[cfg_attr(feature = "serde", serde_as(as = "Bytes"), serde(rename = 0x02))] pub client_data_hash: &'a Sha256Hash, /// > An array of [`public_key::Descriptor`] structures, each denoting a /// > credential, as specified in `WebAuthn`... If this parameter is present /// > the authenticator MUST only generate a assertion using one of the /// > denoted credentials. // Cannot be empty if present + #[serde(rename = 0x03)] pub allow_list: Option<&'a Vec<&'a public_key::Descriptor>>, /// > Parameters to influence authenticator operation. These parameters /// > might be authenticator specific. + #[serde(rename = 0x04)] pub extensions: Option<&'a BTreeMap>, /// > Parameters to influence authenticator operation. + #[serde(rename = 0x05)] pub options: Option<&'a BTreeMap>, + #[serde(rename = 0x06)] pub pin_uv_auth_param: Option<&'a [u8]>, /// > PIN/UV protocol version selected by platform. + #[serde(rename = 0x07)] pub pin_uv_auth_protocol_version: Option, }