Skip to content

Commit

Permalink
add RootNavState for PasswordCredential
Browse files Browse the repository at this point in the history
  • Loading branch information
Nailik committed Oct 19, 2024
1 parent ce65b7a commit 82730f4
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ sealed class SpecialCircumstance : Parcelable {
*/
@Parcelize
data class PasswordAssertion(
val passwordAssertionRequest: PasswordCredentialAssertionRequest,
val passwordCredentialAssertionRequest: PasswordCredentialAssertionRequest,
) : SpecialCircumstance()

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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.
*/
Expand Down

0 comments on commit 82730f4

Please sign in to comment.