From 114efe5dc93634df057098199d0a6528699c6e22 Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Mon, 17 Jun 2024 22:53:02 +0200 Subject: [PATCH] get_info: But uncommon fields behind feature flag --- .github/workflows/ci.yml | 1 + CHANGELOG.md | 1 + Cargo.toml | 2 ++ src/ctap2/get_info.rs | 22 ++++++++++++++++++++++ 4 files changed, 26 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b850ddc..d69e649 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,6 +16,7 @@ jobs: - name: Check library run: | cargo check + cargo check --features get-info-full cargo check --features large-blobs cargo check --all-features diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c2e338..1208f3b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Mark `get_assertion::{ExtensionsInput, ExtensionsOutput}` and `make_credential::Extensions` as non-exhaustive and implement `Default` - Mark CTAP2 request and response types as non-exhaustive where possible - Use references where possible +- Put uncommon fields in `get_info` behind `get-info-full` feature flag [#8]: https://github.com/trussed-dev/ctap-types/pull/8 [#9]: https://github.com/solokeys/ctap-types/issues/9 diff --git a/Cargo.toml b/Cargo.toml index 87e09e0..ff969b4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,6 +21,8 @@ serde_bytes = { version = "0.11.12", default-features = false } serde_repr = "0.1" [features] +# enables all fields for ctap2::get_info::CtapOptions +get-info-full = [] # enables support for implementing the large-blobs extension, see src/sizes.rs large-blobs = [] diff --git a/src/ctap2/get_info.rs b/src/ctap2/get_info.rs index 056e33c..096be8b 100644 --- a/src/ctap2/get_info.rs +++ b/src/ctap2/get_info.rs @@ -108,6 +108,7 @@ impl ResponseBuilder { #[non_exhaustive] #[serde(rename_all = "camelCase")] pub struct CtapOptions { + #[cfg(feature = "get-info-full")] #[serde(skip_serializing_if = "Option::is_none")] pub ep: Option, // default false pub rk: bool, @@ -119,32 +120,42 @@ pub struct CtapOptions { pub uv: Option, // default not capable #[serde(skip_serializing_if = "Option::is_none")] pub plat: Option, // default false + #[cfg(feature = "get-info-full")] #[serde(skip_serializing_if = "Option::is_none")] pub uv_acfg: Option, // default false + #[cfg(feature = "get-info-full")] #[serde(skip_serializing_if = "Option::is_none")] pub always_uv: Option, #[serde(skip_serializing_if = "Option::is_none")] pub cred_mgmt: Option, + #[cfg(feature = "get-info-full")] #[serde(skip_serializing_if = "Option::is_none")] pub authnr_cfg: Option, + #[cfg(feature = "get-info-full")] #[serde(skip_serializing_if = "Option::is_none")] pub bio_enroll: Option, // default false #[serde(skip_serializing_if = "Option::is_none")] pub client_pin: Option, #[serde(skip_serializing_if = "Option::is_none")] pub large_blobs: Option, + #[cfg(feature = "get-info-full")] #[serde(skip_serializing_if = "Option::is_none")] pub uv_bio_enroll: Option, + #[cfg(feature = "get-info-full")] #[serde(rename = "setMinPINLength", skip_serializing_if = "Option::is_none")] pub set_min_pin_length: Option, // default false #[serde(skip_serializing_if = "Option::is_none")] pub pin_uv_auth_token: Option, + #[cfg(feature = "get-info-full")] #[serde(skip_serializing_if = "Option::is_none")] pub make_cred_uv_not_rqd: Option, + #[cfg(feature = "get-info-full")] #[serde(skip_serializing_if = "Option::is_none")] pub credential_mgmt_preview: Option, + #[cfg(feature = "get-info-full")] #[serde(skip_serializing_if = "Option::is_none")] pub user_verification_mgmt_preview: Option, + #[cfg(feature = "get-info-full")] #[serde(skip_serializing_if = "Option::is_none")] pub no_mc_ga_permissions_with_client_pin: Option, } @@ -152,24 +163,35 @@ pub struct CtapOptions { impl Default for CtapOptions { fn default() -> Self { Self { + #[cfg(feature = "get-info-full")] ep: None, rk: false, up: true, uv: None, plat: None, + #[cfg(feature = "get-info-full")] uv_acfg: None, + #[cfg(feature = "get-info-full")] always_uv: None, cred_mgmt: None, + #[cfg(feature = "get-info-full")] authnr_cfg: None, + #[cfg(feature = "get-info-full")] bio_enroll: None, client_pin: None, large_blobs: None, + #[cfg(feature = "get-info-full")] uv_bio_enroll: None, pin_uv_auth_token: None, + #[cfg(feature = "get-info-full")] set_min_pin_length: None, + #[cfg(feature = "get-info-full")] make_cred_uv_not_rqd: None, + #[cfg(feature = "get-info-full")] credential_mgmt_preview: None, + #[cfg(feature = "get-info-full")] user_verification_mgmt_preview: None, + #[cfg(feature = "get-info-full")] no_mc_ga_permissions_with_client_pin: None, } }