Skip to content

refactor(storage-core): move storage files out of @bitwarden/common #15076

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 2 commits into
base: main
Choose a base branch
from

Conversation

addisonbeck
Copy link
Contributor

@addisonbeck addisonbeck commented Jun 4, 2025

🎟️ Tracking

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

📔 Objective

This PR creates a platform owned storage-core library and attempts to extract all relevant code for it from @bitwarden/common.

Currently all classes are re-exported from their original homes in @bitwarden/common. Updates to references will come on followup PRs scoped to each impacted team.

This library has no dependencies on other Bitwarden code.

📸 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

@addisonbeck addisonbeck force-pushed the storage-core-library branch 2 times, most recently from 1fdb0ab to 2fb1932 Compare June 4, 2025 17:01
Copy link
Contributor

github-actions bot commented Jun 4, 2025

Logo
Checkmarx One – Scan Summary & Details4e097f2e-b6c9-4cfb-8b30-51745a0ccc65

New Issues (1)

Checkmarx found the following issues in this Pull Request

Severity Issue Source File / Package Checkmarx Insight
MEDIUM Missing_HSTS_Header /apps/web/src/app/dirt/reports/pages/inactive-two-factor-report.component.ts: 131
detailsThe web-application does not define an HSTS header, leaving it vulnerable to attack.
ID: PJlSLvIAgFvf39MBov%2FkpgpnZHo%3D
Attack Vector

@addisonbeck addisonbeck force-pushed the storage-core-library branch 6 times, most recently from 473d3a7 to fa999c5 Compare June 4, 2025 17:43
Copy link

codecov bot commented Jun 4, 2025

Codecov Report

Attention: Patch coverage is 33.33333% with 8 lines in your changes missing coverage. Please review.

Project coverage is 36.74%. Comparing base (e8224fd) to head (9fffbc0).

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...ommon/src/platform/abstractions/storage.service.ts 0.00% 5 Missing ⚠️
...on/src/platform/services/memory-storage.service.ts 0.00% 1 Missing ⚠️
.../src/platform/services/storage-service.provider.ts 0.00% 1 Missing ⚠️
...c/platform/state/storage/memory-storage.service.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #15076      +/-   ##
==========================================
- Coverage   36.75%   36.74%   -0.01%     
==========================================
  Files        3201     3201              
  Lines       92657    92611      -46     
  Branches    13929    13924       -5     
==========================================
- Hits        34060    34034      -26     
+ Misses      57191    57172      -19     
+ Partials     1406     1405       -1     

☔ 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.

@addisonbeck addisonbeck force-pushed the storage-core-library branch from fa999c5 to 137bb21 Compare June 4, 2025 18:42
@addisonbeck addisonbeck force-pushed the storage-core-library branch 2 times, most recently from d1aa48f to 676ef09 Compare June 4, 2025 19:19
@addisonbeck addisonbeck force-pushed the storage-core-library branch from 676ef09 to 7b3006e Compare June 5, 2025 16:49
Base automatically changed from nx-plugin to main June 5, 2025 18:20
@addisonbeck addisonbeck force-pushed the storage-core-library branch from 7b3006e to 9fffbc0 Compare June 5, 2025 18:58

import { AbstractStorageService, ObservableStorageService, StorageUpdate } from "./storage.service";

export class SerializedMemoryStorageService
Copy link
Contributor Author

@addisonbeck addisonbeck Jun 5, 2025

Choose a reason for hiding this comment

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

We had two MemoryStorageServices in different places. They are nearly identical, but one worked with serialized data and the other didn't so I renamed it. This might not be the best name. These services may even be redundant.

Copy link
Member

Choose a reason for hiding this comment

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

I like it!

Copy link

sonarqubecloud bot commented Jun 5, 2025

@addisonbeck addisonbeck marked this pull request as ready for review June 5, 2025 19:16
@addisonbeck addisonbeck requested a review from a team as a code owner June 5, 2025 19:16
Copy link
Member

@justindbaur justindbaur left a comment

Choose a reason for hiding this comment

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

Love it! So excited to have our stuff in libs!!

StorageUpdateType,
StorageUpdate,
ObservableStorageService,
AbstractStorageService,
Copy link
Member

Choose a reason for hiding this comment

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

I'm thinking this might be a good opportunity for getting rid of this prefix. We could rename it to StorageService in the storage-core lib but still re-export it as AbstractStorageService for compat.

Copy link
Member

Choose a reason for hiding this comment

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

This was previously in a spec folder, in your opinion, should that continue?


import { AbstractStorageService, ObservableStorageService, StorageUpdate } from "./storage.service";

export class SerializedMemoryStorageService
Copy link
Member

Choose a reason for hiding this comment

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

I like it!

Copy link
Member

Choose a reason for hiding this comment

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

I like that this is part of the template, to help people get a start with a test but once other tests are added do you think people should keep this test. Or should it be kept and test that the things you're expecting to export are actually there?

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.

2 participants