[PR #6517] [MERGED] [PM-32029] Implement SDK interfaces for cookie management #43728

Closed
opened 2026-04-23 22:24:06 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/bitwarden/android/pull/6517
Author: @SaintPatrck
Created: 2/10/2026
Status: Merged
Merged: 2/11/2026
Merged by: @SaintPatrck

Base: mainHead: cookie-vending/p8-t3_server-comm-config-platform-api


📝 Commits (4)

  • e2d56ac [PM-32029] Implement SDK interfaces for cookie management
  • cf1146a Remove deleteCookieConfig in favor of storeCookieConfig with null
  • 7529cdf Merge remote-tracking branch 'origin/main' into cookie-vending/p8-t3_server-comm-config-platform-api
  • feb5e33 Add detailed KDoc to explain cookie acquisition fallback

📊 Changes

27 files changed (+836 additions, -5 deletions)

View changed files

📝 app/src/main/kotlin/com/x8bit/bitwarden/data/platform/datasource/disk/CookieDiskSource.kt (+3 -3)
📝 app/src/main/kotlin/com/x8bit/bitwarden/data/platform/datasource/disk/CookieDiskSourceImpl.kt (+2 -2)
app/src/main/kotlin/com/x8bit/bitwarden/data/platform/error/CookiesRequiredException.kt (+12 -0)
app/src/main/kotlin/com/x8bit/bitwarden/data/platform/manager/CookieAcquisitionRequestManager.kt (+24 -0)
app/src/main/kotlin/com/x8bit/bitwarden/data/platform/manager/CookieAcquisitionRequestManagerImpl.kt (+24 -0)
📝 app/src/main/kotlin/com/x8bit/bitwarden/data/platform/manager/SdkClientManagerImpl.kt (+6 -0)
📝 app/src/main/kotlin/com/x8bit/bitwarden/data/platform/manager/di/PlatformManagerModule.kt (+25 -0)
app/src/main/kotlin/com/x8bit/bitwarden/data/platform/manager/model/CookieAcquisitionRequest.kt (+10 -0)
app/src/main/kotlin/com/x8bit/bitwarden/data/platform/manager/sdk/SdkPlatformApiFactory.kt (+14 -0)
app/src/main/kotlin/com/x8bit/bitwarden/data/platform/manager/sdk/SdkPlatformApiFactoryImpl.kt (+20 -0)
📝 app/src/main/kotlin/com/x8bit/bitwarden/data/platform/manager/sdk/SdkRepositoryFactory.kt (+6 -0)
📝 app/src/main/kotlin/com/x8bit/bitwarden/data/platform/manager/sdk/SdkRepositoryFactoryImpl.kt (+12 -0)
app/src/main/kotlin/com/x8bit/bitwarden/data/platform/manager/sdk/platformapi/ServerCommunicationConfigPlatformApiImpl.kt (+53 -0)
app/src/main/kotlin/com/x8bit/bitwarden/data/platform/manager/sdk/repository/ServerCommunicationConfigRepositoryImpl.kt (+76 -0)
app/src/main/kotlin/com/x8bit/bitwarden/data/platform/repository/util/AcquiredCookieExtensions.kt (+19 -0)
app/src/main/kotlin/com/x8bit/bitwarden/data/platform/repository/util/CookieConfigurationDataExtensions.kt (+18 -0)
📝 app/src/main/kotlin/com/x8bit/bitwarden/data/vault/datasource/sdk/ScopedVaultSdkSourceImpl.kt (+3 -0)
📝 app/src/main/kotlin/com/x8bit/bitwarden/data/vault/datasource/sdk/di/VaultSdkModule.kt (+3 -0)
📝 app/src/test/kotlin/com/x8bit/bitwarden/data/platform/datasource/disk/CookieDiskSourceTest.kt (+44 -0)
app/src/test/kotlin/com/x8bit/bitwarden/data/platform/datasource/sdk/ServerCommunicationConfigPlatformApiTest.kt (+64 -0)

...and 7 more files

📄 Description

🎟️ Tracking

PM-32039

📔 Objective

Implement the repository and platform API interfaces required by the servercommunicationconfig SDK module. It wires them into the SDK client, handles the cookie acquisition flow, and provides the necessary data conversions and state management.

Integrate the servercommunicationconfig SDK by implementing its ServerCommunicationConfigRepository and ServerCommunicationConfigPlatformApi interfaces, enabling the SDK to manage cookie-based authentication configurations.

Behavioral Changes

  • When an SDK-driven API call requires cookies, it will now trigger a CookieAcquisitionRequest state change and throw a CookiesRequiredException. This is designed to halt the current operation and signal the UI to navigate to a cookie acquisition screen.

Specific Changes

Part A: SDK Platform API Implementation

  • ServerCommunicationConfigPlatformApiImpl: Implements the SDK's ServerCommunicationConfigPlatformApi.
        - acquireCookies(): When called by the SDK, it uses CookieAcquisitionRequestManager to set a pending acquisition request. It then throws a CookiesRequiredException to cancel the current API call, allowing the UI to handle the navigation flow.
  • CookieAcquisitionRequestManager: A new manager with a StateFlow (cookieAcquisitionRequestFlow) to broadcast the need for cookie acquisition to the application's UI/navigation layer.
  • CookiesRequiredException: A new IOException to signal that an operation was halted because cookies are required.
  • SdkPlatformApiFactory: A new factory responsible for creating instances of the ServerCommunicationConfigPlatformApiImpl, now integrated into SdkClientManager.

Part B: SDK Repository Implementation

  • ServerCommunicationConfigRepositoryImpl: Implements the SDK's ServerCommunicationConfigRepository.
        - Bridges the SDK's storage contract to the application's CookieDiskSource and ConfigDiskSource.
        - get(): Reads the server communication bootstrap config and the locally stored cookies, converting them into the SDK's ServerCommunicationConfig model. It returns BootstrapConfig.Direct if the configuration is not ssoCookieVendor.
        - save(): Converts the SDK's ServerCommunicationConfig back into the application's CookieConfigurationData and persists it using CookieDiskSource.
        - It handles BootstrapConfig.Direct by deleting any existing cookie configuration for the given hostname.
  • CookieDiskSource: Extended with a deleteCookieConfig(hostname) method.

Part C: Data Model and Utilities

  • CookieConfigurationDataExtensions / AcquiredCookieExtensions: New extension functions to seamlessly convert between the SDK's AcquiredCookie and the application's domain model CookieConfigurationData.Cookie.
  • CookieAcquisitionRequest: New data class to represent a pending cookie acquisition request, containing the target hostname.

Part D: Dependency Injection & Integration

  • PlatformManagerModule: Updated to provide CookieAcquisitionRequestManager, SdkPlatformApiFactory, and to inject new dependencies into SdkRepositoryFactoryImpl and SdkClientManagerImpl.
  • SdkClientManagerImpl: Now configured with the ServerCommunicationConfigRepository and ServerCommunicationConfigPlatformApi during client initialization.
  • SdkRepositoryFactory / SdkPlatformApiFactory: Interfaces and implementations are created to manage the lifecycle of SDK-related repositories and platform APIs.

Tests: 9 new tests, all passing

  • ServerCommunicationConfigRepositoryTest: 6 tests covering get and save logic, including conversions and handling different bootstrap types.
  • ServerCommunicationConfigPlatformApiTest: 2 tests verifying that acquireCookies sets the manager state and throws the correct exception.
  • CookieAcquisitionRequestManagerTest: 4 tests for the StateFlow behavior.
  • AcquiredCookieExtensionsTest & CookieConfigurationDataExtensionsTest: 4 tests confirming correct data model conversions.
  • SdkPlatformApiFactoryTests & SdkRepositoryFactoryTests: New tests for the factories.
  • CookieDiskSourceTest: 2 new tests for the deleteCookieConfig functionality.
  • Existing tests like SdkClientManagerTest were updated to accommodate new dependencies.

Reminders before review

  • Contributor guidelines followed
  • All formatters and local linters executed and passed
  • Written new unit and / or integration tests where applicable
  • Protected functional changes with optionality (feature flags)
  • Used internationalization (i18n) for all UI strings
  • CI builds passed
  • Communicated to DevOps any deployment requirements
  • Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team

🦮 Reviewer guidelines

  • 👍 (:+1:) or similar for great changes
  • 📝 (:memo:) or ℹ️ (:information_source:) for notes or general info
  • (:question:) for questions
  • 🤔 (:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion
  • 🎨 (:art:) for suggestions / improvements
  • (:x:) or ⚠️ (:warning:) for more significant problems or concerns needing attention
  • 🌱 (:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt
  • ⛏ (:pick:) for minor or nitpick changes

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/bitwarden/android/pull/6517 **Author:** [@SaintPatrck](https://github.com/SaintPatrck) **Created:** 2/10/2026 **Status:** ✅ Merged **Merged:** 2/11/2026 **Merged by:** [@SaintPatrck](https://github.com/SaintPatrck) **Base:** `main` ← **Head:** `cookie-vending/p8-t3_server-comm-config-platform-api` --- ### 📝 Commits (4) - [`e2d56ac`](https://github.com/bitwarden/android/commit/e2d56acad52a6c52cb593b26801e473db08ffb3e) [PM-32029] Implement SDK interfaces for cookie management - [`cf1146a`](https://github.com/bitwarden/android/commit/cf1146aed41397038dde24ae62668d275da92ba0) Remove deleteCookieConfig in favor of storeCookieConfig with null - [`7529cdf`](https://github.com/bitwarden/android/commit/7529cdf03b2fce49bfa6a4819161d9fc72e8be73) Merge remote-tracking branch 'origin/main' into cookie-vending/p8-t3_server-comm-config-platform-api - [`feb5e33`](https://github.com/bitwarden/android/commit/feb5e33e9a0bc566225b624d72a7826ecb17f786) Add detailed KDoc to explain cookie acquisition fallback ### 📊 Changes **27 files changed** (+836 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `app/src/main/kotlin/com/x8bit/bitwarden/data/platform/datasource/disk/CookieDiskSource.kt` (+3 -3) 📝 `app/src/main/kotlin/com/x8bit/bitwarden/data/platform/datasource/disk/CookieDiskSourceImpl.kt` (+2 -2) ➕ `app/src/main/kotlin/com/x8bit/bitwarden/data/platform/error/CookiesRequiredException.kt` (+12 -0) ➕ `app/src/main/kotlin/com/x8bit/bitwarden/data/platform/manager/CookieAcquisitionRequestManager.kt` (+24 -0) ➕ `app/src/main/kotlin/com/x8bit/bitwarden/data/platform/manager/CookieAcquisitionRequestManagerImpl.kt` (+24 -0) 📝 `app/src/main/kotlin/com/x8bit/bitwarden/data/platform/manager/SdkClientManagerImpl.kt` (+6 -0) 📝 `app/src/main/kotlin/com/x8bit/bitwarden/data/platform/manager/di/PlatformManagerModule.kt` (+25 -0) ➕ `app/src/main/kotlin/com/x8bit/bitwarden/data/platform/manager/model/CookieAcquisitionRequest.kt` (+10 -0) ➕ `app/src/main/kotlin/com/x8bit/bitwarden/data/platform/manager/sdk/SdkPlatformApiFactory.kt` (+14 -0) ➕ `app/src/main/kotlin/com/x8bit/bitwarden/data/platform/manager/sdk/SdkPlatformApiFactoryImpl.kt` (+20 -0) 📝 `app/src/main/kotlin/com/x8bit/bitwarden/data/platform/manager/sdk/SdkRepositoryFactory.kt` (+6 -0) 📝 `app/src/main/kotlin/com/x8bit/bitwarden/data/platform/manager/sdk/SdkRepositoryFactoryImpl.kt` (+12 -0) ➕ `app/src/main/kotlin/com/x8bit/bitwarden/data/platform/manager/sdk/platformapi/ServerCommunicationConfigPlatformApiImpl.kt` (+53 -0) ➕ `app/src/main/kotlin/com/x8bit/bitwarden/data/platform/manager/sdk/repository/ServerCommunicationConfigRepositoryImpl.kt` (+76 -0) ➕ `app/src/main/kotlin/com/x8bit/bitwarden/data/platform/repository/util/AcquiredCookieExtensions.kt` (+19 -0) ➕ `app/src/main/kotlin/com/x8bit/bitwarden/data/platform/repository/util/CookieConfigurationDataExtensions.kt` (+18 -0) 📝 `app/src/main/kotlin/com/x8bit/bitwarden/data/vault/datasource/sdk/ScopedVaultSdkSourceImpl.kt` (+3 -0) 📝 `app/src/main/kotlin/com/x8bit/bitwarden/data/vault/datasource/sdk/di/VaultSdkModule.kt` (+3 -0) 📝 `app/src/test/kotlin/com/x8bit/bitwarden/data/platform/datasource/disk/CookieDiskSourceTest.kt` (+44 -0) ➕ `app/src/test/kotlin/com/x8bit/bitwarden/data/platform/datasource/sdk/ServerCommunicationConfigPlatformApiTest.kt` (+64 -0) _...and 7 more files_ </details> ### 📄 Description ## 🎟️ Tracking PM-32039 ## 📔 Objective Implement the repository and platform API interfaces required by the `servercommunicationconfig` SDK module. It wires them into the SDK client, handles the cookie acquisition flow, and provides the necessary data conversions and state management. Integrate the `servercommunicationconfig` SDK by implementing its `ServerCommunicationConfigRepository` and `ServerCommunicationConfigPlatformApi` interfaces, enabling the SDK to manage cookie-based authentication configurations. ### Behavioral Changes - When an SDK-driven API call requires cookies, it will now trigger a `CookieAcquisitionRequest` state change and throw a `CookiesRequiredException`. This is designed to halt the current operation and signal the UI to navigate to a cookie acquisition screen. ### Specific Changes **Part A: SDK Platform API Implementation** - **`ServerCommunicationConfigPlatformApiImpl`**: Implements the SDK's `ServerCommunicationConfigPlatformApi`.     - `acquireCookies()`: When called by the SDK, it uses `CookieAcquisitionRequestManager` to set a pending acquisition request. It then throws a `CookiesRequiredException` to cancel the current API call, allowing the UI to handle the navigation flow. - **`CookieAcquisitionRequestManager`**: A new manager with a `StateFlow` (`cookieAcquisitionRequestFlow`) to broadcast the need for cookie acquisition to the application's UI/navigation layer. - **`CookiesRequiredException`**: A new `IOException` to signal that an operation was halted because cookies are required. - **`SdkPlatformApiFactory`**: A new factory responsible for creating instances of the `ServerCommunicationConfigPlatformApiImpl`, now integrated into `SdkClientManager`. **Part B: SDK Repository Implementation** - **`ServerCommunicationConfigRepositoryImpl`**: Implements the SDK's `ServerCommunicationConfigRepository`.     - Bridges the SDK's storage contract to the application's `CookieDiskSource` and `ConfigDiskSource`.     - `get()`: Reads the server communication bootstrap config and the locally stored cookies, converting them into the SDK's `ServerCommunicationConfig` model. It returns `BootstrapConfig.Direct` if the configuration is not `ssoCookieVendor`.     - `save()`: Converts the SDK's `ServerCommunicationConfig` back into the application's `CookieConfigurationData` and persists it using `CookieDiskSource`.     - It handles `BootstrapConfig.Direct` by deleting any existing cookie configuration for the given hostname. - **`CookieDiskSource`**: Extended with a `deleteCookieConfig(hostname)` method. **Part C: Data Model and Utilities** - **`CookieConfigurationDataExtensions` / `AcquiredCookieExtensions`**: New extension functions to seamlessly convert between the SDK's `AcquiredCookie` and the application's domain model `CookieConfigurationData.Cookie`. - **`CookieAcquisitionRequest`**: New data class to represent a pending cookie acquisition request, containing the target hostname. **Part D: Dependency Injection & Integration** - **`PlatformManagerModule`**: Updated to provide `CookieAcquisitionRequestManager`, `SdkPlatformApiFactory`, and to inject new dependencies into `SdkRepositoryFactoryImpl` and `SdkClientManagerImpl`. - **`SdkClientManagerImpl`**: Now configured with the `ServerCommunicationConfigRepository` and `ServerCommunicationConfigPlatformApi` during client initialization. - **`SdkRepositoryFactory` / `SdkPlatformApiFactory`**: Interfaces and implementations are created to manage the lifecycle of SDK-related repositories and platform APIs. **Tests: 9 new tests, all passing** - `ServerCommunicationConfigRepositoryTest`: 6 tests covering `get` and `save` logic, including conversions and handling different bootstrap types. - `ServerCommunicationConfigPlatformApiTest`: 2 tests verifying that `acquireCookies` sets the manager state and throws the correct exception. - `CookieAcquisitionRequestManagerTest`: 4 tests for the StateFlow behavior. - `AcquiredCookieExtensionsTest` & `CookieConfigurationDataExtensionsTest`: 4 tests confirming correct data model conversions. - `SdkPlatformApiFactoryTests` & `SdkRepositoryFactoryTests`: New tests for the factories. - `CookieDiskSourceTest`: 2 new tests for the `deleteCookieConfig` functionality. - Existing tests like `SdkClientManagerTest` were updated to accommodate new dependencies. ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## 🦮 Reviewer guidelines <!-- Suggested interactions but feel free to use (or not) as you desire! --> - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹ️ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠️ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or ♻️ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-23 22:24:06 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/android#43728