BIT-765: Add additional properties to GetTokenResponseJson.Success (#136)

This commit is contained in:
Brian Yencho
2023-10-19 09:09:21 -05:00
committed by Álison Fernandes
parent 1d2f23d426
commit ab2a500607
7 changed files with 250 additions and 5 deletions

View File

@@ -10,12 +10,65 @@ sealed class GetTokenResponseJson {
/**
* Models json response of the get token request.
*
* @param accessToken the access token.
* @property accessToken The user's access token.
* @property refreshToken The user's refresh token.
* @property tokenType The type of token (ex: "Bearer").
* @property expiresInSeconds The amount of time (in seconds) before the [accessToken] expires.
* @property key The user's key.
* @property privateKey The user's private key.
* @property kdfType The KDF type.
* @property kdfIterations The number of iterations when calculating a user's password.
* @property kdfMemory The amount of memory to use when calculating a password hash (MB).
* @property kdfParallelism The number of threads to use when calculating a password hash.
* @property shouldForcePasswordReset Whether or not the app must force a password reset.
* @property shouldResetMasterPassword Whether or not the user is required to reset their
* master password.
* @property masterPasswordPolicyOptions The options available for a user's master password.
* @property userDecryptionOptions The options available to a user for decryption.
*/
@Serializable
data class Success(
@SerialName("access_token")
val accessToken: String,
@SerialName("refresh_token")
val refreshToken: String,
@SerialName("token_type")
val tokenType: String,
@SerialName("expires_in")
val expiresInSeconds: Int,
@SerialName("Key")
val key: String,
@SerialName("PrivateKey")
val privateKey: String,
@SerialName("Kdf")
val kdfType: KdfTypeJson,
@SerialName("KdfIterations")
val kdfIterations: Int?,
@SerialName("KdfMemory")
val kdfMemory: Int?,
@SerialName("KdfParallelism")
val kdfParallelism: Int?,
@SerialName("ForcePasswordReset")
val shouldForcePasswordReset: Boolean,
@SerialName("ResetMasterPassword")
val shouldResetMasterPassword: Boolean,
@SerialName("MasterPasswordPolicy")
val masterPasswordPolicyOptions: MasterPasswordPolicyOptionsJson?,
@SerialName("UserDecryptionOptions")
val userDecryptionOptions: UserDecryptionOptionsJson?,
) : GetTokenResponseJson()
/**

View File

@@ -0,0 +1,15 @@
package com.x8bit.bitwarden.data.auth.datasource.network.model
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
/**
* Decryption options related to a user's key connector.
*
* @property keyConnectorUrl URL to the user's key connector.
*/
@Serializable
data class KeyConnectorUserDecryptionOptionsJson(
@SerialName("KeyConnectorUrl")
val keyConnectorUrl: String,
)

View File

@@ -0,0 +1,39 @@
package com.x8bit.bitwarden.data.auth.datasource.network.model
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
/**
* Policies that may be applied to a master password.
*
* @property minimumComplexity The minimum required password complexity (if applicable).
* @property minimumLength The minimum required password length (if applicable).
* @property shouldRequireUppercase Whether or not uppercase characters should be required.
* @property shouldRequireLowercase Whether or not lowercase characters should be required.
* @property shouldRequireNumbers Whether or not numbers should be required.
* @property shouldRequireSpecialCharacters Whether or not special characters should be required.
* @property shouldEnforceOnLogin Whether or not the restrictions should be enforced on login.
*/
@Serializable
data class MasterPasswordPolicyOptionsJson(
@SerialName("MinComplexity")
val minimumComplexity: Int?,
@SerialName("MinLength")
val minimumLength: Int?,
@SerialName("RequireUpper")
val shouldRequireUppercase: Boolean?,
@SerialName("RequireLower")
val shouldRequireLowercase: Boolean?,
@SerialName("RequireNumbers")
val shouldRequireNumbers: Boolean?,
@SerialName("RequireSpecial")
val shouldRequireSpecialCharacters: Boolean?,
@SerialName("EnforceOnLogin")
val shouldEnforceOnLogin: Boolean?,
)

View File

@@ -0,0 +1,32 @@
package com.x8bit.bitwarden.data.auth.datasource.network.model
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
/**
* Decryption options related to a user's trusted device.
*
* @property encryptedPrivateKey The user's encrypted private key.
* @property encryptedUserKey The user's encrypted key.
* @property hasAdminApproval Whether or not the user has admin approval.
* @property hasLoginApprovingDevice Whether or not the user has a login approving device.
* @property hasManageResetPasswordPermission Whether or not the user has manage reset password
* permission.
*/
@Serializable
data class TrustedDeviceUserDecryptionOptionsJson(
@SerialName("EncryptedPrivateKey")
val encryptedPrivateKey: String?,
@SerialName("EncryptedUserKey")
val encryptedUserKey: String?,
@SerialName("HasAdminApproval")
val hasAdminApproval: Boolean,
@SerialName("HasLoginApprovingDevice")
val hasLoginApprovingDevice: Boolean,
@SerialName("HasManageResetPasswordPermission")
val hasManageResetPasswordPermission: Boolean,
)

View File

@@ -0,0 +1,25 @@
package com.x8bit.bitwarden.data.auth.datasource.network.model
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
/**
* The options available to a user for decryption.
*
* @property hasMasterPassword Whether the current user has a master password that can be used to
* decrypt their vault.
* @property trustedDeviceUserDecryptionOptions Decryption options related to a user's trusted
* device.
* @property keyConnectorUserDecryptionOptions Decryption options related to a user's key connector.
*/
@Serializable
data class UserDecryptionOptionsJson(
@SerialName("HasMasterPassword")
val hasMasterPassword: Boolean,
@SerialName("TrustedDeviceOption")
val trustedDeviceUserDecryptionOptions: TrustedDeviceUserDecryptionOptionsJson?,
@SerialName("KeyConnectorOption")
val keyConnectorUserDecryptionOptions: KeyConnectorUserDecryptionOptionsJson?,
)