Skip to content

Commit

Permalink
get_info: Put uncommon fields behind feature flag
Browse files Browse the repository at this point in the history
  • Loading branch information
robin-nitrokey committed Jun 21, 2024
1 parent aa1164c commit bf5736b
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []

Expand Down
22 changes: 22 additions & 0 deletions src/ctap2/get_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool>, // default false
pub rk: bool,
Expand All @@ -119,57 +120,78 @@ pub struct CtapOptions {
pub uv: Option<bool>, // default not capable
#[serde(skip_serializing_if = "Option::is_none")]
pub plat: Option<bool>, // default false
#[cfg(feature = "get-info-full")]
#[serde(skip_serializing_if = "Option::is_none")]
pub uv_acfg: Option<bool>, // default false
#[cfg(feature = "get-info-full")]
#[serde(skip_serializing_if = "Option::is_none")]
pub always_uv: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub cred_mgmt: Option<bool>,
#[cfg(feature = "get-info-full")]
#[serde(skip_serializing_if = "Option::is_none")]
pub authnr_cfg: Option<bool>,
#[cfg(feature = "get-info-full")]
#[serde(skip_serializing_if = "Option::is_none")]
pub bio_enroll: Option<bool>, // default false
#[serde(skip_serializing_if = "Option::is_none")]
pub client_pin: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub large_blobs: Option<bool>,
#[cfg(feature = "get-info-full")]
#[serde(skip_serializing_if = "Option::is_none")]
pub uv_bio_enroll: Option<bool>,
#[cfg(feature = "get-info-full")]
#[serde(rename = "setMinPINLength", skip_serializing_if = "Option::is_none")]
pub set_min_pin_length: Option<bool>, // default false
#[serde(skip_serializing_if = "Option::is_none")]
pub pin_uv_auth_token: Option<bool>,
#[cfg(feature = "get-info-full")]
#[serde(skip_serializing_if = "Option::is_none")]
pub make_cred_uv_not_rqd: Option<bool>,
#[cfg(feature = "get-info-full")]
#[serde(skip_serializing_if = "Option::is_none")]
pub credential_mgmt_preview: Option<bool>,
#[cfg(feature = "get-info-full")]
#[serde(skip_serializing_if = "Option::is_none")]
pub user_verification_mgmt_preview: Option<bool>,
#[cfg(feature = "get-info-full")]
#[serde(skip_serializing_if = "Option::is_none")]
pub no_mc_ga_permissions_with_client_pin: Option<bool>,
}

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,
}
}
Expand Down

0 comments on commit bf5736b

Please sign in to comment.