diff --git a/libs/common/src/state-migrations/migrations/57-move-cipher-service-to-state-provider.spec.ts b/libs/common/src/state-migrations/migrations/57-move-cipher-service-to-state-provider.spec.ts index 499cff1c89a..f51699bc791 100644 --- a/libs/common/src/state-migrations/migrations/57-move-cipher-service-to-state-provider.spec.ts +++ b/libs/common/src/state-migrations/migrations/57-move-cipher-service-to-state-provider.spec.ts @@ -26,11 +26,13 @@ function exampleJSON() { }, }, ciphers: { - "cipher-id-10": { - id: "cipher-id-10", - }, - "cipher-id-11": { - id: "cipher-id-11", + encrypted: { + "cipher-id-10": { + id: "cipher-id-10", + }, + "cipher-id-11": { + id: "cipher-id-11", + }, }, }, }, @@ -150,11 +152,13 @@ describe("CipherServiceMigrator", () => { }, }, ciphers: { - "cipher-id-10": { - id: "cipher-id-10", - }, - "cipher-id-11": { - id: "cipher-id-11", + encrypted: { + "cipher-id-10": { + id: "cipher-id-10", + }, + "cipher-id-11": { + id: "cipher-id-11", + }, }, }, }, diff --git a/libs/common/src/state-migrations/migrations/57-move-cipher-service-to-state-provider.ts b/libs/common/src/state-migrations/migrations/57-move-cipher-service-to-state-provider.ts index e71d889bb79..80c776e1b69 100644 --- a/libs/common/src/state-migrations/migrations/57-move-cipher-service-to-state-provider.ts +++ b/libs/common/src/state-migrations/migrations/57-move-cipher-service-to-state-provider.ts @@ -4,7 +4,9 @@ import { Migrator } from "../migrator"; type ExpectedAccountType = { data: { localData?: unknown; - ciphers?: unknown; + ciphers?: { + encrypted: unknown; + }; }; }; @@ -37,7 +39,7 @@ export class CipherServiceMigrator extends Migrator<56, 57> { } //Migrate ciphers - const ciphers = account?.data?.ciphers; + const ciphers = account?.data?.ciphers?.encrypted; if (ciphers != null) { await helper.setToUser(userId, CIPHERS_DISK, ciphers); delete account.data.ciphers; @@ -68,7 +70,8 @@ export class CipherServiceMigrator extends Migrator<56, 57> { const ciphers = await helper.getFromUser(userId, CIPHERS_DISK); 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.setToUser(userId, CIPHERS_DISK, null);