1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-19 09:43:23 +00:00

[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
This commit is contained in:
Justin Baur
2024-02-27 15:58:31 -06:00
committed by GitHub
parent 929b5ebec3
commit 87c75e5ac8
14 changed files with 553 additions and 10 deletions

View File

@@ -0,0 +1,36 @@
// eslint-disable-next-line import/no-restricted-paths
import { StateEventRegistrarService } from "@bitwarden/common/platform/state/state-event-registrar.service";
import { CachedServices, FactoryOptions, factory } from "./factory-options";
import {
GlobalStateProviderInitOptions,
globalStateProviderFactory,
} from "./global-state-provider.factory";
import {
StorageServiceProviderInitOptions,
storageServiceProviderFactory,
} from "./storage-service-provider.factory";
type StateEventRegistrarServiceFactoryOptions = FactoryOptions;
export type StateEventRegistrarServiceInitOptions = StateEventRegistrarServiceFactoryOptions &
GlobalStateProviderInitOptions &
StorageServiceProviderInitOptions;
export async function stateEventRegistrarServiceFactory(
cache: {
stateEventRegistrarService?: StateEventRegistrarService;
} & CachedServices,
opts: StateEventRegistrarServiceInitOptions,
): Promise<StateEventRegistrarService> {
return factory(
cache,
"stateEventRegistrarService",
opts,
async () =>
new StateEventRegistrarService(
await globalStateProviderFactory(cache, opts),
await storageServiceProviderFactory(cache, opts),
),
);
}

View File

@@ -0,0 +1,33 @@
import { StorageServiceProvider } from "@bitwarden/common/platform/services/storage-service.provider";
import { CachedServices, FactoryOptions, factory } from "./factory-options";
import {
DiskStorageServiceInitOptions,
MemoryStorageServiceInitOptions,
observableDiskStorageServiceFactory,
observableMemoryStorageServiceFactory,
} from "./storage-service.factory";
type StorageServiceProviderFactoryOptions = FactoryOptions;
export type StorageServiceProviderInitOptions = StorageServiceProviderFactoryOptions &
MemoryStorageServiceInitOptions &
DiskStorageServiceInitOptions;
export async function storageServiceProviderFactory(
cache: {
storageServiceProvider?: StorageServiceProvider;
} & CachedServices,
opts: StorageServiceProviderInitOptions,
): Promise<StorageServiceProvider> {
return factory(
cache,
"storageServiceProvider",
opts,
async () =>
new StorageServiceProvider(
await observableDiskStorageServiceFactory(cache, opts),
await observableMemoryStorageServiceFactory(cache, opts),
),
);
}