PM-35273: feat: Add support for SDK API calls by providing base urls#6805
Conversation
| }, | ||
| ) : SdkClientManager { | ||
| private val userIdToClientMap = mutableMapOf<String?, Client>() | ||
| private val userIdToClientMap = mutableMapOf<String, Client>() |
There was a problem hiding this comment.
Previously, we would create a single client that was unassociated with a user and reuse it. This will no longer work because we need to make sure the base URLs are appropriately set based on the current settings.
So now we never store the unassociated client.
|
|
||
| override suspend fun <T> singleUseClient( | ||
| block: suspend Client.() -> T, | ||
| ): T = clientProvider(null).use { it.block() } |
There was a problem hiding this comment.
I have completely removed the ability to fetch a client for a null UserID and added this function to ensure that a short lived client is always closed when it is done with its task.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6805 +/- ##
==========================================
+ Coverage 85.33% 85.35% +0.02%
==========================================
Files 962 959 -3
Lines 61070 61060 -10
Branches 8656 8651 -5
==========================================
+ Hits 52113 52118 +5
+ Misses 5957 5942 -15
Partials 3000 3000
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Great job! No new security vulnerabilities introduced in this pull request |
ff65a7b to
58f06ad
Compare
| */ | ||
| suspend fun <T> singleUseClient( | ||
| userId: String? = null, | ||
| accessToken: String? = null, |
There was a problem hiding this comment.
The need for this access token is specifically for intermediate states during the login flow.
The login process has not yet completed, so we have not persisted the access token. The SDK still requires the access token to do it's job properly, so we provide it manually here.
58f06ad to
bacb7f0
Compare
bacb7f0 to
e34f30d
Compare
🤖 Bitwarden Claude Code ReviewOverall Assessment: APPROVE Reviewed the refactor that wires Code Review DetailsNo findings. The three existing unresolved review threads from @david-livefront proactively explain the key design decisions (no longer caching unassociated clients, always closing short-lived clients, manual access-token pathway for intermediate login states), which addressed the questions I would have otherwise raised. |
|
Thanks @SaintPatrck |

🎟️ Tracking
PM-35273
📔 Objective
This PR adds support for instantiating the Bitwarden SDK Client with
ClientSettingsallowing the SDK to make appropriate network requests.