Skip to content

[PM-22408] Remove setMasterKeyEncryptedUserKey from KeyService #15087

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Thomas-Avery
Copy link
Contributor

@Thomas-Avery Thomas-Avery commented Jun 4, 2025

🎟️ Tracking

https://bitwarden.atlassian.net/browse/PM-22408

📔 Objective

This PR removes the KeyService's setMasterKeyEncryptedUserKey method in favor of using the masterPasswordService's setMasterKeyEncryptedUserKey and requiring consumers to pass in a userID.

This is a part of the effort to remove the KeyService's usage of ActiveUserState and require UserID for methods.

Team reviewer notes:

Previously, there was a bug when passing in a null string to KeyService's setMasterKeyEncryptedUserKey would call the masterPasswordService like so.

    await this.masterPasswordService.setMasterKeyEncryptedUserKey(
      new EncString(null),
      userId,
    );

This counterintuitively didn't throw an error, and the stateProvider attempts to clear the entry for masterKeyEncryptedUserKey (which doesn't exist at the time).

For these code changes, I'm preserving the previous behavior (no error), but make it clear we skip setting setMasterKeyEncryptedUserKey when the key response isn't there.

Auth Team

Since we need the EncString in all the login strategies, it made sense to me to make the IdentityTokenResponse key a EncString. I also made it optional to indicate it isn't always expected.

If the team prefers something else, please let me know.

Platform team

I changed ProfileResponse to stay consistent with the Auth approach. If the team prefers something else, please let me know.

⏰ 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

Copy link
Contributor

github-actions bot commented Jun 4, 2025

Logo
Checkmarx One – Scan Summary & Detailsd023980e-155c-431b-8874-60ac2a8945fc

Great job, no security vulnerabilities found in this Pull Request

Copy link

codecov bot commented Jun 4, 2025

Codecov Report

Attention: Patch coverage is 65.00000% with 7 lines in your changes missing coverage. Please review.

Project coverage is 36.88%. Comparing base (9d743a7) to head (5b245f3).

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...rc/auth/models/response/identity-token.response.ts 25.00% 3 Missing ⚠️
...ibs/common/src/models/response/profile.response.ts 50.00% 2 Missing ⚠️
...s/common/src/platform/sync/default-sync.service.ts 0.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #15087      +/-   ##
==========================================
+ Coverage   36.84%   36.88%   +0.03%     
==========================================
  Files        3208     3208              
  Lines       92719    92725       +6     
  Branches    13935    13939       +4     
==========================================
+ Hits        34164    34197      +33     
+ Misses      57150    57120      -30     
- Partials     1405     1408       +3     

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

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Thomas-Avery Thomas-Avery changed the title [PM-22408] [PM-22408] Remove setMasterKeyEncryptedUserKey from KeyService Jun 5, 2025
@Thomas-Avery Thomas-Avery self-assigned this Jun 6, 2025
@Thomas-Avery Thomas-Avery marked this pull request as ready for review June 6, 2025 20:35
@Thomas-Avery Thomas-Avery requested review from a team as code owners June 6, 2025 20:35
Copy link

sonarqubecloud bot commented Jun 6, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants