1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-08 20:50:28 +00:00

WIP: Changes to how ciphers are replaced when migrating with SDK

This commit is contained in:
Nik Gilmore
2025-09-10 17:10:53 -07:00
parent 7f9a663040
commit f23deab376
2 changed files with 26 additions and 23 deletions

View File

@@ -384,27 +384,28 @@ export class Cipher extends Domain implements Decryptable<CipherView> {
// version: 1,
data: typeof this.data === "string" ? this.data : JSON.stringify(this.data),
};
console.log("Cipher toSdkCipher data:", sdkCipher.data, ". \n\n\nIt is of type ", typeof this.data);
// switch (this.type) {
// case CipherType.Login:
// sdkCipher.login = this.login.toSdkLogin();
// break;
// case CipherType.SecureNote:
// sdkCipher.secureNote = this.secureNote.toSdkSecureNote();
// break;
// case CipherType.Card:
// sdkCipher.card = this.card.toSdkCard();
// break;
// case CipherType.Identity:
// sdkCipher.identity = this.identity.toSdkIdentity();
// break;
// case CipherType.SshKey:
// sdkCipher.sshKey = this.sshKey.toSdkSshKey();
// break;
// default:
// break;
// }
switch (this.type) {
case CipherType.Login:
sdkCipher.login = this.login.toSdkLogin();
break;
case CipherType.SecureNote:
sdkCipher.secureNote = this.secureNote.toSdkSecureNote();
break;
case CipherType.Card:
sdkCipher.card = this.card.toSdkCard();
break;
case CipherType.Identity:
sdkCipher.identity = this.identity.toSdkIdentity();
break;
case CipherType.SshKey:
sdkCipher.sshKey = this.sshKey.toSdkSshKey();
break;
default:
break;
}
return sdkCipher;
}

View File

@@ -1133,12 +1133,14 @@ export class CipherService implements CipherServiceAbstraction {
cipherObjects,
userId,
));
// migratedCiphers.forEach((c) => (ciphers[c.id] = c.toCipherData()));
migratedCiphers.forEach((c) => (ciphers[c.id] = ciphers[c.id]));
// TODO: Something here broke loading my ciphers... need to investigate.
const res = await this.updateEncryptedCipherState((current) => {
migratedCiphers.forEach((c) => (current[c.id as CipherId] = c.toCipherData()));
return current;
}, userId);
console.log("REPLAZCE: Replacing all ciphers for user", userId);
console.log("== Replacing all ciphers for user", userId);
await this.updateEncryptedCipherState(() => ciphers, userId);
}
/**