Skip to content

Commit 1869d83

Browse files
committed
Implement removal of stale secure storage keys during state migration to ensure clean state management.
1 parent 337ff31 commit 1869d83

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

libs/services/state-service/stateMigration.service.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,23 @@ export class StateMigrationService {
305305
// await this.secureStorageService.remove(oldKey);
306306
}
307307
}
308+
309+
// migrateStateFrom1To2 stored ALL SecureStorageKeys under `${userId}_*`, including
310+
// non-credential keys (sync config, directory type, org ID, directory config prefix).
311+
// Their values are already migrated above via the account object into regular storage,
312+
// so remove these stale credential-store entries unconditionally.
313+
const staleSecureKeys = [
314+
`${clientId}_${SecureStorageKeys.directoryConfigPrefix}`,
315+
`${clientId}_${SecureStorageKeys.sync}`,
316+
`${clientId}_${SecureStorageKeys.directoryType}`,
317+
`${clientId}_${SecureStorageKeys.organizationId}`,
318+
];
319+
320+
for (const staleKey of staleSecureKeys) {
321+
if (await this.secureStorageService.has(staleKey)) {
322+
await this.secureStorageService.remove(staleKey);
323+
}
324+
}
308325
}
309326

310327
// Migrate window/tray settings from globals object

0 commit comments

Comments
 (0)