1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-15 15:53:27 +00:00

Use Memory Storage directly in Session Sync (#4423)

* Use Memory Storage directly in Session Sync

* Update apps/browser/src/decorators/session-sync-observable/browser-session.decorator.spec.ts

Co-authored-by: Justin Baur <19896123+justindbaur@users.noreply.github.com>

* Fix up test

Co-authored-by: Justin Baur <19896123+justindbaur@users.noreply.github.com>
This commit is contained in:
Matt Gibson
2023-01-12 15:39:33 -05:00
committed by GitHub
parent 508979df89
commit 23897ae5fb
17 changed files with 146 additions and 154 deletions

View File

@@ -7,10 +7,11 @@ export abstract class AbstractStorageService {
abstract remove(key: string, options?: StorageOptions): Promise<void>;
}
export abstract class AbstractCachedStorageService extends AbstractStorageService {
export abstract class AbstractMemoryStorageService extends AbstractStorageService {
// Used to identify the service in the session sync decorator framework
static readonly TYPE = "MemoryStorageService";
readonly type = AbstractMemoryStorageService.TYPE;
abstract get<T>(key: string, options?: MemoryStorageOptions<T>): Promise<T>;
abstract getBypassCache<T>(key: string, options?: MemoryStorageOptions<T>): Promise<T>;
}
export interface MemoryStorageServiceInterface {
get<T>(key: string, options?: MemoryStorageOptions<T>): Promise<T>;
}

View File

@@ -1,12 +1,6 @@
import {
AbstractStorageService,
MemoryStorageServiceInterface,
} from "../abstractions/storage.service";
import { AbstractMemoryStorageService } from "../abstractions/storage.service";
export class MemoryStorageService
extends AbstractStorageService
implements MemoryStorageServiceInterface
{
export class MemoryStorageService extends AbstractMemoryStorageService {
private store = new Map<string, any>();
get<T>(key: string): Promise<T> {
@@ -33,4 +27,8 @@ export class MemoryStorageService
this.store.delete(key);
return Promise.resolve();
}
getBypassCache<T>(key: string): Promise<T> {
return this.get<T>(key);
}
}

View File

@@ -5,7 +5,7 @@ import { LogService } from "../abstractions/log.service";
import { StateService as StateServiceAbstraction } from "../abstractions/state.service";
import { StateMigrationService } from "../abstractions/stateMigration.service";
import {
MemoryStorageServiceInterface,
AbstractMemoryStorageService,
AbstractStorageService,
} from "../abstractions/storage.service";
import { HtmlStorageLocation } from "../enums/htmlStorageLocation";
@@ -87,7 +87,7 @@ export class StateService<
constructor(
protected storageService: AbstractStorageService,
protected secureStorageService: AbstractStorageService,
protected memoryStorageService: AbstractStorageService & MemoryStorageServiceInterface,
protected memoryStorageService: AbstractMemoryStorageService,
protected logService: LogService,
protected stateMigrationService: StateMigrationService,
protected stateFactory: StateFactory<TGlobalState, TAccount>,