mirror of
https://github.com/bitwarden/browser
synced 2025-12-16 16:23:44 +00:00
fix: using undecorated service in jslib module directly
This commit is contained in:
@@ -1744,7 +1744,11 @@ const safeProviders: SafeProvider[] = [
|
|||||||
useClass: DefaultNewDeviceVerificationComponentService,
|
useClass: DefaultNewDeviceVerificationComponentService,
|
||||||
deps: [],
|
deps: [],
|
||||||
}),
|
}),
|
||||||
safeProvider(IpcSessionRepository),
|
safeProvider({
|
||||||
|
provide: IpcSessionRepository,
|
||||||
|
useClass: IpcSessionRepository,
|
||||||
|
deps: [StateProvider],
|
||||||
|
}),
|
||||||
safeProvider({
|
safeProvider({
|
||||||
provide: PremiumInterestStateService,
|
provide: PremiumInterestStateService,
|
||||||
useClass: NoopPremiumInterestStateService,
|
useClass: NoopPremiumInterestStateService,
|
||||||
|
|||||||
40
libs/common/src/platform/ipc/ipc-session-repository.spec.ts
Normal file
40
libs/common/src/platform/ipc/ipc-session-repository.spec.ts
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
import { FakeActiveUserAccessor, FakeStateProvider } from "../../../spec";
|
||||||
|
import { UserId } from "../../types/guid";
|
||||||
|
|
||||||
|
import { IpcSessionRepository } from "./ipc-session-repository";
|
||||||
|
|
||||||
|
describe("IpcSessionRepository", () => {
|
||||||
|
const userId = "user-id" as UserId;
|
||||||
|
let stateProvider!: FakeStateProvider;
|
||||||
|
let repository!: IpcSessionRepository;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
stateProvider = new FakeStateProvider(new FakeActiveUserAccessor(userId));
|
||||||
|
repository = new IpcSessionRepository(stateProvider);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("returns undefined when empty", async () => {
|
||||||
|
const result = await repository.get("BrowserBackground");
|
||||||
|
|
||||||
|
expect(result).toBeUndefined();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("saves and retrieves a session", async () => {
|
||||||
|
const session = { some: "data" };
|
||||||
|
await repository.save("BrowserBackground", session);
|
||||||
|
|
||||||
|
const result = await repository.get("BrowserBackground");
|
||||||
|
|
||||||
|
expect(result).toEqual(session);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("removes a session", async () => {
|
||||||
|
const session = { some: "data" };
|
||||||
|
await repository.save("BrowserBackground", session);
|
||||||
|
|
||||||
|
await repository.remove("BrowserBackground");
|
||||||
|
const result = await repository.get("BrowserBackground");
|
||||||
|
|
||||||
|
expect(result).toBeUndefined();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -8,6 +8,11 @@ const IPC_SESSIONS = KeyDefinition.record<object, string>(IPC_MEMORY, "ipcSessio
|
|||||||
deserializer: (value: object) => value,
|
deserializer: (value: object) => value,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementation of SDK-defined repository interface/trait. Do not use directly.
|
||||||
|
* All error handling is done by the caller (the SDK).
|
||||||
|
* For more information see IPC docs.
|
||||||
|
*/
|
||||||
export class IpcSessionRepository implements SdkIpcSessionRepository {
|
export class IpcSessionRepository implements SdkIpcSessionRepository {
|
||||||
private states: GlobalState<Record<string, object>>;
|
private states: GlobalState<Record<string, object>>;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user