Skip to content

Commit

Permalink
Add missing hashPurpose to mobile demo apps (#407)
Browse files Browse the repository at this point in the history
## Type of change
```
- [x] Bug fix
- [ ] New feature development
- [ ] Tech debt (refactoring, code cleanup, dependency upgrades, etc)
- [ ] Build/deploy pipeline (DevOps)
- [ ] Other
```

## Objective
Noticed the mobile demo apps weren't updated with the new hashPurpose
parameter, also ran formatting over the files
  • Loading branch information
dani-garcia authored Dec 8, 2023
1 parent 5cf658d commit e6977ae
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import androidx.compose.ui.unit.dp
import androidx.fragment.app.FragmentActivity
import com.bitwarden.core.DateTime
import com.bitwarden.core.Folder
import com.bitwarden.core.HashPurpose
import com.bitwarden.core.InitOrgCryptoRequest
import com.bitwarden.core.InitUserCryptoMethod
import com.bitwarden.core.InitUserCryptoRequest
Expand Down Expand Up @@ -58,9 +59,9 @@ import javax.net.ssl.X509TrustManager

/**
* IMPORTANT: This file is provided only for the purpose of demostrating the use of the SDK functionality.
* It hasn't gone through a throrough security review and should not be considered production ready. It also doesn't
* handle a lot of errors and edge cases that a production application would need to deal with.
* Developers are encouraged to review and improve the code as needed to meet their security requirements.
* It hasn't gone through a throrough security review and should not be considered production ready. It also doesn't
* handle a lot of errors and edge cases that a production application would need to deal with.
* Developers are encouraged to review and improve the code as needed to meet their security requirements.
* Additionally, we recommend to consult with security experts and conduct thorough testing before using the code in production.
*/

Expand Down Expand Up @@ -181,7 +182,8 @@ class MainActivity : FragmentActivity() {
prelogin_body.kdfParallelism!!
)
}
val masterPasswordHash = client.auth().hashPassword(EMAIL, PASSWORD, kdf)
val masterPasswordHash =
client.auth().hashPassword(EMAIL, PASSWORD, kdf, HashPurpose.SERVER_AUTHORIZATION)

///////////////////////////// Login /////////////////////////////

Expand Down
14 changes: 7 additions & 7 deletions languages/swift/iOS/App/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import SwiftUI

/**
* IMPORTANT: This file is provided only for the purpose of demostrating the use of the SDK functionality.
* It hasn't gone through a throrough security review and should not be considered production ready. It also doesn't
* handle a lot of errors and edge cases that a production application would need to deal with.
* Developers are encouraged to review and improve the code as needed to meet their security requirements.
* It hasn't gone through a throrough security review and should not be considered production ready. It also doesn't
* handle a lot of errors and edge cases that a production application would need to deal with.
* Developers are encouraged to review and improve the code as needed to meet their security requirements.
* Additionally, we recommend to consult with security experts and conduct thorough testing before using the code in production.
*/

Expand Down Expand Up @@ -49,8 +49,8 @@ struct ContentView: View {
Button(action: {
Task {
do {
try await clientExamplePassword(clientAuth: client.auth(), clientCrypto: client.crypto(), setupBiometrics: setupBiometrics)
try await decryptVault(clientCrypto: client.crypto(), clientVault: client.vault())
try await clientExamplePassword(clientAuth: client.auth(), clientCrypto: client.crypto(), setupBiometrics: setupBiometrics)
try await decryptVault(clientCrypto: client.crypto(), clientVault: client.vault())
} catch {
print("ERROR:", error)
}
Expand All @@ -64,7 +64,7 @@ struct ContentView: View {
Button(action: {
Task {
do {
try await clientExampleBiometrics(clientCrypto: client.crypto())
try await clientExampleBiometrics(clientCrypto: client.crypto())
try await decryptVault(clientCrypto: client.crypto(), clientVault: client.vault())
} catch {
print("ERROR:", error)
Expand Down Expand Up @@ -117,7 +117,7 @@ struct ContentView: View {
}

let passwordHash = try await clientAuth.hashPassword(
email: EMAIL, password: PASSWORD, kdfParams: kdf)
email: EMAIL, password: PASSWORD, kdfParams: kdf, purpose: .serverAuthorization)

///////////////////////////// Login /////////////////////////////

Expand Down

0 comments on commit e6977ae

Please sign in to comment.