-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from bitwarden/PM-8579-CONTRIB-PM-7720-android…
…-package-name-support Add android package name support
- Loading branch information
Showing
9 changed files
with
264 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
use serde::Serialize; | ||
|
||
/// A trait describing how client data should be generated during a WebAuthn operation. | ||
pub trait ClientData<E: Serialize> { | ||
/// Extra client data to be appended to the automatically generated client data. | ||
fn extra_client_data(&self) -> E; | ||
|
||
/// The hash of the client data to be used in the WebAuthn operation. | ||
fn client_data_hash(&self) -> Option<Vec<u8>>; | ||
} | ||
|
||
/// The client data and its hash will be automatically generated from the request | ||
/// according to the WebAuthn specification. | ||
pub struct DefaultClientData; | ||
impl ClientData<()> for DefaultClientData { | ||
fn extra_client_data(&self) {} | ||
|
||
fn client_data_hash(&self) -> Option<Vec<u8>> { | ||
None | ||
} | ||
} | ||
|
||
/// The extra client data will be appended to the automatically generated client data. | ||
/// The hash will be automatically generated from the result client data according to the WebAuthn specification. | ||
pub struct DefaultClientDataWithExtra<E: Serialize>(pub E); | ||
impl<E: Serialize + Clone> ClientData<E> for DefaultClientDataWithExtra<E> { | ||
fn extra_client_data(&self) -> E { | ||
self.0.clone() | ||
} | ||
fn client_data_hash(&self) -> Option<Vec<u8>> { | ||
None | ||
} | ||
} | ||
|
||
/// The client data will be automatically generated from the request according to the WebAuthn specification | ||
/// but it will not be used as a base for the hash. The client data hash will instead be provided by the caller. | ||
pub struct DefaultClientDataWithCustomHash(pub Vec<u8>); | ||
impl ClientData<()> for DefaultClientDataWithCustomHash { | ||
fn extra_client_data(&self) {} | ||
|
||
fn client_data_hash(&self) -> Option<Vec<u8>> { | ||
Some(self.0.clone()) | ||
} | ||
} | ||
|
||
/// Backwards compatibility with the previous `register` and `authenticate` functions | ||
/// which only took `Option<Vec<u8>>` as a client data hash. | ||
impl ClientData<()> for Option<Vec<u8>> { | ||
fn extra_client_data(&self) {} | ||
|
||
fn client_data_hash(&self) -> Option<Vec<u8>> { | ||
self.clone() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.