1
0
mirror of https://github.com/bitwarden/browser synced 2026-01-07 02:53:28 +00:00
Files
browser/apps/web/src/app/platform/web-storage-service.provider.ts
Justin Baur 87c75e5ac8 [PM-6404] Initial Clear Events Code (#8029)
* Add New KeyDefinitionOption

* Add New Services

* Add WebStorageServiceProvider Tests

* Update Error Message

* Add `UserKeyDefinition`

* Fix Deserialization Helpers

* Fix KeyDefinition

* Add `UserKeyDefinition`

* Fix Deserialization Helpers

* Fix KeyDefinition

* Move `ClearEvent`

* Cleanup

* Fix Imports

* Remove `updateMock`

* Call Super in Web Implementation

* Use Better Type to Avoid Casting

* Better Error Docs

* Move StorageKey Creation to Function

* Throw Aggregated Error for Failures
2024-02-27 21:58:31 +00:00

38 lines
1.3 KiB
TypeScript

import {
AbstractStorageService,
ObservableStorageService,
} from "@bitwarden/common/platform/abstractions/storage.service";
import {
PossibleLocation,
StorageServiceProvider,
} from "@bitwarden/common/platform/services/storage-service.provider";
import {
ClientLocations,
// eslint-disable-next-line import/no-restricted-paths
} from "@bitwarden/common/platform/state/state-definition";
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);
}
}
}