From 257ac57bd33c5c9f13af3caf3d832c0176cb5d82 Mon Sep 17 00:00:00 2001 From: Steve Myers Date: Tue, 7 Apr 2026 12:48:48 -0500 Subject: [PATCH] fix!: change auth_delay to return u8 API BREAKING change. --- README.md | 2 +- cktap-ffi/src/sats_card.rs | 2 +- cktap-ffi/src/sats_chip.rs | 2 +- cktap-ffi/src/tap_signer.rs | 2 +- lib/src/apdu.rs | 4 ++-- lib/src/sats_card.rs | 8 ++++---- lib/src/sats_chip.rs | 8 ++++---- lib/src/shared.rs | 6 +++--- lib/src/tap_signer.rs | 8 ++++---- 9 files changed, 21 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index f1b6c72..7629bb4 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,7 @@ just stop # stop emulator #### Run CLI with desktop USB PCSC NFC card reader ``` -just run --help +just run -- --help just run certs just run read ``` diff --git a/cktap-ffi/src/sats_card.rs b/cktap-ffi/src/sats_card.rs index cea2cda..476726e 100644 --- a/cktap-ffi/src/sats_card.rs +++ b/cktap-ffi/src/sats_card.rs @@ -48,7 +48,7 @@ impl SatsCard { addr: card.addr.clone(), pubkey, card_ident: card.card_ident(), - auth_delay: card.auth_delay().map(|d| d as u8), + auth_delay: card.auth_delay(), } } diff --git a/cktap-ffi/src/sats_chip.rs b/cktap-ffi/src/sats_chip.rs index 6ffcfae..1b73d05 100644 --- a/cktap-ffi/src/sats_chip.rs +++ b/cktap-ffi/src/sats_chip.rs @@ -38,7 +38,7 @@ impl SatsChip { .map(|p| p.iter().map(|&p| p as u64).collect()), pubkey: card.pubkey().to_string(), card_ident: card.card_ident(), - auth_delay: card.auth_delay().map(|d| d as u8), + auth_delay: card.auth_delay(), } } diff --git a/cktap-ffi/src/tap_signer.rs b/cktap-ffi/src/tap_signer.rs index 7437d60..919da01 100644 --- a/cktap-ffi/src/tap_signer.rs +++ b/cktap-ffi/src/tap_signer.rs @@ -41,7 +41,7 @@ impl TapSigner { num_backups: card.num_backups.unwrap_or_default() as u64, pubkey: card.pubkey().to_string(), card_ident: card.card_ident(), - auth_delay: card.auth_delay().map(|d| d as u8), + auth_delay: card.auth_delay(), } } diff --git a/lib/src/apdu.rs b/lib/src/apdu.rs index 7fd233e..3d5eea3 100644 --- a/lib/src/apdu.rs +++ b/lib/src/apdu.rs @@ -132,7 +132,7 @@ pub struct StatusResponse { /// normal operation begins. If the CVC value is incorrect, the 15-second delay between /// attempts continues. #[serde(default)] - pub auth_delay: Option, + pub auth_delay: Option, } impl ResponseApdu for StatusResponse {} @@ -628,7 +628,7 @@ pub struct WaitResponse { success: bool, /// how much more delay is now required #[serde(default)] - pub(crate) auth_delay: usize, + pub(crate) auth_delay: u8, } impl ResponseApdu for WaitResponse {} diff --git a/lib/src/sats_card.rs b/lib/src/sats_card.rs index cd28b88..0b9fb8e 100644 --- a/lib/src/sats_card.rs +++ b/lib/src/sats_card.rs @@ -32,7 +32,7 @@ pub struct SatsCard { pub addr: Option, pub pubkey: PublicKey, pub card_nonce: [u8; 16], - pub auth_delay: Option, + pub auth_delay: Option, } impl Authentication for SatsCard { @@ -56,11 +56,11 @@ impl Authentication for SatsCard { self.card_nonce = new_nonce; } - fn auth_delay(&self) -> &Option { - &self.auth_delay + fn auth_delay(&self) -> Option { + self.auth_delay } - fn set_auth_delay(&mut self, auth_delay: Option) { + fn set_auth_delay(&mut self, auth_delay: Option) { self.auth_delay = auth_delay; } diff --git a/lib/src/sats_chip.rs b/lib/src/sats_chip.rs index 91be62a..3e1f2b1 100644 --- a/lib/src/sats_chip.rs +++ b/lib/src/sats_chip.rs @@ -28,7 +28,7 @@ pub struct SatsChip { pub num_backups: Option, pub pubkey: PublicKey, pub card_nonce: [u8; 16], - pub auth_delay: Option, + pub auth_delay: Option, } impl Authentication for SatsChip { @@ -52,11 +52,11 @@ impl Authentication for SatsChip { self.card_nonce = new_nonce; } - fn auth_delay(&self) -> &Option { - &self.auth_delay + fn auth_delay(&self) -> Option { + self.auth_delay } - fn set_auth_delay(&mut self, auth_delay: Option) { + fn set_auth_delay(&mut self, auth_delay: Option) { self.auth_delay = auth_delay; } diff --git a/lib/src/shared.rs b/lib/src/shared.rs index 0b97190..8f2a2a9 100644 --- a/lib/src/shared.rs +++ b/lib/src/shared.rs @@ -76,8 +76,8 @@ pub trait Authentication { fn pubkey(&self) -> &PublicKey; fn card_nonce(&self) -> &[u8; 16]; fn set_card_nonce(&mut self, new_nonce: [u8; 16]); - fn auth_delay(&self) -> &Option; - fn set_auth_delay(&mut self, auth_delay: Option); + fn auth_delay(&self) -> Option; + fn set_auth_delay(&mut self, auth_delay: Option); fn transport(&self) -> Arc; fn card_ident(&self) -> String { card_pubkey_to_ident(self.pubkey()) @@ -244,7 +244,7 @@ pub trait Read: Authentication { #[async_trait] pub trait Wait: Authentication { - async fn wait(&mut self, cvc: Option) -> Result, CkTapError> { + async fn wait(&mut self, cvc: Option) -> Result, CkTapError> { let epubkey_xcvc = cvc.map(|cvc| { let (_, epubkey, xcvc) = self.calc_ekeys_xcvc(&cvc, WaitCommand::name()); (epubkey, xcvc) diff --git a/lib/src/tap_signer.rs b/lib/src/tap_signer.rs index f876691..33be1b9 100644 --- a/lib/src/tap_signer.rs +++ b/lib/src/tap_signer.rs @@ -38,7 +38,7 @@ pub struct TapSigner { pub num_backups: Option, pub pubkey: PublicKey, pub card_nonce: [u8; 16], - pub auth_delay: Option, + pub auth_delay: Option, } impl Authentication for TapSigner { @@ -62,11 +62,11 @@ impl Authentication for TapSigner { self.card_nonce = new_nonce; } - fn auth_delay(&self) -> &Option { - &self.auth_delay + fn auth_delay(&self) -> Option { + self.auth_delay } - fn set_auth_delay(&mut self, auth_delay: Option) { + fn set_auth_delay(&mut self, auth_delay: Option) { self.auth_delay = auth_delay; }