mirror of
https://github.com/bitwarden/browser
synced 2026-01-06 10:33:57 +00:00
33 lines
1.1 KiB
TypeScript
33 lines
1.1 KiB
TypeScript
import {
|
|
AbstractStorageService,
|
|
ClientLocations,
|
|
ObservableStorageService,
|
|
PossibleLocation,
|
|
StorageServiceProvider,
|
|
} from "@bitwarden/storage-core";
|
|
|
|
export class WebStorageServiceProvider extends StorageServiceProvider {
|
|
constructor(
|
|
diskStorageService: AbstractStorageService & ObservableStorageService,
|
|
memoryStorageService: AbstractStorageService & ObservableStorageService,
|
|
private readonly diskLocalStorageService: AbstractStorageService & ObservableStorageService,
|
|
) {
|
|
super(diskStorageService, memoryStorageService);
|
|
}
|
|
|
|
override get(
|
|
defaultLocation: PossibleLocation,
|
|
overrides: Partial<ClientLocations>,
|
|
): [location: PossibleLocation, service: AbstractStorageService & ObservableStorageService] {
|
|
const location = overrides["web"] ?? defaultLocation;
|
|
switch (location) {
|
|
case "disk-local":
|
|
return ["disk-local", this.diskLocalStorageService];
|
|
default:
|
|
// Pass in computed location to super because they could have
|
|
// overriden default "disk" with web "memory".
|
|
return super.get(location, overrides);
|
|
}
|
|
}
|
|
}
|