mirror of
https://github.com/bitwarden/browser
synced 2025-12-13 06:43:35 +00:00
Fix migrated state service data (#8815)
State service held data in an encrypted pair, with potentially both encrypted and decrypted values. We want the encrypted form for these disk migrations (decrypted would always be empty on disk anyways).
This commit is contained in:
@@ -26,11 +26,13 @@ function exampleJSON() {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
ciphers: {
|
ciphers: {
|
||||||
"cipher-id-10": {
|
encrypted: {
|
||||||
id: "cipher-id-10",
|
"cipher-id-10": {
|
||||||
},
|
id: "cipher-id-10",
|
||||||
"cipher-id-11": {
|
},
|
||||||
id: "cipher-id-11",
|
"cipher-id-11": {
|
||||||
|
id: "cipher-id-11",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -150,11 +152,13 @@ describe("CipherServiceMigrator", () => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
ciphers: {
|
ciphers: {
|
||||||
"cipher-id-10": {
|
encrypted: {
|
||||||
id: "cipher-id-10",
|
"cipher-id-10": {
|
||||||
},
|
id: "cipher-id-10",
|
||||||
"cipher-id-11": {
|
},
|
||||||
id: "cipher-id-11",
|
"cipher-id-11": {
|
||||||
|
id: "cipher-id-11",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -4,7 +4,9 @@ import { Migrator } from "../migrator";
|
|||||||
type ExpectedAccountType = {
|
type ExpectedAccountType = {
|
||||||
data: {
|
data: {
|
||||||
localData?: unknown;
|
localData?: unknown;
|
||||||
ciphers?: unknown;
|
ciphers?: {
|
||||||
|
encrypted: unknown;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -37,7 +39,7 @@ export class CipherServiceMigrator extends Migrator<56, 57> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Migrate ciphers
|
//Migrate ciphers
|
||||||
const ciphers = account?.data?.ciphers;
|
const ciphers = account?.data?.ciphers?.encrypted;
|
||||||
if (ciphers != null) {
|
if (ciphers != null) {
|
||||||
await helper.setToUser(userId, CIPHERS_DISK, ciphers);
|
await helper.setToUser(userId, CIPHERS_DISK, ciphers);
|
||||||
delete account.data.ciphers;
|
delete account.data.ciphers;
|
||||||
@@ -68,7 +70,8 @@ export class CipherServiceMigrator extends Migrator<56, 57> {
|
|||||||
const ciphers = await helper.getFromUser(userId, CIPHERS_DISK);
|
const ciphers = await helper.getFromUser(userId, CIPHERS_DISK);
|
||||||
|
|
||||||
if (account.data && ciphers != null) {
|
if (account.data && ciphers != null) {
|
||||||
account.data.ciphers = ciphers;
|
account.data.ciphers ||= { encrypted: null };
|
||||||
|
account.data.ciphers.encrypted = ciphers;
|
||||||
await helper.set(userId, account);
|
await helper.set(userId, account);
|
||||||
}
|
}
|
||||||
await helper.setToUser(userId, CIPHERS_DISK, null);
|
await helper.setToUser(userId, CIPHERS_DISK, null);
|
||||||
|
|||||||
Reference in New Issue
Block a user