diff --git a/common/src/commonMain/kotlin/com/artemchep/keyguard/platform/util/PlatformUserAgent.kt b/common/src/commonMain/kotlin/com/artemchep/keyguard/platform/util/PlatformUserAgent.kt index 2c32f56..a32a5ab 100644 --- a/common/src/commonMain/kotlin/com/artemchep/keyguard/platform/util/PlatformUserAgent.kt +++ b/common/src/commonMain/kotlin/com/artemchep/keyguard/platform/util/PlatformUserAgent.kt @@ -3,3 +3,13 @@ package com.artemchep.keyguard.platform.util import com.artemchep.keyguard.platform.Platform expect val Platform.userAgent: String + +// Taken from: +// https://releases.electronjs.org/releases/stable +private const val CHROME_VERSION = "126.0.6478.114" + +// Seems like desktop clients always use the Windows user-agents for +// privacy reasons. +val Platform.defaultUserAgent: String + get() = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/$CHROME_VERSION Safari/537.36" + diff --git a/common/src/commonMain/kotlin/com/artemchep/keyguard/provider/bitwarden/api/login.kt b/common/src/commonMain/kotlin/com/artemchep/keyguard/provider/bitwarden/api/login.kt index 31b32d1..da05f11 100644 --- a/common/src/commonMain/kotlin/com/artemchep/keyguard/provider/bitwarden/api/login.kt +++ b/common/src/commonMain/kotlin/com/artemchep/keyguard/provider/bitwarden/api/login.kt @@ -11,6 +11,7 @@ import com.artemchep.keyguard.common.util.int import com.artemchep.keyguard.core.store.bitwarden.BitwardenToken import com.artemchep.keyguard.platform.CurrentPlatform import com.artemchep.keyguard.platform.Platform +import com.artemchep.keyguard.platform.util.defaultUserAgent import com.artemchep.keyguard.platform.util.userAgent import com.artemchep.keyguard.provider.bitwarden.ServerEnv import com.artemchep.keyguard.provider.bitwarden.ServerTwoFactorToken @@ -76,7 +77,7 @@ data class BitwardenPersona( clientVersion = CLIENT_VERSION, deviceType = "8", deviceName = "linux", - userAgent = userAgent, + userAgent = defaultUserAgent, ) private fun Platform.Desktop.MacOS.bitwardenPersona( @@ -86,7 +87,7 @@ data class BitwardenPersona( clientVersion = CLIENT_VERSION, deviceType = "7", deviceName = "macos", - userAgent = userAgent, + userAgent = defaultUserAgent, ) private fun Platform.Desktop.Windows.bitwardenPersona( @@ -96,7 +97,7 @@ data class BitwardenPersona( clientVersion = CLIENT_VERSION, deviceType = "6", deviceName = "windows", - userAgent = userAgent, + userAgent = defaultUserAgent, ) } } diff --git a/common/src/jvmMain/kotlin/com/artemchep/keyguard/di/GlobalModuleJvm.kt b/common/src/jvmMain/kotlin/com/artemchep/keyguard/di/GlobalModuleJvm.kt index 2715863..650fb1f 100644 --- a/common/src/jvmMain/kotlin/com/artemchep/keyguard/di/GlobalModuleJvm.kt +++ b/common/src/jvmMain/kotlin/com/artemchep/keyguard/di/GlobalModuleJvm.kt @@ -361,7 +361,7 @@ import com.artemchep.keyguard.crypto.CryptoGeneratorJvm import com.artemchep.keyguard.crypto.FileEncryptorImpl import com.artemchep.keyguard.platform.CurrentPlatform import com.artemchep.keyguard.platform.util.isRelease -import com.artemchep.keyguard.platform.util.userAgent +import com.artemchep.keyguard.provider.bitwarden.api.BitwardenPersona import com.artemchep.keyguard.provider.bitwarden.usecase.CipherUrlCheckImpl import com.artemchep.keyguard.provider.bitwarden.usecase.CipherUrlDuplicateCheckImpl import io.ktor.client.HttpClient @@ -1295,7 +1295,8 @@ fun globalModuleJvm() = DI.Module( val okHttpClient: OkHttpClient = instance() HttpClient(OkHttp) { install(UserAgent) { - agent = CurrentPlatform.userAgent + agent = BitwardenPersona.of(CurrentPlatform) + .userAgent } engine { preconfigured = okHttpClient