Skip to content

Conversation

quexten
Copy link
Contributor

@quexten quexten commented Oct 2, 2025

🎟️ Tracking

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

📔 Objective

The initial implementation assumed that the struct of of the PasswordProtectedKeyEnvelope in crypto had to be generic, because the key context is generic w.r.t. the keys used, and the keys are only then provided by core. Because uniffy / wasm-bindgen can't handle generics, I added a non-generic wrapper struct in core, leaving us with two different "PasswordProtectedKeyEnvelopes".

This understanding was not correct. You don't actually need to make the struct generic, having just two specific functions on the impl generic to the key id's suffices, allowing us to drop the "non generic wrapper" entirely, vastly simplifing our code here. The changes are mostly removing code and moving the uniffi mapping to the crypto crate.

⏰ 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

@github-actions
Copy link
Contributor

github-actions bot commented Oct 2, 2025

Logo
Checkmarx One – Scan Summary & Details4d6cc3b1-3f93-405c-8787-d65a6b924115

Great job! No new security vulnerabilities introduced in this pull request

@codecov
Copy link

codecov bot commented Oct 2, 2025

Codecov Report

❌ Patch coverage is 41.66667% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.33%. Comparing base (2a00b72) to head (aca916a).

Files with missing lines Patch % Lines
...crypto/src/safe/password_protected_key_envelope.rs 52.94% 8 Missing ⚠️
crates/bitwarden-crypto/src/uniffi_support.rs 0.00% 5 Missing ⚠️
crates/bitwarden-core/src/uniffi_support.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #488      +/-   ##
==========================================
- Coverage   78.34%   78.33%   -0.01%     
==========================================
  Files         287      286       -1     
  Lines       28095    28084      -11     
==========================================
- Hits        22010    21999      -11     
  Misses       6085     6085              

☔ View full report in Codecov by Sentry.
📢 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@quexten quexten changed the title Remove non-generic wrapper for PasswordProtectedKeyEnvelope [PM-26534] Remove non-generic wrapper for PasswordProtectedKeyEnvelope Oct 6, 2025
@quexten quexten marked this pull request as ready for review October 14, 2025 11:46
@quexten quexten requested review from a team as code owners October 14, 2025 11:46
}

#[cfg(feature = "wasm")]
impl FromWasmAbi for PasswordProtectedKeyEnvelope {
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

@quexten quexten Oct 15, 2025

Choose a reason for hiding this comment

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

Previously, because we had the newtype wrapper, we could use tsify to auto-generate it. For just working with the type directly, I did not find a good way to use tsify other than creating a newtype in the same file, which did not seem like the right solution.

That said, tsify just generates FromWasmAbi. https://github.com/madonoharu/tsify/blob/ab399fe86761e94f99bdb57a0b18a78d54b08671/tsify-macros/src/wasm_bindgen.rs#L202

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

@Thomas-Avery Thomas-Avery Oct 15, 2025

Choose a reason for hiding this comment

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

Thank you for the context. I guess if it breaks in the future we can just follow whatever tsify comes up with to solve for it. I would like someone with more wasm bindgen experience than me to review.

Copy link
Contributor Author

@quexten quexten Oct 15, 2025

Choose a reason for hiding this comment

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

Leaving this comment open until the review from @bitwarden/team-sdk-sme

Copy link
Member

Choose a reason for hiding this comment

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

Yea it's unstable but a lot of things depends on it and we'll know if it stops compiling.

Hinton
Hinton previously approved these changes Oct 15, 2025
Thomas-Avery
Thomas-Avery previously approved these changes Oct 16, 2025
addisonbeck
addisonbeck previously approved these changes Oct 16, 2025
@quexten quexten dismissed stale reviews from addisonbeck, Thomas-Avery, and Hinton via 00dcbe4 October 20, 2025 12:09
@sonarqubecloud
Copy link

@quexten quexten requested review from Hinton and addisonbeck October 20, 2025 12:31
@quexten quexten requested a review from Thomas-Avery October 20, 2025 12:31
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.

4 participants