From cec70a9c6437ab69ca050ca6920122735243eaf3 Mon Sep 17 00:00:00 2001 From: David Perez Date: Mon, 15 Apr 2024 14:02:38 -0500 Subject: [PATCH] Update the Bitwarden SDK (#1271) --- .../data/auth/datasource/sdk/AuthSdkSource.kt | 1 + .../data/auth/datasource/sdk/AuthSdkSourceImpl.kt | 2 ++ .../data/auth/repository/AuthRepositoryImpl.kt | 1 + .../data/auth/datasource/sdk/AuthSdkSourceTest.kt | 4 ++++ .../data/auth/repository/AuthRepositoryTest.kt | 10 ++++++++++ gradle/libs.versions.toml | 2 +- 6 files changed, 19 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/x8bit/bitwarden/data/auth/datasource/sdk/AuthSdkSource.kt b/app/src/main/java/com/x8bit/bitwarden/data/auth/datasource/sdk/AuthSdkSource.kt index fd593e1ca..445bf5076 100644 --- a/app/src/main/java/com/x8bit/bitwarden/data/auth/datasource/sdk/AuthSdkSource.kt +++ b/app/src/main/java/com/x8bit/bitwarden/data/auth/datasource/sdk/AuthSdkSource.kt @@ -52,6 +52,7 @@ interface AuthSdkSource { */ suspend fun makeRegisterTdeKeysAndUnlockVault( userId: String, + email: String, orgPublicKey: String, rememberDevice: Boolean, ): Result diff --git a/app/src/main/java/com/x8bit/bitwarden/data/auth/datasource/sdk/AuthSdkSourceImpl.kt b/app/src/main/java/com/x8bit/bitwarden/data/auth/datasource/sdk/AuthSdkSourceImpl.kt index 4d6db7a20..5a3ea944d 100644 --- a/app/src/main/java/com/x8bit/bitwarden/data/auth/datasource/sdk/AuthSdkSourceImpl.kt +++ b/app/src/main/java/com/x8bit/bitwarden/data/auth/datasource/sdk/AuthSdkSourceImpl.kt @@ -78,12 +78,14 @@ class AuthSdkSourceImpl( override suspend fun makeRegisterTdeKeysAndUnlockVault( userId: String, + email: String, orgPublicKey: String, rememberDevice: Boolean, ): Result = runCatching { getClient(userId = userId) .auth() .makeRegisterTdeKeys( + email = email, orgPublicKey = orgPublicKey, rememberDevice = rememberDevice, ) diff --git a/app/src/main/java/com/x8bit/bitwarden/data/auth/repository/AuthRepositoryImpl.kt b/app/src/main/java/com/x8bit/bitwarden/data/auth/repository/AuthRepositoryImpl.kt index 6b07dce76..07b0874e1 100644 --- a/app/src/main/java/com/x8bit/bitwarden/data/auth/repository/AuthRepositoryImpl.kt +++ b/app/src/main/java/com/x8bit/bitwarden/data/auth/repository/AuthRepositoryImpl.kt @@ -367,6 +367,7 @@ class AuthRepositoryImpl( .flatMap { organizationKeys -> authSdkSource.makeRegisterTdeKeysAndUnlockVault( userId = userId, + email = account.profile.email, orgPublicKey = organizationKeys.publicKey, rememberDevice = authDiskSource.shouldTrustDevice, ) diff --git a/app/src/test/java/com/x8bit/bitwarden/data/auth/datasource/sdk/AuthSdkSourceTest.kt b/app/src/test/java/com/x8bit/bitwarden/data/auth/datasource/sdk/AuthSdkSourceTest.kt index 5f4597b6e..40357a7ee 100644 --- a/app/src/test/java/com/x8bit/bitwarden/data/auth/datasource/sdk/AuthSdkSourceTest.kt +++ b/app/src/test/java/com/x8bit/bitwarden/data/auth/datasource/sdk/AuthSdkSourceTest.kt @@ -163,12 +163,14 @@ class AuthSdkSourceTest { fun `makeRegisterTdeKeysAndUnlockVault should call SDK and return a Result with the correct data`() = runBlocking { val userId = "userId" + val email = "email" val orgPublicKey = "orgPublicKey" val rememberDevice = true val expectedResult = mockk() coEvery { sdkClientManager.getOrCreateClient(userId = userId) } returns client coEvery { clientAuth.makeRegisterTdeKeys( + email = email, orgPublicKey = orgPublicKey, rememberDevice = rememberDevice, ) @@ -176,12 +178,14 @@ class AuthSdkSourceTest { val result = authSkdSource.makeRegisterTdeKeysAndUnlockVault( userId = userId, + email = email, orgPublicKey = orgPublicKey, rememberDevice = rememberDevice, ) assertEquals(expectedResult.asSuccess(), result) coVerify(exactly = 1) { clientAuth.makeRegisterTdeKeys( + email = email, orgPublicKey = orgPublicKey, rememberDevice = rememberDevice, ) diff --git a/app/src/test/java/com/x8bit/bitwarden/data/auth/repository/AuthRepositoryTest.kt b/app/src/test/java/com/x8bit/bitwarden/data/auth/repository/AuthRepositoryTest.kt index 4f1ac5047..1fbf36ca3 100644 --- a/app/src/test/java/com/x8bit/bitwarden/data/auth/repository/AuthRepositoryTest.kt +++ b/app/src/test/java/com/x8bit/bitwarden/data/auth/repository/AuthRepositoryTest.kt @@ -823,6 +823,7 @@ class AuthRepositoryTest { coEvery { authSdkSource.makeRegisterTdeKeysAndUnlockVault( userId = USER_ID_1, + email = EMAIL, orgPublicKey = orgPublicKey, rememberDevice = shouldTrustDevice, ) @@ -836,6 +837,7 @@ class AuthRepositoryTest { organizationService.getOrganizationKeys(orgId) authSdkSource.makeRegisterTdeKeysAndUnlockVault( userId = USER_ID_1, + email = EMAIL, orgPublicKey = orgPublicKey, rememberDevice = shouldTrustDevice, ) @@ -877,6 +879,7 @@ class AuthRepositoryTest { coEvery { authSdkSource.makeRegisterTdeKeysAndUnlockVault( userId = USER_ID_1, + email = EMAIL, orgPublicKey = orgPublicKey, rememberDevice = shouldTrustDevice, ) @@ -896,6 +899,7 @@ class AuthRepositoryTest { organizationService.getOrganizationKeys(orgId) authSdkSource.makeRegisterTdeKeysAndUnlockVault( userId = USER_ID_1, + email = EMAIL, orgPublicKey = orgPublicKey, rememberDevice = shouldTrustDevice, ) @@ -941,6 +945,7 @@ class AuthRepositoryTest { coEvery { authSdkSource.makeRegisterTdeKeysAndUnlockVault( userId = USER_ID_1, + email = EMAIL, orgPublicKey = orgPublicKey, rememberDevice = shouldTrustDevice, ) @@ -968,6 +973,7 @@ class AuthRepositoryTest { organizationService.getOrganizationKeys(orgId) authSdkSource.makeRegisterTdeKeysAndUnlockVault( userId = USER_ID_1, + email = EMAIL, orgPublicKey = orgPublicKey, rememberDevice = shouldTrustDevice, ) @@ -1021,6 +1027,7 @@ class AuthRepositoryTest { coEvery { authSdkSource.makeRegisterTdeKeysAndUnlockVault( userId = USER_ID_1, + email = EMAIL, orgPublicKey = orgPublicKey, rememberDevice = shouldTrustDevice, ) @@ -1050,6 +1057,7 @@ class AuthRepositoryTest { organizationService.getOrganizationKeys(orgId) authSdkSource.makeRegisterTdeKeysAndUnlockVault( userId = USER_ID_1, + email = EMAIL, orgPublicKey = orgPublicKey, rememberDevice = shouldTrustDevice, ) @@ -1104,6 +1112,7 @@ class AuthRepositoryTest { coEvery { authSdkSource.makeRegisterTdeKeysAndUnlockVault( userId = USER_ID_1, + email = EMAIL, orgPublicKey = orgPublicKey, rememberDevice = shouldTrustDevice, ) @@ -1139,6 +1148,7 @@ class AuthRepositoryTest { organizationService.getOrganizationKeys(orgId) authSdkSource.makeRegisterTdeKeysAndUnlockVault( userId = USER_ID_1, + email = EMAIL, orgPublicKey = orgPublicKey, rememberDevice = shouldTrustDevice, ) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index a4431c1f8..0c9007176 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -23,7 +23,7 @@ androidxSplash = "1.1.0-rc01" androidXAppCompat = "1.6.1" androdixAutofill = "1.1.0" androidxWork = "2.9.0" -bitwardenSdk = "0.4.0-20240412.113052-206" +bitwardenSdk = "0.4.0-20240415.150112-210" crashlytics = "2.9.9" detekt = "1.23.6" firebaseBom = "32.8.1"