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

Stores: Remove StoreCipher::{en,de}crypt_value_[base64_]typed #3638

Merged
merged 6 commits into from
Jul 3, 2024

Conversation

richvdh
Copy link
Member

@richvdh richvdh commented Jul 2, 2024

StoreCipher's interface has grown baroque over the years. These four functions aren't giving a whole lot of value: they are only used in a couple of places in the codebase, and are pretty simple.

This PR is a mission to clean that up.

Review commit-by-commit.

reuse `IndexeddbSerializer::maybe_encrypt_value` instead of re-inventing it.
Instead of un-base64-ing and calling `decrypt_value_typed` (which deserializes
the result`), call `decrypt_value_base64_data` (which un-base64s before
decrypting but does not deserialize the result), then deserialize.

This makes it more symmetrical with `encrypt_value_base64_typed`, and helps me
get rid of `decrypt_value_typed` (which is barely used.)
looks like they got C&Ped from `encrypt_value_typed`.
Each of these are quite simple, are only used in two places, and their
existence melts my brain.
... to use `en/decrypt_value_base64_data` instead of
`en/decrypt_value_base64_typed`.

We have to have the de/serialization code for the unencrypted case anyway, so
using the higher-level method isn't helping us much.
Outside of tests, these things are totally unused.
@richvdh richvdh requested a review from a team as a code owner July 2, 2024 12:31
@richvdh richvdh requested review from Hywan and removed request for a team July 2, 2024 12:31
Copy link

codecov bot commented Jul 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.22%. Comparing base (263c86b) to head (f8761de).
Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3638      +/-   ##
==========================================
+ Coverage   84.19%   84.22%   +0.03%     
==========================================
  Files         256      256              
  Lines       26594    26585       -9     
==========================================
+ Hits        22391    22392       +1     
+ Misses       4203     4193      -10     

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

/// assert_eq!(value, decrypted);
/// # anyhow::Ok(()) };
/// ```
pub fn decrypt_value_typed<T: DeserializeOwned>(
Copy link
Contributor

@poljar poljar Jul 2, 2024

Choose a reason for hiding this comment

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

Removing this removes the ability to use the StoreCipher with more efficient serialization formats, which at least one user used in the past: #688.

Also, we wanted to remove the other, the JSON based, methods: #718.

While I understand the baroqueness argument and the poor naming of the methods I don't think I'd want to remove this functionality.

Copy link
Member Author

@richvdh richvdh Jul 2, 2024

Choose a reason for hiding this comment

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

Removing this removes the ability to use the StoreCipher with more efficient serialization formats, which at least one user used in the past: #688.

Well, you can use encrypt_value_data instead?

Also, we wanted to remove the other, the JSON based, methods: #718.

While I understand the baroqueness argument and the poor naming of the methods I don't think I'd want to remove this functionality.

Well, I'd quite like to get rid of encrypt_value and decrypt_value as well; I just didn't get that far.

Per my note on #718, I'm slightly confused about what it's asking for. In particular I note that #3086 deprecated encrypt_value_typed. Has your thinking changed here?

Copy link
Contributor

Choose a reason for hiding this comment

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

Well, you can use encrypt_value_data instead?

Ah indeed, we still have that one. Then I don't have any objections.

@richvdh richvdh merged commit 5d716f9 into main Jul 3, 2024
39 checks passed
@richvdh richvdh deleted the rav/store_cipher_cleanup branch July 3, 2024 08:42
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