Update SDK to 3.0.0-8379-cc7daf10 - #7267
Conversation
|
Claude finished @bw-ghapp[bot]'s task in 9m 37s —— View job SDK bump evaluated
Verification run on this checkout:
Compile-time breaksNone found. The one change that required Android work — the state bridge's new Two other records gained fields without breaking Kotlin construction:
Runtime considerations1. The SDK now records the id of the wrapping key (org key for org ciphers, user key otherwise) at encrypt time, and its own Not a regression — the field is optional server-side and Android never sent it. But the SDK comment is explicit that "the server uses it to reject writes made under a wrong key," so once that validation is enforced for V2 accounts, Android cipher writes would start failing. Wiring it up is feature work with a rollout/flagging call attached (which V2 flag gates it, whether the network contract change ships now), so I've flagged it rather than guessed. Fix this → 2. Persisting the user key id is the right call, and the lock/unlock caveat from my earlier comment doesn't apply
3. New backfill API is available but uncalled — bitwarden/sdk-internal#1388 adds uniffi-exported Everything else in range — confirmed safe
CommitNo commit — nothing needed fixing. Working tree clean; the state bridge work this bump required was already committed to this branch. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7267 +/- ##
==========================================
- Coverage 86.25% 86.25% -0.01%
==========================================
Files 891 891
Lines 65294 65302 +8
Branches 9808 9808
==========================================
+ Hits 56320 56326 +6
- Misses 5472 5474 +2
Partials 3502 3502
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:
|
38524d6 to
8f9474d
Compare
8f9474d to
6d95b62
Compare
The SDK's state_bridge! macro gained a user_key_id slot in bitwarden/sdk-internal#1388, adding setUserKeyId/getUserKeyId/ clearUserKeyId to the StateBridgeForeignImpl callback interface. Nothing on Android reads the user key id yet, so it is held in memory alongside the user key rather than persisted to AuthDiskSource.
| private var inMemoryUserKey: SymmetricCryptoKey? = null | ||
|
|
||
| @Volatile | ||
| private var inMemoryUserKeyId: String? = null |
There was a problem hiding this comment.
This should not be volatile, but persisted to disk.
There was a problem hiding this comment.
@claude Please persist the user key id to disk instead of making it volatile. The key id should be persisted.
There was a problem hiding this comment.
Claude finished @quexten's task in 5m 24s —— View job
User key id is now persisted
- Read
SdkStateBridgeand theAuthDiskSourcepersistence patterns - Add a persisted
userKeyIdslot toAuthDiskSource/AuthDiskSourceImpl - Wire
SdkStateBridgeset/get/clear through the disk source - Update
FakeAuthDiskSourceand tests -
Build + run tests— gradle is not in this run's allowed tools (see note below) - Commit and push —
8b27a1a
What changed
AuthDiskSource / AuthDiskSourceImpl — new per-user slot alongside the other cryptographic state:
private const val USER_KEY_ID_KEY = "userKeyId"
override fun getUserKeyId(userId: String): String? =
getString(key = USER_KEY_ID_KEY.appendIdentifier(userId))
override fun storeUserKeyId(userId: String, userKeyId: String?) {
putString(key = USER_KEY_ID_KEY.appendIdentifier(userId), value = userKeyId)
}SdkStateBridge (app/.../sdk/statebridge/SdkStateBridge.kt:42-51) — the @Volatile inMemoryUserKeyId field and the "not persisted" comment are gone; the three callbacks now delegate to the disk source, matching how setEncryptedPin/setV2UpgradeToken/setPersistentPinEnvelope already behave:
override suspend fun setUserKeyId(value: String) {
authDiskSource.storeUserKeyId(userId = userId, userKeyId = value)
}
override suspend fun getUserKeyId(): String? = authDiskSource.getUserKeyId(userId = userId)
override suspend fun clearUserKeyId() {
authDiskSource.storeUserKeyId(userId = userId, userKeyId = null)
}clearData(userId) now clears the key id too (AuthDiskSourceImpl.kt:205), so it is wiped along with the rest of the user's data on logout via UserLogoutManager. The inMemoryUserKey slot is deliberately left volatile — that one is actual key material and must not touch disk.
Tests — SdkStateBridgeTest now asserts against the disk source rather than a round-trip through the bridge, FakeAuthDiskSource gained the backing map plus an assertUserKeyId helper and clears the slot in clearData, and AuthDiskSourceTest gained getUserKeyId/storeUserKeyId SharedPreferences tests plus a clearData assertion.
Two things worth your call
- Plain vs. encrypted preferences. I used
putString/getString(plainbwPreferencesStorage), notputEncryptedString. The key id is an identifier the server already knows, not key material, and this matches howv2UpgradeTokenand the persistent PIN envelope are stored. Say the word if you'd rather it live in the encrypted store. clearUserKeyIdnow erases the persisted value. That is the literal bridge contract, but note the SDK calls it whenever it tears down the user's crypto state — so if it fires on lock rather than only on logout, the id won't survive a lock/unlock cycle. Worth a look from the SDK side; I didn't add any Android-side special-casing.
Verification
I could not run ./gradlew in this job — every gradle invocation was rejected with "This command requires approval", unlike the earlier run on this PR. So the changes are not compile- or test-verified locally; the change is small and mechanical (interface method + impl + fake + delegation), but CI on this push is the actual check. If you want me to verify locally on a future run, gradle needs to be added to --allowedTools.
· branch sdlc/sdk-update
The user key id slot on the state bridge was held in memory only, so the id the server knows was lost on every process restart. Route it through AuthDiskSource so it survives restarts and is cleared with the rest of the user's data on logout. Co-authored-by: Bernd Schoolmann <11866552+quexten@users.noreply.github.com>
Updates the SDK version from
3.0.0-8288-99ffb6eftocom.bitwarden:sdk-android 3.0.0-8379-cc7daf10What's Changed
Raw changelog