-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Entities linked to Factor Source #302
Changes from 16 commits
666bafa
bbbf801
66c16b7
897ca57
2e751aa
31c1f3b
c327385
f562663
7fa5564
068d92b
1263959
e81710e
b6b39df
c51c7d8
fa5b6f0
46d9069
e7a80b1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
use crate::prelude::*; | ||
use sargon::EntitiesLinkedToFactorSource as InternalEntitiesLinkedToFactorSource; | ||
|
||
/// This is the result of checking what entities are controlled by a given `FactorSource`. | ||
#[derive(Clone, PartialEq, InternalConversion, uniffi::Record)] | ||
pub struct EntitiesLinkedToFactorSource { | ||
/// The integrity of the factor source. | ||
pub integrity: FactorSourceIntegrity, | ||
|
||
/// The visible accounts linked to the factor source. | ||
pub accounts: Vec<Account>, | ||
|
||
/// The hidden accounts linked to the factor source. | ||
pub hidden_accounts: Vec<Account>, | ||
|
||
/// The visible personas linked to the factor source. | ||
pub personas: Vec<Persona>, | ||
|
||
/// The hidden personas linked to the factor source. | ||
pub hidden_personas: Vec<Persona>, | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
use crate::prelude::*; | ||
use sargon::DeviceFactorSourceIntegrity as InternalDeviceFactorSourceIntegrity; | ||
|
||
/// A struct representing the integrity of a device factor source. | ||
#[derive(Clone, PartialEq, Eq, InternalConversion, uniffi::Record)] | ||
pub struct DeviceFactorSourceIntegrity { | ||
/// The factor source that is linked to the entities. | ||
pub factor_source: DeviceFactorSource, | ||
|
||
/// Whether the mnemonic of the factor source is present in keychain. | ||
pub is_mnemonic_present_in_keychain: bool, | ||
|
||
/// Whether the mnemonic of the factor source is marked as backed up. | ||
pub is_mnemonic_marked_as_backed_up: bool, | ||
} | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
use crate::prelude::*; | ||
use sargon::FactorSourceIntegrity as InternalFactorSourceIntegrity; | ||
|
||
/// An enum representing the integrity of a factor source. | ||
#[derive(Clone, PartialEq, InternalConversion, uniffi::Enum)] | ||
pub enum FactorSourceIntegrity { | ||
Device(DeviceFactorSourceIntegrity), | ||
|
||
Ledger(LedgerHardwareWalletFactorSource), | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
mod device; | ||
mod integrity; | ||
|
||
pub use device::*; | ||
pub use integrity::*; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
mod entities_linked_to_factor_source; | ||
mod integrity; | ||
mod profile_to_check; | ||
|
||
pub use entities_linked_to_factor_source::*; | ||
pub use integrity::*; | ||
pub use profile_to_check::*; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
use crate::prelude::*; | ||
use sargon::ProfileToCheck as InternalProfileToCheck; | ||
|
||
/// The Profile to which we want to check the entities linked to a factor source. | ||
#[derive(Clone, PartialEq, InternalConversion, uniffi::Enum)] | ||
#[allow(clippy::large_enum_variant)] | ||
pub enum ProfileToCheck { | ||
/// We should check against the current Profile. | ||
Current, | ||
|
||
/// We should check against a specific Profile. | ||
/// Useful when we are in the Import Mnenmonics flow. | ||
Specific(Profile), | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,11 @@ pub trait SecureStorageDriver: Send + Sync + std::fmt::Debug { | |
) -> Result<()>; | ||
|
||
async fn delete_data_for_key(&self, key: SecureStorageKey) -> Result<()>; | ||
|
||
async fn contains_data_for_key( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe a batch query would make sense? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for the current implementation we will only make the request for a given Factor Source, but I can extend it to take a set of keys instead. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @micbakos-rdx mentioned that we can check for key existence without any biometrics. |
||
&self, | ||
key: SecureStorageKey, | ||
) -> Result<bool>; | ||
} | ||
|
||
#[derive(Debug)] | ||
|
@@ -58,4 +63,14 @@ impl InternalSecureStorageDriver for SecureStorageDriverAdapter { | |
.await | ||
.into_internal_result() | ||
} | ||
|
||
async fn contains_data_for_key( | ||
&self, | ||
key: InternalSecureStorageKey, | ||
) -> InternalResult<bool> { | ||
self.wrapped | ||
.contains_data_for_key(key.into()) | ||
.await | ||
.into_internal_result() | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
use crate::prelude::*; | ||
|
||
#[uniffi::export] | ||
impl SargonOS { | ||
/// Returns the entities linked to a given `FactorSource`, either on the current `Profile` or a specific one. | ||
pub async fn entities_linked_to_factor_source( | ||
&self, | ||
factor_source: FactorSource, | ||
profile_to_check: ProfileToCheck, | ||
) -> Result<EntitiesLinkedToFactorSource> { | ||
self.wrapped | ||
.entities_linked_to_factor_source( | ||
factor_source.into_internal(), | ||
profile_to_check.into_internal(), | ||
) | ||
.await | ||
.into_result() | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am a bit lost here.first of all is this input for sargon or output that hosts will use?it's the output
what is the difference between
is_mnemonic_present_in_keychain
andis_mnemonic_marked_as_backed_up
?If
is_mnemonic_marked_as_backed_up
is true then doesn't that mean theis_mnemonic_present_in_keychain
is also true?What android has to do with the
is_mnemonic_present_in_keychain
? Or is it a boolean that just used by iOS?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is_mnemonic_marked_as_backed_up
is set to true if the user says "I have written this down".is_mnemonic_present_in_keychain
is app/sargon checking that SecureStorage at least contains a key-value tuple where the key matches the FactorSourceID of some DeviceFactorSource.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why the name has to be related to iOS though?
shouldn't be
is_mnemonic_present
or something else?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we have similar thing in Android mnemonicExist
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it should probably be
_in_secure_storage
. Not "keychain", good catch @giannis-rdxAnd @matiasbzurovski we can have a computed property in Swift Sargon called ...inKeychain, to make it clear
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated it to replace every reference to
_in_keychain
to_in_secure_stroage
.