PM-38625: Chore: Store the WrappedAccountCryptographicState#7030
PM-38625: Chore: Store the WrappedAccountCryptographicState#7030david-livefront wants to merge 1 commit into
Conversation
🤖 Bitwarden Claude Code ReviewOverall Assessment: APPROVE This PR migrates from separately stored Code Review Details
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #7030 +/- ##
==========================================
+ Coverage 85.50% 86.80% +1.29%
==========================================
Files 1005 903 -102
Lines 66462 65029 -1433
Branches 9328 9285 -43
==========================================
- Hits 56829 56448 -381
+ Misses 6426 5383 -1043
+ Partials 3207 3198 -9
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| profile.privateKeyOrNull()?.let { privateKey -> | ||
| storeAccountCryptographicState( | ||
| userId = userId, | ||
| accountCryptographicState = profile.accountKeys.toAccountCryptographicState( | ||
| privateKey = privateKey, | ||
| ), | ||
| ) | ||
| } |
There was a problem hiding this comment.
❓ QUESTION: Sync no longer clears stored cryptographic state when the response carries null keys
Details
Previously storeProfileData unconditionally called storePrivateKey(userId, profile.privateKey) and storeAccountKeys(userId, profile.accountKeys). If a sync response returned null for those fields, the on-disk values were cleared.
The new implementation only writes when profile.privateKeyOrNull() is non-null, so a sync response with both accountKeys and the deprecated privateKey field null will leave any previously stored WrappedAccountCryptographicState untouched rather than clearing it.
Is the divergence intentional (e.g., to guard against transient null sync responses overwriting valid local state), or should we preserve the previous "clear on null" behavior by writing null to storeAccountCryptographicState when privateKeyOrNull() is null?
| val securityState = this?.securityState?.securityState | ||
| val signingKey = this?.signatureKeyPair?.wrappedSigningKey | ||
| val signedPublicKey = this?.publicKeyEncryptionKeyPair?.signedPublicKey | ||
| return if (signingKey != null && securityState != null && signedPublicKey != null) { |
There was a problem hiding this comment.
This logic has not changed but I was able to completely remove the createWrappedAccountCryptographicState() function
🎟️ Tracking
PM-38625
📔 Objective
This PR removes the
privateKeyandaccountKeysfrom our persistence layer and migrates everything we need to a newWrappedAccountCryptographicStateobject.AuthDiskSourceprivateKeyand/oraccountKeysshould now store the appropriateWrappedAccountCryptographicStateprivateKeyand/oraccountKeysshould now retrieve theWrappedAccountCryptographicState