1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-16 16:23:44 +00:00

Ps/allow state provider migrations from v 9 (#7263)

* Provide missing spec helpers and fakers

* We need to be able to migrate v9 stuff to state providers
This commit is contained in:
Matt Gibson
2023-12-18 07:50:04 -05:00
committed by GitHub
parent bc1f93d098
commit 69657a5ab5
3 changed files with 60 additions and 24 deletions

View File

@@ -123,8 +123,8 @@ export class MigrationHelper {
* @returns
*/
private getUserKey(userId: string, keyDefinition: KeyDefinitionLike): string {
if (this.currentVersion < 10) {
return userKeyBuilderPre10();
if (this.currentVersion < 9) {
return userKeyBuilderPre9();
} else {
return userKeyBuilder(userId, keyDefinition);
}
@@ -137,8 +137,8 @@ export class MigrationHelper {
* @returns
*/
private getGlobalKey(keyDefinition: KeyDefinitionLike): string {
if (this.currentVersion < 10) {
return globalKeyBuilderPre10();
if (this.currentVersion < 9) {
return globalKeyBuilderPre9();
} else {
return globalKeyBuilder(keyDefinition);
}
@@ -158,8 +158,8 @@ function userKeyBuilder(userId: string, keyDefinition: KeyDefinitionLike): strin
return `user_${userId}_${keyDefinition.stateDefinition.name}_${keyDefinition.key}`;
}
function userKeyBuilderPre10(): string {
throw Error("No key builder should be used for versions prior to 10.");
function userKeyBuilderPre9(): string {
throw Error("No key builder should be used for versions prior to 9.");
}
/**
@@ -174,6 +174,6 @@ function globalKeyBuilder(keyDefinition: KeyDefinitionLike): string {
return `global_${keyDefinition.stateDefinition.name}_${keyDefinition.key}`;
}
function globalKeyBuilderPre10(): string {
throw Error("No key builder should be used for versions prior to 10.");
function globalKeyBuilderPre9(): string {
throw Error("No key builder should be used for versions prior to 9.");
}