[PM-23280] Save MasterPasswordUnlockData to local state (#5944)

This commit is contained in:
André Bispo
2025-10-02 15:48:28 +01:00
committed by GitHub
parent 874edfad69
commit 1638a20bf0
19 changed files with 359 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
package com.bitwarden.network.model
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
/**
* Represents the data used to create the kdf settings.
*/
@Serializable
data class KdfJson(
@SerialName("KdfType")
val kdfType: KdfTypeJson,
@SerialName("Iterations")
val iterations: Int,
@SerialName("Memory")
val memory: Int?,
@SerialName("Parallelism")
val parallelism: Int?,
)

View File

@@ -0,0 +1,25 @@
package com.bitwarden.network.model
import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import kotlinx.serialization.json.JsonNames
/**
* Represents the data used to unlock with the master password.
*/
@Serializable
@OptIn(ExperimentalSerializationApi::class)
data class MasterPasswordUnlockDataJson(
@SerialName("Salt")
val salt: String,
@SerialName("Kdf")
val kdf: KdfJson,
// TODO: PM-26397 this was done due to naming inconsistency server side,
// should be cleaned up when server side is updated
@SerialName("MasterKeyWrappedUserKey")
@JsonNames("MasterKeyEncryptedUserKey")
val masterKeyWrappedUserKey: String,
)

View File

@@ -48,6 +48,9 @@ data class SyncResponseJson(
@SerialName("sends")
val sends: List<Send>?,
@SerialName("UserDecryption")
val userDecryption: UserDecryptionJson?,
) {
/**
* Represents domains in the vault response.

View File

@@ -0,0 +1,13 @@
package com.bitwarden.network.model
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
/**
* Represents the user decryption options received on sync.
*/
@Serializable
data class UserDecryptionJson(
@SerialName("MasterPasswordUnlock")
val masterPasswordUnlock: MasterPasswordUnlockDataJson?,
)

View File

@@ -21,6 +21,10 @@ data class UserDecryptionOptionsJson(
@JsonNames("HasMasterPassword")
val hasMasterPassword: Boolean,
@SerialName("masterPasswordUnlock")
@JsonNames("MasterPasswordUnlock")
val masterPasswordUnlock: MasterPasswordUnlockDataJson?,
@SerialName("trustedDeviceOption")
@JsonNames("TrustedDeviceOption")
val trustedDeviceUserDecryptionOptions: TrustedDeviceUserDecryptionOptionsJson?,

View File

@@ -626,6 +626,7 @@ private val LOGIN_SUCCESS = GetTokenResponseJson.Success(
keyConnectorUserDecryptionOptions = KeyConnectorUserDecryptionOptionsJson(
keyConnectorUrl = "keyConnectorUrl",
),
masterPasswordUnlock = null,
),
keyConnectorUrl = "keyConnectorUrl",
)

View File

@@ -13,6 +13,7 @@ fun createMockSyncResponse(
policies: List<SyncResponseJson.Policy> = listOf(createMockPolicy(number = number)),
domains: SyncResponseJson.Domains = createMockDomains(number = number),
sends: List<SyncResponseJson.Send> = listOf(createMockSend(number = number)),
userDecryption: UserDecryptionJson? = null,
): SyncResponseJson =
SyncResponseJson(
folders = folders,
@@ -22,4 +23,5 @@ fun createMockSyncResponse(
policies = policies,
domains = domains,
sends = sends,
userDecryption = userDecryption,
)