[PM-37886] refactor: Pass keyConnectorKeyWrappedUserKey through LoginUnlockMethod instead of persisting in state#2764
Conversation
…UnlockMethod instead of persisting in state
🤖 Bitwarden Claude Code ReviewOverall Assessment: APPROVE This is a focused refactor that threads Code Review DetailsNo findings. |
🎟️ Tracking
PM-37886
📔 Objective
When a user logs in with key connector, their
keyConnectorKeyWrappedUserKeyis being persisted to the device asencryptedUserKey. For key connector, once the user is logged in and the vault is unlocked, this key is no longer used. As such, it doesn't need to be persisted.Additional context: #2677 (comment)
This updates the key connector flows to pass the
keyConnectorKeyWrappedUserKeyfrom the login response throughLoginUnlockMethod.keyConnector, which can then be used to unlock the vault inAuthRepository.unlockVaultWithKeyConnectorKey().LoginUnlockMethod.keyConnectornow carriesencryptedUserKey: String?populated fromresponse.keyinAuthService.unlockMethod(for:), eliminating the need to read it back from state during unlock.AuthRepository.unlockVaultWithKeyConnectorKeyaccepts a non-optionalencryptedUserKey: Stringparameter directly, removing the redundantgetAccountEncryptionKeysstate read.KeyConnectorService.convertNewUserToKeyConnectorno longer persistsencryptedUserKeyto state (both v1 and v2 paths); thecryptographicState(private key) is still persisted as required for future operations.SingleSignOnProcessornow uses an explicitguard let encryptedUserKeyto trigger the key connector migration dialog for new users, replacing the implicitnoAccountCryptographicStateerror path.