Skip to content

Commit 257ac57

Browse files
committed
fix!: change auth_delay to return u8
API BREAKING change.
1 parent 5ea2991 commit 257ac57

9 files changed

Lines changed: 21 additions & 21 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ just stop # stop emulator
7979
#### Run CLI with desktop USB PCSC NFC card reader
8080

8181
```
82-
just run --help
82+
just run -- --help
8383
just run certs
8484
just run read
8585
```

cktap-ffi/src/sats_card.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ impl SatsCard {
4848
addr: card.addr.clone(),
4949
pubkey,
5050
card_ident: card.card_ident(),
51-
auth_delay: card.auth_delay().map(|d| d as u8),
51+
auth_delay: card.auth_delay(),
5252
}
5353
}
5454

cktap-ffi/src/sats_chip.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ impl SatsChip {
3838
.map(|p| p.iter().map(|&p| p as u64).collect()),
3939
pubkey: card.pubkey().to_string(),
4040
card_ident: card.card_ident(),
41-
auth_delay: card.auth_delay().map(|d| d as u8),
41+
auth_delay: card.auth_delay(),
4242
}
4343
}
4444

cktap-ffi/src/tap_signer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ impl TapSigner {
4141
num_backups: card.num_backups.unwrap_or_default() as u64,
4242
pubkey: card.pubkey().to_string(),
4343
card_ident: card.card_ident(),
44-
auth_delay: card.auth_delay().map(|d| d as u8),
44+
auth_delay: card.auth_delay(),
4545
}
4646
}
4747

lib/src/apdu.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ pub struct StatusResponse {
132132
/// normal operation begins. If the CVC value is incorrect, the 15-second delay between
133133
/// attempts continues.
134134
#[serde(default)]
135-
pub auth_delay: Option<usize>,
135+
pub auth_delay: Option<u8>,
136136
}
137137

138138
impl ResponseApdu for StatusResponse {}
@@ -628,7 +628,7 @@ pub struct WaitResponse {
628628
success: bool,
629629
/// how much more delay is now required
630630
#[serde(default)]
631-
pub(crate) auth_delay: usize,
631+
pub(crate) auth_delay: u8,
632632
}
633633

634634
impl ResponseApdu for WaitResponse {}

lib/src/sats_card.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub struct SatsCard {
3232
pub addr: Option<String>,
3333
pub pubkey: PublicKey,
3434
pub card_nonce: [u8; 16],
35-
pub auth_delay: Option<usize>,
35+
pub auth_delay: Option<u8>,
3636
}
3737

3838
impl Authentication for SatsCard {
@@ -56,11 +56,11 @@ impl Authentication for SatsCard {
5656
self.card_nonce = new_nonce;
5757
}
5858

59-
fn auth_delay(&self) -> &Option<usize> {
60-
&self.auth_delay
59+
fn auth_delay(&self) -> Option<u8> {
60+
self.auth_delay
6161
}
6262

63-
fn set_auth_delay(&mut self, auth_delay: Option<usize>) {
63+
fn set_auth_delay(&mut self, auth_delay: Option<u8>) {
6464
self.auth_delay = auth_delay;
6565
}
6666

lib/src/sats_chip.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub struct SatsChip {
2828
pub num_backups: Option<usize>,
2929
pub pubkey: PublicKey,
3030
pub card_nonce: [u8; 16],
31-
pub auth_delay: Option<usize>,
31+
pub auth_delay: Option<u8>,
3232
}
3333

3434
impl Authentication for SatsChip {
@@ -52,11 +52,11 @@ impl Authentication for SatsChip {
5252
self.card_nonce = new_nonce;
5353
}
5454

55-
fn auth_delay(&self) -> &Option<usize> {
56-
&self.auth_delay
55+
fn auth_delay(&self) -> Option<u8> {
56+
self.auth_delay
5757
}
5858

59-
fn set_auth_delay(&mut self, auth_delay: Option<usize>) {
59+
fn set_auth_delay(&mut self, auth_delay: Option<u8>) {
6060
self.auth_delay = auth_delay;
6161
}
6262

lib/src/shared.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ pub trait Authentication {
7676
fn pubkey(&self) -> &PublicKey;
7777
fn card_nonce(&self) -> &[u8; 16];
7878
fn set_card_nonce(&mut self, new_nonce: [u8; 16]);
79-
fn auth_delay(&self) -> &Option<usize>;
80-
fn set_auth_delay(&mut self, auth_delay: Option<usize>);
79+
fn auth_delay(&self) -> Option<u8>;
80+
fn set_auth_delay(&mut self, auth_delay: Option<u8>);
8181
fn transport(&self) -> Arc<dyn CkTransport>;
8282
fn card_ident(&self) -> String {
8383
card_pubkey_to_ident(self.pubkey())
@@ -244,7 +244,7 @@ pub trait Read: Authentication {
244244

245245
#[async_trait]
246246
pub trait Wait: Authentication {
247-
async fn wait(&mut self, cvc: Option<String>) -> Result<Option<usize>, CkTapError> {
247+
async fn wait(&mut self, cvc: Option<String>) -> Result<Option<u8>, CkTapError> {
248248
let epubkey_xcvc = cvc.map(|cvc| {
249249
let (_, epubkey, xcvc) = self.calc_ekeys_xcvc(&cvc, WaitCommand::name());
250250
(epubkey, xcvc)

lib/src/tap_signer.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ pub struct TapSigner {
3838
pub num_backups: Option<usize>,
3939
pub pubkey: PublicKey,
4040
pub card_nonce: [u8; 16],
41-
pub auth_delay: Option<usize>,
41+
pub auth_delay: Option<u8>,
4242
}
4343

4444
impl Authentication for TapSigner {
@@ -62,11 +62,11 @@ impl Authentication for TapSigner {
6262
self.card_nonce = new_nonce;
6363
}
6464

65-
fn auth_delay(&self) -> &Option<usize> {
66-
&self.auth_delay
65+
fn auth_delay(&self) -> Option<u8> {
66+
self.auth_delay
6767
}
6868

69-
fn set_auth_delay(&mut self, auth_delay: Option<usize>) {
69+
fn set_auth_delay(&mut self, auth_delay: Option<u8>) {
7070
self.auth_delay = auth_delay;
7171
}
7272

0 commit comments

Comments
 (0)