mirror of
https://github.com/bitwarden/browser
synced 2025-12-11 22:03:36 +00:00
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:
@@ -13,6 +13,10 @@ import {
|
|||||||
// Represents data in state service pre-migration
|
// Represents data in state service pre-migration
|
||||||
function preMigrationJson() {
|
function preMigrationJson() {
|
||||||
return {
|
return {
|
||||||
|
// desktop only global data format
|
||||||
|
"global.vaultTimeout": -1,
|
||||||
|
"global.vaultTimeoutAction": "lock",
|
||||||
|
|
||||||
global: {
|
global: {
|
||||||
vaultTimeout: 30,
|
vaultTimeout: 30,
|
||||||
vaultTimeoutAction: "lock",
|
vaultTimeoutAction: "lock",
|
||||||
@@ -267,6 +271,10 @@ describe("VaultTimeoutSettingsServiceStateProviderMigrator", () => {
|
|||||||
otherStuff: "otherStuff",
|
otherStuff: "otherStuff",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Expect we removed desktop specially formatted global data
|
||||||
|
expect(helper.remove).toHaveBeenCalledWith("global\\.vaultTimeout");
|
||||||
|
expect(helper.remove).toHaveBeenCalledWith("global\\.vaultTimeoutAction");
|
||||||
|
|
||||||
// User data
|
// User data
|
||||||
expect(helper.set).toHaveBeenCalledWith("user1", {
|
expect(helper.set).toHaveBeenCalledWith("user1", {
|
||||||
settings: {
|
settings: {
|
||||||
|
|||||||
@@ -122,10 +122,15 @@ export class VaultTimeoutSettingsServiceStateProviderMigrator extends Migrator<6
|
|||||||
|
|
||||||
await Promise.all([...accounts.map(({ userId, account }) => migrateAccount(userId, account))]);
|
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?.vaultTimeout;
|
||||||
delete globalData?.vaultTimeoutAction;
|
delete globalData?.vaultTimeoutAction;
|
||||||
await helper.set("global", globalData);
|
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> {
|
async rollback(helper: MigrationHelper): Promise<void> {
|
||||||
|
|||||||
Reference in New Issue
Block a user