Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing hashPurpose to mobile demo apps #407

Merged
merged 1 commit into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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