Skip to content
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

[PM-11869] Adjust CollectionService to be reactive to keys being available #11144

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

Conversation

eliykat
Copy link
Member

@eliykat eliykat commented Sep 19, 2024

🎟️ Tracking

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

📔 Objective

Currently, CollectionService tries to decrypt collections as soon as they're available from state, without organization keys necessarily being available. This can cause decryption errors.

This PR refactors CollectionService so that it uses reactive data for both collection state and org keys and only decrypts once both are available.

This code is fairly dense, so a brief explanation of changes:

  1. change the DECRYPTED_COLLECTION_DATA_KEY definition to take a different observable as its input, instead of the encrypted state
  2. pass both collectionData and the orgKeys to the getDerived call
  3. change the decryptMany method signature to optionally accept keys that are passed in

📸 Screenshots

⏰ 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

@eliykat eliykat requested a review from a team as a code owner September 19, 2024 04:42
Copy link
Contributor

github-actions bot commented Sep 19, 2024

Logo
Checkmarx One – Scan Summary & Detailsd5027a70-b6e3-4c04-82aa-be1217a46ee7

No New Or Fixed Issues Found

eliykat and others added 2 commits September 19, 2024 18:59
Copy link

codecov bot commented Sep 19, 2024

Codecov Report

Attention: Patch coverage is 73.33333% with 4 lines in your changes missing coverage. Please review.

Project coverage is 35.10%. Comparing base (6484460) to head (d782137).

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...bs/common/src/vault/services/collection.service.ts 73.33% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #11144      +/-   ##
==========================================
+ Coverage   35.07%   35.10%   +0.03%     
==========================================
  Files        2710     2710              
  Lines       84542    84542              
  Branches    16064    16065       +1     
==========================================
+ Hits        29653    29680      +27     
+ Misses      53918    53891      -27     
  Partials      971      971              

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

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.

1 participant