1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-16 08:13:42 +00:00

Vault/pm-7580/resolve-cipher-update-race (#8806)

* Resolve updated values from updates

Uses the now returned updated values from cipher service to guarantee-return the updated cipher for CLI edits

* Use updated cipher for creation

* Use updated cipher for editing collections

* Await async methods

Cipher data more closely approximates server responses. TODO: this should really use actual response types
This commit is contained in:
Matt Gibson
2024-04-18 14:06:31 -04:00
committed by GitHub
parent d5f503a0d6
commit ce75f7b565
5 changed files with 73 additions and 50 deletions

View File

@@ -86,8 +86,7 @@ export class EditCommand {
cipherView = CipherExport.toView(req, cipherView);
const encCipher = await this.cipherService.encrypt(cipherView);
try {
await this.cipherService.updateWithServer(encCipher);
const updatedCipher = await this.cipherService.get(cipher.id);
const updatedCipher = await this.cipherService.updateWithServer(encCipher);
const decCipher = await updatedCipher.decrypt(
await this.cipherService.getKeyForCipherKeyDecryption(updatedCipher),
);
@@ -111,8 +110,7 @@ export class EditCommand {
cipher.collectionIds = req;
try {
await this.cipherService.saveCollectionsWithServer(cipher);
const updatedCipher = await this.cipherService.get(cipher.id);
const updatedCipher = await this.cipherService.saveCollectionsWithServer(cipher);
const decCipher = await updatedCipher.decrypt(
await this.cipherService.getKeyForCipherKeyDecryption(updatedCipher),
);