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-17487] Load cipher data into new notification experience #13185

Merged

Conversation

dan-livefront
Copy link
Collaborator

@dan-livefront dan-livefront commented Jan 31, 2025

  • Implement new getNotificationCipherData function in background
  • Update stories to match new naming
  • Edit types to be relevant to current functionality

🎟️ Tracking

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

📔 Objective

The objective of this PR is to get the relevant Cipher Data into the new notification bar experience, the approach taken was to create a NotificationCipherData type that use the relevant cipher data for login for each url without the need of excess data. Leveraged existing functions and patterns.

📸 Screenshots

Screenshot 2025-01-31 at 12 11 57 PM

⏰ 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

- Implement new getNotificationCipherData function in background
- Update stories to match new naming
- Edit types to be relevant to current functionality
Copy link
Contributor

github-actions bot commented Jan 31, 2025

Logo
Checkmarx One – Scan Summary & Details01ad92f2-c844-4c3a-b537-b70994c1816b

New Issues (2)

Checkmarx found the following issues in this Pull Request

Severity Issue Source File / Package Checkmarx Insight
MEDIUM CVE-2024-55565 Npm-nanoid-3.3.7 Vulnerable Package
MEDIUM Client_Privacy_Violation /apps/desktop/src/app/tools/password-generator-history.component.html: 15
detailsMethod password_generator_history_component at line 15 of /apps/desktop/src/app/tools/password-generator-history.component.html sends user informat...
Attack Vector
Fixed Issues (1)

Great job! The following issues were fixed in this Pull Request

Severity Issue Source File / Package
LOW Angular_Usage_of_Unsafe_DOM_Sanitizer /libs/components/src/avatar/avatar.component.ts: 87

Copy link

codecov bot commented Jan 31, 2025

Codecov Report

Attention: Patch coverage is 7.14286% with 13 lines in your changes missing coverage. Please review.

Project coverage is 35.05%. Comparing base (0523ce0) to head (4c0753d).
Report is 34 commits behind head on main.

Files with missing lines Patch % Lines
...src/autofill/background/notification.background.ts 11.11% 8 Missing ⚠️
...er/src/autofill/content/components/cipher/types.ts 0.00% 2 Missing ⚠️
apps/browser/src/autofill/notification/bar.ts 0.00% 2 Missing ⚠️
.../autofill/content/components/cipher/cipher-info.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #13185      +/-   ##
==========================================
- Coverage   35.41%   35.05%   -0.37%     
==========================================
  Files        3009     3036      +27     
  Lines       90815    92731    +1916     
  Branches    16877    16891      +14     
==========================================
+ Hits        32163    32503     +340     
- Misses      56185    57764    +1579     
+ Partials     2467     2464       -3     

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

@dan-livefront dan-livefront marked this pull request as ready for review January 31, 2025 18:09
@dan-livefront dan-livefront requested a review from a team as a code owner January 31, 2025 18:09
@dan-livefront dan-livefront requested a review from jprusik January 31, 2025 18:09
@jprusik jprusik changed the title PM-17487-load-cipher-data-into-new-notification-experience [PM-17487] Load cipher data into new notification experience Feb 5, 2025
Comment on lines 148 to 150
const currentTab = await BrowserApi.getTabFromCurrentWindow();
const showFavicons = await firstValueFrom(this.domainSettingsService.showFavicons$);
const env = await firstValueFrom(this.environmentService.environment$);
Copy link
Contributor

@jprusik jprusik Feb 5, 2025

Choose a reason for hiding this comment

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

small perf nit; if you want to allow async data fetching here, but still await the data collectively:

Suggested change
const currentTab = await BrowserApi.getTabFromCurrentWindow();
const showFavicons = await firstValueFrom(this.domainSettingsService.showFavicons$);
const env = await firstValueFrom(this.environmentService.environment$);
const [currentTab, showFavicons, env] = await Promise.all([
BrowserApi.getTabFromCurrentWindow(),
firstValueFrom(this.domainSettingsService.showFavicons$),
firstValueFrom(this.environmentService.environment$),
]);

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added!

@jprusik
Copy link
Contributor

jprusik commented Feb 6, 2025

TY - nice work!

@dan-livefront dan-livefront merged commit 276d9b9 into main Feb 6, 2025
35 of 36 checks passed
@dan-livefront dan-livefront deleted the PM-17487-load-cipher-data-into-new-notification-experience branch February 6, 2025 16:54
}),
document.body,
);
sendPlatformMessage({ command: "bgGetDecryptedCiphers" }, (cipherData) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Note to future code archaeologists:

We discussed including this data with the initial notification data fetch (see "initNotificationBar" message), but opted to follow this pattern for now.

* @returns {Promise<NotificationCipherData[]>}
*/

async getNotificationCipherData(): Promise<NotificationCipherData[]> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Note: passing only cipher data that is actually needed/used in the Notification context (hence the narrow naming scope)

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

Successfully merging this pull request may close these issues.

2 participants