generated from bitwarden/template
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BIT-102: Create account functionality (#132)
- Loading branch information
1 parent
6f21206
commit 79c953b
Showing
35 changed files
with
1,134 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
...c/main/java/com/x8bit/bitwarden/data/auth/datasource/network/model/RegisterRequestJson.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package com.x8bit.bitwarden.data.auth.datasource.network.model | ||
|
||
import com.x8bit.bitwarden.data.auth.datasource.network.model.RegisterRequestJson.Keys | ||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
/** | ||
* Request body for register. | ||
* | ||
* @param email the email to be registered. | ||
* @param masterPasswordHash the master password (encrypted). | ||
* @param masterPasswordHint the hint for the master password (nullable). | ||
* @param captchaResponse the captcha bypass token. | ||
* @param key the user key for the request (encrypted). | ||
* @param keys a [Keys] object containing public and private keys. | ||
* @param kdfType the kdf type represented as an [Int]. | ||
* @param kdfIterations the number of kdf iterations. | ||
*/ | ||
@Serializable | ||
data class RegisterRequestJson( | ||
@SerialName("email") | ||
val email: String, | ||
|
||
@SerialName("masterPasswordHash") | ||
val masterPasswordHash: String, | ||
|
||
@SerialName("masterPasswordHint") | ||
val masterPasswordHint: String?, | ||
|
||
@SerialName("captchaResponse") | ||
val captchaResponse: String?, | ||
|
||
@SerialName("key") | ||
val key: String, | ||
|
||
@SerialName("keys") | ||
val keys: Keys, | ||
|
||
@SerialName("kdf") | ||
val kdfType: KdfTypeJson, | ||
|
||
@SerialName("kdfIterations") | ||
val kdfIterations: UInt, | ||
) { | ||
|
||
/** | ||
* A keys object containing public and private keys. | ||
* | ||
* @param publicKey the public key (encrypted). | ||
* @param encryptedPrivateKey the private key (encrypted). | ||
*/ | ||
@Serializable | ||
data class Keys( | ||
@SerialName("publicKey") | ||
val publicKey: String, | ||
|
||
@SerialName("encryptedPrivateKey") | ||
val encryptedPrivateKey: String, | ||
) | ||
} |
45 changes: 45 additions & 0 deletions
45
.../main/java/com/x8bit/bitwarden/data/auth/datasource/network/model/RegisterResponseJson.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.x8bit.bitwarden.data.auth.datasource.network.model | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
/** | ||
* Models response bodies for the register request. | ||
*/ | ||
@Serializable | ||
sealed class RegisterResponseJson { | ||
|
||
/** | ||
* Models a successful json response of the register request. | ||
* | ||
* @param captchaBypassToken the bypass token. | ||
*/ | ||
@Serializable | ||
data class Success( | ||
@SerialName("captchaBypassToken") | ||
val captchaBypassToken: String, | ||
) : RegisterResponseJson() | ||
|
||
/** | ||
* Models a json body of a captcha error. | ||
* | ||
* @param validationErrors object containing error validations of the response. | ||
*/ | ||
@Serializable | ||
data class CaptchaRequired( | ||
@SerialName("validationErrors") | ||
val validationErrors: ValidationErrors, | ||
) : RegisterResponseJson() { | ||
|
||
/** | ||
* Error validations containing a HCaptcha Site Key. | ||
* | ||
* @param captchaKeys keys for attempting captcha verification. | ||
*/ | ||
@Serializable | ||
data class ValidationErrors( | ||
@SerialName("HCaptcha_SiteKey") | ||
val captchaKeys: List<String>, | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
app/src/main/java/com/x8bit/bitwarden/data/auth/datasource/sdk/util/KdfExtensions.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.x8bit.bitwarden.data.auth.datasource.sdk.util | ||
|
||
import com.bitwarden.core.Kdf | ||
import com.x8bit.bitwarden.data.auth.datasource.network.model.KdfTypeJson | ||
import com.x8bit.bitwarden.data.auth.datasource.network.model.KdfTypeJson.ARGON2_ID | ||
import com.x8bit.bitwarden.data.auth.datasource.network.model.KdfTypeJson.PBKDF2_SHA256 | ||
|
||
/** | ||
* Convert a [Kdf] to a [KdfTypeJson]. | ||
*/ | ||
fun Kdf.toKdfTypeJson(): KdfTypeJson = | ||
when (this) { | ||
is Kdf.Argon2id -> ARGON2_ID | ||
is Kdf.Pbkdf2 -> PBKDF2_SHA256 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...uth/datasource/network/model/AuthState.kt → ...n/data/auth/repository/model/AuthState.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...h/datasource/network/model/LoginResult.kt → ...data/auth/repository/model/LoginResult.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
app/src/main/java/com/x8bit/bitwarden/data/auth/repository/model/RegisterResult.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.x8bit.bitwarden.data.auth.repository.model | ||
|
||
/** | ||
* Models result of registering a new account. | ||
*/ | ||
sealed class RegisterResult { | ||
/** | ||
* Register succeeded. | ||
* | ||
* @param captchaToken the captcha bypass token to bypass future captcha verifications. | ||
*/ | ||
data class Success(val captchaToken: String) : RegisterResult() | ||
|
||
/** | ||
* Captcha verification is required. | ||
* | ||
* @param captchaId the captcha id for performing the captcha verification. | ||
*/ | ||
data class CaptchaRequired(val captchaId: String) : RegisterResult() | ||
|
||
/** | ||
* There was an error logging in. | ||
* | ||
* @param errorMessage a message describing the error. | ||
*/ | ||
data class Error(val errorMessage: String?) : RegisterResult() | ||
} |
Oops, something went wrong.