Skip to content

[PM-37886] refactor: Update Key Connector vault unlock to use SDK's keyConnectorUrl method#2748

Open
matt-livefront wants to merge 4 commits into
mainfrom
matt/PM-37886-key-connector-url
Open

[PM-37886] refactor: Update Key Connector vault unlock to use SDK's keyConnectorUrl method#2748
matt-livefront wants to merge 4 commits into
mainfrom
matt/PM-37886-key-connector-url

Conversation

@matt-livefront

@matt-livefront matt-livefront commented Jun 3, 2026

Copy link
Copy Markdown
Collaborator

🎟️ Tracking

PM-37886

📔 Objective

Migrates the Key Connector vault unlock to let the SDK handle Key Connector communication, removing the app's direct GET /user-keys network call.

Changes

  • AuthRepository.unlockVaultWithKeyConnectorKey: switches from InitUserCryptoMethod.keyConnector(masterKey:userKey:) (which required a prior getMasterKeyFromKeyConnector API call) to InitUserCryptoMethod.keyConnectorUrl(url:keyConnectorKeyWrappedUserKey:), which delegates the Key Connector fetch to the SDK.
  • Removes getMasterKeyFromKeyConnector from KeyConnectorService and KeyConnectorAPIService protocols and implementations.
  • Deletes KeyConnectorUserKeyRequest and KeyConnectorUserKeyResponseModel.

@matt-livefront matt-livefront added ai-review Request a Claude code review t:tech-debt Change Type - Tech debt labels Jun 3, 2026
@github-actions github-actions Bot added the app:password-manager Bitwarden Password Manager app context label Jun 3, 2026
@github-actions

github-actions Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Bitwarden Claude Code Review

Overall Assessment: APPROVE

This PR migrates unlockVaultWithKeyConnectorKey from the two-step flow (GET /user-keys + InitUserCryptoMethod.keyConnector) to the SDK-encapsulated InitUserCryptoMethod.keyConnectorUrl, removing the dedicated getMasterKeyFromKeyConnector API surface, its request/response models, fixtures, and tests. The refactor is clean — no dangling references to deleted types remain (verified PostKeyConnectorUserKeyRequest is a distinct type still used for the migration POST path), and the previously flagged loading overlay regression in SingleSignOnProcessor.singleSignOnCompleted has been addressed. Commit 7666c264b adds coordinator.hideLoadingOverlay() to the noAccountCryptographicState catch branch before showing the confirmation alert, and commit 5c0448351 updates the three affected tests to assert XCTAssertFalse(coordinator.isLoadingOverlayShowing) after pre-setting the overlay to true.

Code Review Details

No new findings. Previous IMPORTANT finding on BitwardenShared/UI/Auth/Login/SingleSignOn/SingleSignOnProcessor.swift:240 has been resolved with verified test coverage. The follow-up cleanup to convert loading-overlay dismissal to defer is tracked separately in PM-38748.

@codecov

codecov Bot commented Jun 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.82%. Comparing base (7644d1b) to head (7666c26).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2748      +/-   ##
==========================================
+ Coverage   87.81%   87.82%   +0.01%     
==========================================
  Files        1707     1704       -3     
  Lines      165707   165842     +135     
==========================================
+ Hits       145517   145657     +140     
+ Misses      20190    20185       -5     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Base automatically changed from matt/PM-27238-key-connector-v2 to main June 4, 2026 17:00
@matt-livefront matt-livefront force-pushed the matt/PM-37886-key-connector-url branch from 8517d4c to 221b3f5 Compare June 4, 2026 18:03
@matt-livefront matt-livefront marked this pull request as ready for review June 4, 2026 18:05
@matt-livefront matt-livefront requested a review from a team as a code owner June 4, 2026 18:05
fedemkr
fedemkr previously approved these changes Jun 4, 2026
coordinator.hideLoadingOverlay()
await coordinator.handleEvent(.didCompleteAuth)
} catch StateServiceError.noAccountCryptographicState {
coordinator.hideLoadingOverlay()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎨 To one of the things Claude generated for this, is there a way we could test to make sure the overlay is hidden here?

🤔 Would the hiding of the overlay be something we could defer?

coordinator.hideLoadingOverlay()
await coordinator.handleEvent(.didCompleteAuth)
} catch StateServiceError.noAccountCryptographicState {
coordinator.hideLoadingOverlay()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎨 To one of the things Claude generated for this, is there a way we could test to make sure the overlay is hidden here?

🤔 Would the hiding of the overlay be something we could defer?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎨 To one of the things Claude generated for this, is there a way we could test to make sure the overlay is hidden here?

Yep, I updated the tests for this.

🤔 Would the hiding of the overlay be something we could defer?

That would be ideal. At one point we ran into a problem where defer was causing the loading overlay to not hide when transitioning from the auth flow to the vault, which is why they are manually hidden in some places like this before completing auth. I'd like to clean this up, but I'd prefer to do it separately. I created a ticket: https://bitwarden.atlassian.net/browse/PM-38748.

@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Warning

@matt-livefront Uploading code coverage report failed. Please check the "Upload to codecov.io" step of Process Test Reports job for more details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-review Request a Claude code review app:password-manager Bitwarden Password Manager app context t:tech-debt Change Type - Tech debt

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants