diff --git a/app/src/main/java/com/x8bit/bitwarden/data/platform/manager/model/SpecialCircumstance.kt b/app/src/main/java/com/x8bit/bitwarden/data/platform/manager/model/SpecialCircumstance.kt index fcc08885fc3..fe6352bbac8 100644 --- a/app/src/main/java/com/x8bit/bitwarden/data/platform/manager/model/SpecialCircumstance.kt +++ b/app/src/main/java/com/x8bit/bitwarden/data/platform/manager/model/SpecialCircumstance.kt @@ -104,7 +104,7 @@ sealed class SpecialCircumstance : Parcelable { */ @Parcelize data class PasswordAssertion( - val passwordAssertionRequest: PasswordCredentialAssertionRequest, + val passwordCredentialAssertionRequest: PasswordCredentialAssertionRequest, ) : SpecialCircumstance() /** diff --git a/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/rootnav/RootNavScreen.kt b/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/rootnav/RootNavScreen.kt index 4bb22e3fa86..484be7fade6 100644 --- a/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/rootnav/RootNavScreen.kt +++ b/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/rootnav/RootNavScreen.kt @@ -126,6 +126,9 @@ fun RootNavScreen( is RootNavState.VaultUnlockedForFido2Save, is RootNavState.VaultUnlockedForFido2Assertion, is RootNavState.VaultUnlockedForFido2GetCredentials, + is RootNavState.VaultUnlockedForPasswordSave, + is RootNavState.VaultUnlockedForPasswordAssertion, + is RootNavState.VaultUnlockedForPasswordGetCredentials, -> VAULT_UNLOCKED_GRAPH_ROUTE RootNavState.OnboardingAccountLockSetup -> SETUP_UNLOCK_AS_ROOT_ROUTE @@ -243,6 +246,17 @@ fun RootNavScreen( ) } + is RootNavState.VaultUnlockedForPasswordSave, + is RootNavState.VaultUnlockedForPasswordAssertion, + is RootNavState.VaultUnlockedForPasswordGetCredentials, + -> { + navController.navigateToVaultUnlockedGraph(rootNavOptions) + navController.navigateToVaultItemListingAsRoot( + vaultItemListingType = VaultItemListingType.Login, + navOptions = rootNavOptions, + ) + } + RootNavState.OnboardingAccountLockSetup -> { navController.navigateToSetupUnlockScreenAsRoot(rootNavOptions) } diff --git a/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/rootnav/RootNavViewModel.kt b/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/rootnav/RootNavViewModel.kt index a58306fa4e9..297ec8aa0cf 100644 --- a/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/rootnav/RootNavViewModel.kt +++ b/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/rootnav/RootNavViewModel.kt @@ -12,6 +12,9 @@ import com.x8bit.bitwarden.data.autofill.fido2.model.Fido2CredentialRequest import com.x8bit.bitwarden.data.autofill.fido2.model.Fido2GetCredentialsRequest import com.x8bit.bitwarden.data.autofill.model.AutofillSaveItem import com.x8bit.bitwarden.data.autofill.model.AutofillSelectionData +import com.x8bit.bitwarden.data.autofill.password.model.PasswordCredentialAssertionRequest +import com.x8bit.bitwarden.data.autofill.password.model.PasswordCredentialRequest +import com.x8bit.bitwarden.data.autofill.password.model.PasswordGetCredentialsRequest import com.x8bit.bitwarden.data.platform.manager.SpecialCircumstanceManager import com.x8bit.bitwarden.data.platform.manager.model.SpecialCircumstance import com.x8bit.bitwarden.data.vault.datasource.network.model.OrganizationType @@ -151,9 +154,26 @@ class RootNavViewModel @Inject constructor( ) } - is SpecialCircumstance.PasswordAssertion -> TODO() - is SpecialCircumstance.PasswordGetCredentials -> TODO() - is SpecialCircumstance.PasswordSave -> TODO() + is SpecialCircumstance.PasswordSave -> { + RootNavState.VaultUnlockedForPasswordSave( + activeUserId = userState.activeUserId, + passwordCredentialRequest = specialCircumstance.passwordCredentialRequest, + ) + } + + is SpecialCircumstance.PasswordAssertion -> { + RootNavState.VaultUnlockedForPasswordAssertion( + activeUserId = userState.activeUserId, + passwordCredentialAssertionRequest = specialCircumstance.passwordCredentialAssertionRequest, + ) + } + + is SpecialCircumstance.PasswordGetCredentials -> { + RootNavState.VaultUnlockedForPasswordGetCredentials( + activeUserId = userState.activeUserId, + passwordGetCredentialsRequest = specialCircumstance.passwordGetCredentialsRequest, + ) + } SpecialCircumstance.AccountSecurityShortcut, SpecialCircumstance.GeneratorShortcut, @@ -317,6 +337,39 @@ sealed class RootNavState : Parcelable { val fido2GetCredentialsRequest: Fido2GetCredentialsRequest, ) : RootNavState() + /** + * App should show an add item screen for a user to complete the saving of data collected by + * the password credential manager framework + * + * @param activeUserId ID of the active user. Indirectly used to notify [RootNavViewModel] the + * active user has changed. + * @param passwordCredentialRequest System request containing Password credential data. + */ + @Parcelize + data class VaultUnlockedForPasswordSave( + val activeUserId: String, + val passwordCredentialRequest: PasswordCredentialRequest, + ) : RootNavState() + + /** + * App should perform Password credential assertion for the user. + */ + @Parcelize + data class VaultUnlockedForPasswordAssertion( + val activeUserId: String, + val passwordCredentialAssertionRequest: PasswordCredentialAssertionRequest, + ) : RootNavState() + + /** + * App should unlock the user's vault and retrieve Password credentials associated to the relying + * party. + */ + @Parcelize + data class VaultUnlockedForPasswordGetCredentials( + val activeUserId: String, + val passwordGetCredentialsRequest: PasswordGetCredentialsRequest, + ) : RootNavState() + /** * App should show the new verification codes listing screen for an unlocked user. */