From c1c95bafc195db7ec90dc6a9718ff636a01fb96e Mon Sep 17 00:00:00 2001 From: Nick Zana Date: Mon, 15 May 2023 23:31:22 -0400 Subject: [PATCH] fido-common: Make extensions::Identifier de/serializable --- crates/fido-common/src/extensions.rs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/crates/fido-common/src/extensions.rs b/crates/fido-common/src/extensions.rs index dd32853..e124dfb 100644 --- a/crates/fido-common/src/extensions.rs +++ b/crates/fido-common/src/extensions.rs @@ -1,3 +1,6 @@ +#[cfg(feature = "serde")] +use serde::{Deserialize, Serialize}; + /// > Extensions are identified by a string, called an extension identifier, /// > chosen by the extension author. /// > @@ -18,22 +21,39 @@ /// > Extensions that may exist in multiple versions should take care to include /// > a version in their identifier. In effect, different versions are thus /// > treated as different extensions, e.g., `myCompany_extension_01` -#[derive(PartialEq, Eq, PartialOrd, Ord)] +#[derive(Debug, PartialEq, Eq, PartialOrd, Ord)] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub enum Identifier { + #[cfg_attr(feature = "serde", serde(rename = "appid"))] AppId, + #[cfg_attr(feature = "serde", serde(rename = "txAuthSimple"))] TransactionAuthSimple, + #[cfg_attr(feature = "serde", serde(rename = "txAuthGeneric"))] TransactionAuthGeneric, + #[cfg_attr(feature = "serde", serde(rename = "authnSel"))] AuthenticationSelection, + #[cfg_attr(feature = "serde", serde(rename = "exts"))] Extensions, + #[cfg_attr(feature = "serde", serde(rename = "uvi"))] UserVerificationIndex, + #[cfg_attr(feature = "serde", serde(rename = "loc"))] Location, + #[cfg_attr(feature = "serde", serde(rename = "uvm"))] UserVerificationMethod, + #[cfg_attr(feature = "serde", serde(rename = "credProtect"))] CredentialProtection, + #[cfg_attr(feature = "serde", serde(rename = "credBlob"))] CredentialBlob, + #[cfg_attr(feature = "serde", serde(rename = "largeBlobKey"))] LargeBlobKey, + #[cfg_attr(feature = "serde", serde(rename = "minPinLength"))] MinPinLength, + #[cfg_attr(feature = "serde", serde(rename = "hmac-secret"))] HmacSecret, + #[cfg_attr(feature = "serde", serde(rename = "appidExclude"))] AppIdExclude, + #[cfg_attr(feature = "serde", serde(rename = "credProps"))] CredentialProperties, + #[cfg_attr(feature = "serde", serde(rename = "largeBlob"))] LargeBlob, }