Auth/PM-5501 - VaultTimeoutSettingsSvc State Provider Migration - Cleanup desktop orphaned data (#9277)

* PM-5501 - Remove global vault timeout data on desktop to avoid orphaning the data.

* PM-5501 - Test new migration logic.
This commit is contained in:
Jared Snider 2024-05-21 09:53:40 -04:00 committed by GitHub
parent 56c4be4f1a
commit 00db087cee
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 1 deletions

View File

@ -13,6 +13,10 @@ import {
// Represents data in state service pre-migration
function preMigrationJson() {
return {
// desktop only global data format
"global.vaultTimeout": -1,
"global.vaultTimeoutAction": "lock",
global: {
vaultTimeout: 30,
vaultTimeoutAction: "lock",
@ -267,6 +271,10 @@ describe("VaultTimeoutSettingsServiceStateProviderMigrator", () => {
otherStuff: "otherStuff",
});
// Expect we removed desktop specially formatted global data
expect(helper.remove).toHaveBeenCalledWith("global\\.vaultTimeout");
expect(helper.remove).toHaveBeenCalledWith("global\\.vaultTimeoutAction");
// User data
expect(helper.set).toHaveBeenCalledWith("user1", {
settings: {

View File

@ -122,10 +122,15 @@ export class VaultTimeoutSettingsServiceStateProviderMigrator extends Migrator<6
await Promise.all([...accounts.map(({ userId, account }) => migrateAccount(userId, account))]);
// Delete global data
// Delete global data (works for browser extension and web; CLI doesn't have these as global settings).
delete globalData?.vaultTimeout;
delete globalData?.vaultTimeoutAction;
await helper.set("global", globalData);
// Remove desktop only settings. These aren't found by the above global key removal b/c of
// the different storage key format. This removal does not cause any issues on migrating for other clients.
await helper.remove("global\\.vaultTimeout");
await helper.remove("global\\.vaultTimeoutAction");
}
async rollback(helper: MigrationHelper): Promise<void> {