Skip to content

Commit b72e271

Browse files
committed
fido: Bump to latest version of passkey-rs
1 parent ec0231c commit b72e271

File tree

8 files changed

+44
-64
lines changed

8 files changed

+44
-64
lines changed

Cargo.lock

Lines changed: 19 additions & 39 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/bitwarden-fido/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ chrono = { workspace = true }
2727
coset = ">=0.3.7, <0.4"
2828
itertools = ">=0.13.0, <0.15"
2929
p256 = ">=0.13.2, <0.14"
30-
passkey = { git = "https://github.com/bitwarden/passkey-rs", rev = "3b764633ebc6576c07bdd12ee14d8e5c87b494ed" }
31-
passkey-client = { git = "https://github.com/bitwarden/passkey-rs", rev = "3b764633ebc6576c07bdd12ee14d8e5c87b494ed", features = [
30+
passkey = { git = "https://github.com/bitwarden/passkey-rs", rev = "2e5c0ba1fb60a3a6dec9c7dba175d3e07dc89862" }
31+
passkey-client = { git = "https://github.com/bitwarden/passkey-rs", rev = "2e5c0ba1fb60a3a6dec9c7dba175d3e07dc89862", features = [
3232
"android-asset-validation",
3333
] }
3434
reqwest = { workspace = true }

crates/bitwarden-fido/src/authenticator.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use bitwarden_crypto::CryptoError;
55
use bitwarden_vault::{CipherError, CipherView, EncryptionContext};
66
use itertools::Itertools;
77
use passkey::{
8-
authenticator::{Authenticator, DiscoverabilitySupport, StoreInfo, UIHint, UserCheck},
8+
authenticator::{Authenticator, DiscoverabilitySupport, StoreInfo, UiHint, UserCheck},
99
types::{
1010
Passkey,
1111
ctap2::{self, Ctap2Error, StatusCode, VendorError},
@@ -175,7 +175,7 @@ impl<'a> Fido2Authenticator<'a> {
175175
Err(e) => return Err(MakeCredentialError::Other(format!("{e:?}"))),
176176
};
177177

178-
let attestation_object = response.as_bytes().to_vec();
178+
let attestation_object = response.as_webauthn_bytes().to_vec();
179179
let authenticator_data = response.auth_data.to_vec();
180180
let attested_credential_data = response
181181
.auth_data
@@ -353,6 +353,7 @@ impl passkey::authenticator::CredentialStore for CredentialStoreImpl<'_> {
353353
&self,
354354
ids: Option<&[passkey::types::webauthn::PublicKeyCredentialDescriptor]>,
355355
rp_id: &str,
356+
_user_handle: Option<&[u8]>,
356357
) -> Result<Vec<Self::PasskeyItem>, StatusCode> {
357358
#[derive(Debug, Error)]
358359
enum InnerError {
@@ -600,7 +601,7 @@ impl passkey::authenticator::UserValidationMethod for UserValidationMethodImpl<'
600601

601602
async fn check_user<'a>(
602603
&self,
603-
hint: UIHint<'a, Self::PasskeyItem>,
604+
hint: UiHint<'a, Self::PasskeyItem>,
604605
presence: bool,
605606
_verification: bool,
606607
) -> Result<UserCheck, Ctap2Error> {
@@ -617,7 +618,7 @@ impl passkey::authenticator::UserValidationMethod for UserValidationMethodImpl<'
617618
};
618619

619620
let result = match hint {
620-
UIHint::RequestNewCredential(user, rp) => {
621+
UiHint::RequestNewCredential(user, rp) => {
621622
let new_credential = try_from_credential_new_view(user, rp)
622623
.map_err(|_| Ctap2Error::InvalidCredential)?;
623624

@@ -669,8 +670,8 @@ impl passkey::authenticator::UserValidationMethod for UserValidationMethodImpl<'
669670
}
670671
}
671672

672-
fn map_ui_hint(hint: UIHint<'_, CipherViewContainer>) -> UIHint<'_, CipherView> {
673-
use UIHint::*;
673+
fn map_ui_hint(hint: UiHint<'_, CipherViewContainer>) -> UiHint<'_, CipherView> {
674+
use UiHint::*;
674675
match hint {
675676
InformExcludedCredentialFound(c) => InformExcludedCredentialFound(&c.cipher),
676677
InformNoCredentialsFound => InformNoCredentialsFound,

crates/bitwarden-fido/src/client.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,7 @@ impl Fido2Client<'_> {
130130
cred_props: result
131131
.client_extension_results
132132
.cred_props
133-
.map(|c| CredPropsResult {
134-
rk: c.discoverable,
135-
authenticator_display_name: c.authenticator_display_name,
136-
}),
133+
.map(|c| CredPropsResult { rk: c.discoverable }),
137134
},
138135
response: AuthenticatorAssertionResponse {
139136
client_data_json: result.response.client_data_json.into(),

crates/bitwarden-fido/src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use bitwarden_vault::{
77
CipherError, CipherView, Fido2CredentialFullView, Fido2CredentialNewView, Fido2CredentialView,
88
};
99
use crypto::{CoseKeyToPkcs8Error, PrivateKeyFromSecretKeyError};
10-
use passkey::types::{Passkey, ctap2::Aaguid};
10+
use passkey::types::{CredentialExtensions, Passkey, ctap2::Aaguid};
1111

1212
#[cfg(feature = "uniffi")]
1313
uniffi::setup_scaffolding!();
@@ -26,7 +26,7 @@ pub use authenticator::{
2626
};
2727
pub use client::{Fido2Client, Fido2ClientError};
2828
pub use client_fido::{ClientFido2, ClientFido2Ext, DecryptFido2AutofillCredentialsError};
29-
pub use passkey::authenticator::UIHint;
29+
pub use passkey::authenticator::UiHint;
3030
use thiserror::Error;
3131
pub use traits::{
3232
CheckUserOptions, CheckUserResult, Fido2CallbackError, Fido2CredentialStore,
@@ -126,6 +126,7 @@ fn try_from_credential_full_view(value: Fido2CredentialFullView) -> Result<Passk
126126
rp_id: value.rp_id.clone(),
127127
user_handle: user_handle.map(|u| u.into_bytes().into()),
128128
counter,
129+
extensions: CredentialExtensions { hmac_secret: None },
129130
})
130131
}
131132

crates/bitwarden-fido/src/traits.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use bitwarden_vault::{CipherListView, CipherView, EncryptionContext, Fido2CredentialNewView};
2-
use passkey::authenticator::UIHint;
2+
use passkey::authenticator::UiHint;
33
use thiserror::Error;
44

55
#[allow(missing_docs)]
@@ -21,7 +21,7 @@ pub trait Fido2UserInterface: Send + Sync {
2121
async fn check_user<'a>(
2222
&self,
2323
options: CheckUserOptions,
24-
hint: UIHint<'a, CipherView>,
24+
hint: UiHint<'a, CipherView>,
2525
) -> Result<CheckUserResult, Fido2CallbackError>;
2626
async fn pick_credential_for_authentication(
2727
&self,
@@ -42,6 +42,7 @@ pub trait Fido2CredentialStore: Send + Sync {
4242
&self,
4343
ids: Option<Vec<Vec<u8>>>,
4444
rip_id: String,
45+
// TODO: Add user_handle
4546
) -> Result<Vec<CipherView>, Fido2CallbackError>;
4647

4748
async fn all_credentials(&self) -> Result<Vec<CipherListView>, Fido2CallbackError>;

crates/bitwarden-fido/src/types.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -370,14 +370,12 @@ pub struct ClientExtensionResults {
370370
#[cfg_attr(feature = "uniffi", derive(uniffi::Record))]
371371
pub struct CredPropsResult {
372372
pub rk: Option<bool>,
373-
pub authenticator_display_name: Option<String>,
374373
}
375374

376375
impl From<passkey::types::webauthn::CredentialPropertiesOutput> for CredPropsResult {
377376
fn from(value: passkey::types::webauthn::CredentialPropertiesOutput) -> Self {
378377
Self {
379378
rk: value.discoverable,
380-
authenticator_display_name: value.authenticator_display_name,
381379
}
382380
}
383381
}
@@ -472,9 +470,11 @@ impl TryFrom<UnverifiedAssetLink> for passkey::client::UnverifiedAssetLink<'_> {
472470
type Error = InvalidOriginError;
473471

474472
fn try_from(value: UnverifiedAssetLink) -> Result<Self, Self::Error> {
475-
let asset_link_url = match value.asset_link_url {
476-
Some(url) => Some(Url::parse(&url).map_err(|e| InvalidOriginError(format!("{e}")))?),
477-
None => None,
473+
let asset_link_url = {
474+
let url = value
475+
.asset_link_url
476+
.unwrap_or_else(|| format!("https://{}/.well-known/assetlinks.json", value.host));
477+
Url::parse(&url).map_err(|e| InvalidOriginError(e.to_string()))?
478478
};
479479

480480
passkey::client::UnverifiedAssetLink::new(

crates/bitwarden-uniffi/src/platform/fido2.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -293,9 +293,9 @@ pub enum UIHint {
293293
RequestExistingCredential(CipherView),
294294
}
295295

296-
impl From<bitwarden_fido::UIHint<'_, CipherView>> for UIHint {
297-
fn from(hint: bitwarden_fido::UIHint<'_, CipherView>) -> Self {
298-
use bitwarden_fido::UIHint as BWUIHint;
296+
impl From<bitwarden_fido::UiHint<'_, CipherView>> for UIHint {
297+
fn from(hint: bitwarden_fido::UiHint<'_, CipherView>) -> Self {
298+
use bitwarden_fido::UiHint as BWUIHint;
299299
match hint {
300300
BWUIHint::InformExcludedCredentialFound(cipher) => {
301301
UIHint::InformExcludedCredentialFound(cipher.clone())
@@ -324,7 +324,7 @@ impl bitwarden_fido::Fido2UserInterface for UniffiTraitBridge<&dyn Fido2UserInte
324324
async fn check_user<'a>(
325325
&self,
326326
options: CheckUserOptions,
327-
hint: bitwarden_fido::UIHint<'a, CipherView>,
327+
hint: bitwarden_fido::UiHint<'a, CipherView>,
328328
) -> Result<bitwarden_fido::CheckUserResult, BitFido2CallbackError> {
329329
self.0
330330
.check_user(options.clone(), hint.into())

0 commit comments

Comments
 (0)