mirror of
https://github.com/bitwarden/browser
synced 2025-12-21 10:43:35 +00:00
Merge branch 'main' into autofill/pm-5189-fix-issues-present-with-inline-menu-rendering-in-iframes
This commit is contained in:
@@ -38,9 +38,7 @@ const config: StorybookConfig = {
|
|||||||
},
|
},
|
||||||
env: (config) => ({
|
env: (config) => ({
|
||||||
...config,
|
...config,
|
||||||
FLAGS: JSON.stringify({
|
FLAGS: JSON.stringify({}),
|
||||||
secretsManager: true,
|
|
||||||
}),
|
|
||||||
}),
|
}),
|
||||||
webpackFinal: async (config, { configType }) => {
|
webpackFinal: async (config, { configType }) => {
|
||||||
if (config.resolve) {
|
if (config.resolve) {
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import { CipherService } from "@bitwarden/common/vault/services/cipher.service";
|
|||||||
import { FolderService } from "@bitwarden/common/vault/services/folder/folder.service";
|
import { FolderService } from "@bitwarden/common/vault/services/folder/folder.service";
|
||||||
|
|
||||||
import { BrowserApi } from "../../platform/browser/browser-api";
|
import { BrowserApi } from "../../platform/browser/browser-api";
|
||||||
import { BrowserStateService } from "../../platform/services/browser-state.service";
|
import { DefaultBrowserStateService } from "../../platform/services/default-browser-state.service";
|
||||||
import { NotificationQueueMessageType } from "../enums/notification-queue-message-type.enum";
|
import { NotificationQueueMessageType } from "../enums/notification-queue-message-type.enum";
|
||||||
import { FormData } from "../services/abstractions/autofill.service";
|
import { FormData } from "../services/abstractions/autofill.service";
|
||||||
import AutofillService from "../services/autofill.service";
|
import AutofillService from "../services/autofill.service";
|
||||||
@@ -49,7 +49,7 @@ describe("NotificationBackground", () => {
|
|||||||
const authService = mock<AuthService>();
|
const authService = mock<AuthService>();
|
||||||
const policyService = mock<PolicyService>();
|
const policyService = mock<PolicyService>();
|
||||||
const folderService = mock<FolderService>();
|
const folderService = mock<FolderService>();
|
||||||
const stateService = mock<BrowserStateService>();
|
const stateService = mock<DefaultBrowserStateService>();
|
||||||
const userNotificationSettingsService = mock<UserNotificationSettingsService>();
|
const userNotificationSettingsService = mock<UserNotificationSettingsService>();
|
||||||
const domainSettingsService = mock<DomainSettingsService>();
|
const domainSettingsService = mock<DomainSettingsService>();
|
||||||
const environmentService = mock<EnvironmentService>();
|
const environmentService = mock<EnvironmentService>();
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
|
|||||||
import { CipherService } from "@bitwarden/common/vault/services/cipher.service";
|
import { CipherService } from "@bitwarden/common/vault/services/cipher.service";
|
||||||
|
|
||||||
import { BrowserApi } from "../../platform/browser/browser-api";
|
import { BrowserApi } from "../../platform/browser/browser-api";
|
||||||
import { BrowserStateService } from "../../platform/services/browser-state.service";
|
import { DefaultBrowserStateService } from "../../platform/services/default-browser-state.service";
|
||||||
import { BrowserPlatformUtilsService } from "../../platform/services/platform-utils/browser-platform-utils.service";
|
import { BrowserPlatformUtilsService } from "../../platform/services/platform-utils/browser-platform-utils.service";
|
||||||
import { AutofillService } from "../services/abstractions/autofill.service";
|
import { AutofillService } from "../services/abstractions/autofill.service";
|
||||||
import {
|
import {
|
||||||
@@ -77,7 +77,7 @@ describe("OverlayBackground", () => {
|
|||||||
urls: { icons: "https://icons.bitwarden.com/" },
|
urls: { icons: "https://icons.bitwarden.com/" },
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
const stateService = mock<BrowserStateService>();
|
const stateService = mock<DefaultBrowserStateService>();
|
||||||
const autofillSettingsService = mock<AutofillSettingsService>();
|
const autofillSettingsService = mock<AutofillSettingsService>();
|
||||||
const i18nService = mock<I18nService>();
|
const i18nService = mock<I18nService>();
|
||||||
const platformUtilsService = mock<BrowserPlatformUtilsService>();
|
const platformUtilsService = mock<BrowserPlatformUtilsService>();
|
||||||
|
|||||||
@@ -211,7 +211,7 @@ import BrowserLocalStorageService from "../platform/services/browser-local-stora
|
|||||||
import BrowserMemoryStorageService from "../platform/services/browser-memory-storage.service";
|
import BrowserMemoryStorageService from "../platform/services/browser-memory-storage.service";
|
||||||
import BrowserMessagingPrivateModeBackgroundService from "../platform/services/browser-messaging-private-mode-background.service";
|
import BrowserMessagingPrivateModeBackgroundService from "../platform/services/browser-messaging-private-mode-background.service";
|
||||||
import BrowserMessagingService from "../platform/services/browser-messaging.service";
|
import BrowserMessagingService from "../platform/services/browser-messaging.service";
|
||||||
import { BrowserStateService } from "../platform/services/browser-state.service";
|
import { DefaultBrowserStateService } from "../platform/services/default-browser-state.service";
|
||||||
import I18nService from "../platform/services/i18n.service";
|
import I18nService from "../platform/services/i18n.service";
|
||||||
import { LocalBackedSessionStorageService } from "../platform/services/local-backed-session-storage.service";
|
import { LocalBackedSessionStorageService } from "../platform/services/local-backed-session-storage.service";
|
||||||
import { BackgroundPlatformUtilsService } from "../platform/services/platform-utils/background-platform-utils.service";
|
import { BackgroundPlatformUtilsService } from "../platform/services/platform-utils/background-platform-utils.service";
|
||||||
@@ -466,7 +466,7 @@ export default class MainBackground {
|
|||||||
new MigrationBuilderService(),
|
new MigrationBuilderService(),
|
||||||
);
|
);
|
||||||
|
|
||||||
this.stateService = new BrowserStateService(
|
this.stateService = new DefaultBrowserStateService(
|
||||||
this.storageService,
|
this.storageService,
|
||||||
this.secureStorageService,
|
this.secureStorageService,
|
||||||
this.memoryStorageService,
|
this.memoryStorageService,
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import {
|
|||||||
TokenServiceInitOptions,
|
TokenServiceInitOptions,
|
||||||
} from "../../../auth/background/service-factories/token-service.factory";
|
} from "../../../auth/background/service-factories/token-service.factory";
|
||||||
import { Account } from "../../../models/account";
|
import { Account } from "../../../models/account";
|
||||||
import { BrowserStateService } from "../../services/browser-state.service";
|
import { DefaultBrowserStateService } from "../../services/default-browser-state.service";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
environmentServiceFactory,
|
environmentServiceFactory,
|
||||||
@@ -46,15 +46,15 @@ export type StateServiceInitOptions = StateServiceFactoryOptions &
|
|||||||
MigrationRunnerInitOptions;
|
MigrationRunnerInitOptions;
|
||||||
|
|
||||||
export async function stateServiceFactory(
|
export async function stateServiceFactory(
|
||||||
cache: { stateService?: BrowserStateService } & CachedServices,
|
cache: { stateService?: DefaultBrowserStateService } & CachedServices,
|
||||||
opts: StateServiceInitOptions,
|
opts: StateServiceInitOptions,
|
||||||
): Promise<BrowserStateService> {
|
): Promise<DefaultBrowserStateService> {
|
||||||
const service = await factory(
|
const service = await factory(
|
||||||
cache,
|
cache,
|
||||||
"stateService",
|
"stateService",
|
||||||
opts,
|
opts,
|
||||||
async () =>
|
async () =>
|
||||||
new BrowserStateService(
|
new DefaultBrowserStateService(
|
||||||
await diskStorageServiceFactory(cache, opts),
|
await diskStorageServiceFactory(cache, opts),
|
||||||
await secureStorageServiceFactory(cache, opts),
|
await secureStorageServiceFactory(cache, opts),
|
||||||
await memoryStorageServiceFactory(cache, opts),
|
await memoryStorageServiceFactory(cache, opts),
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { BehaviorSubject } from "rxjs";
|
|||||||
import { AbstractMemoryStorageService } from "@bitwarden/common/platform/abstractions/storage.service";
|
import { AbstractMemoryStorageService } from "@bitwarden/common/platform/abstractions/storage.service";
|
||||||
import { MemoryStorageService } from "@bitwarden/common/platform/services/memory-storage.service";
|
import { MemoryStorageService } from "@bitwarden/common/platform/services/memory-storage.service";
|
||||||
|
|
||||||
import { BrowserStateService } from "../../services/browser-state.service";
|
import { DefaultBrowserStateService } from "../../services/default-browser-state.service";
|
||||||
|
|
||||||
import { browserSession } from "./browser-session.decorator";
|
import { browserSession } from "./browser-session.decorator";
|
||||||
import { SessionStorable } from "./session-storable";
|
import { SessionStorable } from "./session-storable";
|
||||||
@@ -25,7 +25,7 @@ describe("browserSession decorator", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should create if StateService is a constructor argument", () => {
|
it("should create if StateService is a constructor argument", () => {
|
||||||
const stateService = Object.create(BrowserStateService.prototype, {
|
const stateService = Object.create(DefaultBrowserStateService.prototype, {
|
||||||
memoryStorageService: {
|
memoryStorageService: {
|
||||||
value: Object.create(MemoryStorageService.prototype, {
|
value: Object.create(MemoryStorageService.prototype, {
|
||||||
type: { value: MemoryStorageService.TYPE },
|
type: { value: MemoryStorageService.TYPE },
|
||||||
@@ -35,7 +35,7 @@ describe("browserSession decorator", () => {
|
|||||||
|
|
||||||
@browserSession
|
@browserSession
|
||||||
class TestClass {
|
class TestClass {
|
||||||
constructor(private stateService: BrowserStateService) {}
|
constructor(private stateService: DefaultBrowserStateService) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(new TestClass(stateService)).toBeDefined();
|
expect(new TestClass(stateService)).toBeDefined();
|
||||||
|
|||||||
@@ -11,13 +11,13 @@ import { GroupPolicyEnvironment } from "../admin-console/types/group-policy-envi
|
|||||||
import { BrowserApi } from "./browser/browser-api";
|
import { BrowserApi } from "./browser/browser-api";
|
||||||
|
|
||||||
// required to avoid linting errors when there are no flags
|
// required to avoid linting errors when there are no flags
|
||||||
/* eslint-disable-next-line @typescript-eslint/ban-types */
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||||
export type Flags = {
|
export type Flags = {
|
||||||
accountSwitching?: boolean;
|
accountSwitching?: boolean;
|
||||||
} & SharedFlags;
|
} & SharedFlags;
|
||||||
|
|
||||||
// required to avoid linting errors when there are no flags
|
// required to avoid linting errors when there are no flags
|
||||||
/* eslint-disable-next-line @typescript-eslint/ban-types */
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||||
export type DevFlags = {
|
export type DevFlags = {
|
||||||
storeSessionDecrypted?: boolean;
|
storeSessionDecrypted?: boolean;
|
||||||
managedEnvironment?: GroupPolicyEnvironment;
|
managedEnvironment?: GroupPolicyEnvironment;
|
||||||
|
|||||||
@@ -8,6 +8,23 @@ import {
|
|||||||
|
|
||||||
import { fromChromeEvent } from "../../browser/from-chrome-event";
|
import { fromChromeEvent } from "../../browser/from-chrome-event";
|
||||||
|
|
||||||
|
export const serializationIndicator = "__json__";
|
||||||
|
|
||||||
|
export const objToStore = (obj: any) => {
|
||||||
|
if (obj == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (obj instanceof Set) {
|
||||||
|
obj = Array.from(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
[serializationIndicator]: true,
|
||||||
|
value: JSON.stringify(obj),
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
export default abstract class AbstractChromeStorageService
|
export default abstract class AbstractChromeStorageService
|
||||||
implements AbstractStorageService, ObservableStorageService
|
implements AbstractStorageService, ObservableStorageService
|
||||||
{
|
{
|
||||||
@@ -44,7 +61,11 @@ export default abstract class AbstractChromeStorageService
|
|||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
this.chromeStorageApi.get(key, (obj: any) => {
|
this.chromeStorageApi.get(key, (obj: any) => {
|
||||||
if (obj != null && obj[key] != null) {
|
if (obj != null && obj[key] != null) {
|
||||||
resolve(obj[key] as T);
|
let value = obj[key];
|
||||||
|
if (value[serializationIndicator] && typeof value.value === "string") {
|
||||||
|
value = JSON.parse(value.value);
|
||||||
|
}
|
||||||
|
resolve(value as T);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
resolve(null);
|
resolve(null);
|
||||||
@@ -57,14 +78,7 @@ export default abstract class AbstractChromeStorageService
|
|||||||
}
|
}
|
||||||
|
|
||||||
async save(key: string, obj: any): Promise<void> {
|
async save(key: string, obj: any): Promise<void> {
|
||||||
if (obj == null) {
|
obj = objToStore(obj);
|
||||||
// Fix safari not liking null in set
|
|
||||||
return this.remove(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (obj instanceof Set) {
|
|
||||||
obj = Array.from(obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
const keyedObj = { [key]: obj };
|
const keyedObj = { [key]: obj };
|
||||||
return new Promise<void>((resolve) => {
|
return new Promise<void>((resolve) => {
|
||||||
|
|||||||
@@ -1,19 +1,5 @@
|
|||||||
import { StateService as BaseStateServiceAbstraction } from "@bitwarden/common/platform/abstractions/state.service";
|
import { StateService as BaseStateServiceAbstraction } from "@bitwarden/common/platform/abstractions/state.service";
|
||||||
import { StorageOptions } from "@bitwarden/common/platform/models/domain/storage-options";
|
|
||||||
|
|
||||||
import { Account } from "../../../models/account";
|
import { Account } from "../../../models/account";
|
||||||
import { BrowserComponentState } from "../../../models/browserComponentState";
|
|
||||||
import { BrowserSendComponentState } from "../../../models/browserSendComponentState";
|
|
||||||
|
|
||||||
export abstract class BrowserStateService extends BaseStateServiceAbstraction<Account> {
|
export abstract class BrowserStateService extends BaseStateServiceAbstraction<Account> {}
|
||||||
getBrowserSendComponentState: (options?: StorageOptions) => Promise<BrowserSendComponentState>;
|
|
||||||
setBrowserSendComponentState: (
|
|
||||||
value: BrowserSendComponentState,
|
|
||||||
options?: StorageOptions,
|
|
||||||
) => Promise<void>;
|
|
||||||
getBrowserSendTypeComponentState: (options?: StorageOptions) => Promise<BrowserComponentState>;
|
|
||||||
setBrowserSendTypeComponentState: (
|
|
||||||
value: BrowserComponentState,
|
|
||||||
options?: StorageOptions,
|
|
||||||
) => Promise<void>;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -0,0 +1,99 @@
|
|||||||
|
import AbstractChromeStorageService, {
|
||||||
|
objToStore,
|
||||||
|
serializationIndicator,
|
||||||
|
} from "./abstract-chrome-storage-api.service";
|
||||||
|
|
||||||
|
class TestChromeStorageApiService extends AbstractChromeStorageService {}
|
||||||
|
|
||||||
|
describe("objectToStore", () => {
|
||||||
|
it("converts an object to a tagged string", () => {
|
||||||
|
const obj = { key: "value" };
|
||||||
|
const result = objToStore(obj);
|
||||||
|
expect(result).toEqual({
|
||||||
|
[serializationIndicator]: true,
|
||||||
|
value: JSON.stringify(obj),
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("converts a set to an array prior to serialization", () => {
|
||||||
|
const obj = new Set(["value"]);
|
||||||
|
const result = objToStore(obj);
|
||||||
|
expect(result).toEqual({
|
||||||
|
[serializationIndicator]: true,
|
||||||
|
value: JSON.stringify(Array.from(obj)),
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("does nothing to null", () => {
|
||||||
|
expect(objToStore(null)).toEqual(null);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("ChromeStorageApiService", () => {
|
||||||
|
let service: TestChromeStorageApiService;
|
||||||
|
let store: Record<any, any>;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
store = {};
|
||||||
|
|
||||||
|
service = new TestChromeStorageApiService(chrome.storage.local);
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("save", () => {
|
||||||
|
let setMock: jest.Mock;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
// setup save
|
||||||
|
setMock = chrome.storage.local.set as jest.Mock;
|
||||||
|
setMock.mockImplementation((data, callback) => {
|
||||||
|
Object.assign(store, data);
|
||||||
|
callback();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("uses `objToStore` to prepare a value for set", async () => {
|
||||||
|
const key = "key";
|
||||||
|
const value = { key: "value" };
|
||||||
|
await service.save(key, value);
|
||||||
|
expect(setMock).toHaveBeenCalledWith(
|
||||||
|
{
|
||||||
|
[key]: objToStore(value),
|
||||||
|
},
|
||||||
|
expect.any(Function),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("get", () => {
|
||||||
|
let getMock: jest.Mock;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
// setup get
|
||||||
|
getMock = chrome.storage.local.get as jest.Mock;
|
||||||
|
getMock.mockImplementation((key, callback) => {
|
||||||
|
callback({ [key]: store[key] });
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("returns a stored value when it is serialized", async () => {
|
||||||
|
const key = "key";
|
||||||
|
const value = { key: "value" };
|
||||||
|
store[key] = objToStore(value);
|
||||||
|
const result = await service.get(key);
|
||||||
|
expect(result).toEqual(value);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("returns a stored value when it is not serialized", async () => {
|
||||||
|
const key = "key";
|
||||||
|
const value = "value";
|
||||||
|
store[key] = value;
|
||||||
|
const result = await service.get(key);
|
||||||
|
expect(result).toEqual(value);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("returns null when the key does not exist", async () => {
|
||||||
|
const result = await service.get("key");
|
||||||
|
expect(result).toBeNull();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
import { mock, MockProxy } from "jest-mock-extended";
|
import { mock, MockProxy } from "jest-mock-extended";
|
||||||
|
import { firstValueFrom } from "rxjs";
|
||||||
|
|
||||||
import { TokenService } from "@bitwarden/common/auth/abstractions/token.service";
|
import { TokenService } from "@bitwarden/common/auth/abstractions/token.service";
|
||||||
import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service";
|
import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service";
|
||||||
@@ -12,15 +13,11 @@ import { GlobalState } from "@bitwarden/common/platform/models/domain/global-sta
|
|||||||
import { State } from "@bitwarden/common/platform/models/domain/state";
|
import { State } from "@bitwarden/common/platform/models/domain/state";
|
||||||
import { MigrationRunner } from "@bitwarden/common/platform/services/migration-runner";
|
import { MigrationRunner } from "@bitwarden/common/platform/services/migration-runner";
|
||||||
import { mockAccountServiceWith } from "@bitwarden/common/spec";
|
import { mockAccountServiceWith } from "@bitwarden/common/spec";
|
||||||
import { SendType } from "@bitwarden/common/tools/send/enums/send-type";
|
|
||||||
import { SendView } from "@bitwarden/common/tools/send/models/view/send.view";
|
|
||||||
import { UserId } from "@bitwarden/common/types/guid";
|
import { UserId } from "@bitwarden/common/types/guid";
|
||||||
|
|
||||||
import { Account } from "../../models/account";
|
import { Account } from "../../models/account";
|
||||||
import { BrowserComponentState } from "../../models/browserComponentState";
|
|
||||||
import { BrowserSendComponentState } from "../../models/browserSendComponentState";
|
|
||||||
|
|
||||||
import { BrowserStateService } from "./browser-state.service";
|
import { DefaultBrowserStateService } from "./default-browser-state.service";
|
||||||
|
|
||||||
// disable session syncing to just test class
|
// disable session syncing to just test class
|
||||||
jest.mock("../decorators/session-sync-observable/");
|
jest.mock("../decorators/session-sync-observable/");
|
||||||
@@ -39,7 +36,7 @@ describe("Browser State Service", () => {
|
|||||||
const userId = "userId" as UserId;
|
const userId = "userId" as UserId;
|
||||||
const accountService = mockAccountServiceWith(userId);
|
const accountService = mockAccountServiceWith(userId);
|
||||||
|
|
||||||
let sut: BrowserStateService;
|
let sut: DefaultBrowserStateService;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
secureStorageService = mock();
|
secureStorageService = mock();
|
||||||
@@ -71,7 +68,7 @@ describe("Browser State Service", () => {
|
|||||||
const stateGetter = (key: string) => Promise.resolve(state);
|
const stateGetter = (key: string) => Promise.resolve(state);
|
||||||
memoryStorageService.get.mockImplementation(stateGetter);
|
memoryStorageService.get.mockImplementation(stateGetter);
|
||||||
|
|
||||||
sut = new BrowserStateService(
|
sut = new DefaultBrowserStateService(
|
||||||
diskStorageService,
|
diskStorageService,
|
||||||
secureStorageService,
|
secureStorageService,
|
||||||
memoryStorageService,
|
memoryStorageService,
|
||||||
@@ -85,32 +82,17 @@ describe("Browser State Service", () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("getBrowserSendComponentState", () => {
|
describe("add Account", () => {
|
||||||
it("should return a BrowserSendComponentState", async () => {
|
it("should add account", async () => {
|
||||||
const sendState = new BrowserSendComponentState();
|
const newUserId = "newUserId" as UserId;
|
||||||
sendState.sends = [new SendView(), new SendView()];
|
const newAcct = new Account({
|
||||||
sendState.typeCounts = new Map<SendType, number>([
|
profile: { userId: newUserId },
|
||||||
[SendType.File, 3],
|
});
|
||||||
[SendType.Text, 5],
|
|
||||||
]);
|
|
||||||
state.accounts[userId].send = sendState;
|
|
||||||
(global as any)["watch"] = state;
|
|
||||||
|
|
||||||
const actual = await sut.getBrowserSendComponentState();
|
await sut.addAccount(newAcct);
|
||||||
expect(actual).toBeInstanceOf(BrowserSendComponentState);
|
|
||||||
expect(actual).toMatchObject(sendState);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("getBrowserSendTypeComponentState", () => {
|
const accts = await firstValueFrom(sut.accounts$);
|
||||||
it("should return a BrowserComponentState", async () => {
|
expect(accts[newUserId]).toBeDefined();
|
||||||
const componentState = new BrowserComponentState();
|
|
||||||
componentState.scrollY = 0;
|
|
||||||
componentState.searchText = "test";
|
|
||||||
state.accounts[userId].sendType = componentState;
|
|
||||||
|
|
||||||
const actual = await sut.getBrowserSendTypeComponentState();
|
|
||||||
expect(actual).toStrictEqual(componentState);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -15,17 +15,15 @@ import { MigrationRunner } from "@bitwarden/common/platform/services/migration-r
|
|||||||
import { StateService as BaseStateService } from "@bitwarden/common/platform/services/state.service";
|
import { StateService as BaseStateService } from "@bitwarden/common/platform/services/state.service";
|
||||||
|
|
||||||
import { Account } from "../../models/account";
|
import { Account } from "../../models/account";
|
||||||
import { BrowserComponentState } from "../../models/browserComponentState";
|
|
||||||
import { BrowserSendComponentState } from "../../models/browserSendComponentState";
|
|
||||||
import { BrowserApi } from "../browser/browser-api";
|
import { BrowserApi } from "../browser/browser-api";
|
||||||
import { browserSession, sessionSync } from "../decorators/session-sync-observable";
|
import { browserSession, sessionSync } from "../decorators/session-sync-observable";
|
||||||
|
|
||||||
import { BrowserStateService as StateServiceAbstraction } from "./abstractions/browser-state.service";
|
import { BrowserStateService } from "./abstractions/browser-state.service";
|
||||||
|
|
||||||
@browserSession
|
@browserSession
|
||||||
export class BrowserStateService
|
export class DefaultBrowserStateService
|
||||||
extends BaseStateService<GlobalState, Account>
|
extends BaseStateService<GlobalState, Account>
|
||||||
implements StateServiceAbstraction
|
implements BrowserStateService
|
||||||
{
|
{
|
||||||
@sessionSync({
|
@sessionSync({
|
||||||
initializer: Account.fromJSON as any, // TODO: Remove this any when all any types are removed from Account
|
initializer: Account.fromJSON as any, // TODO: Remove this any when all any types are removed from Account
|
||||||
@@ -115,46 +113,6 @@ export class BrowserStateService
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getBrowserSendComponentState(options?: StorageOptions): Promise<BrowserSendComponentState> {
|
|
||||||
return (
|
|
||||||
await this.getAccount(this.reconcileOptions(options, await this.defaultInMemoryOptions()))
|
|
||||||
)?.send;
|
|
||||||
}
|
|
||||||
|
|
||||||
async setBrowserSendComponentState(
|
|
||||||
value: BrowserSendComponentState,
|
|
||||||
options?: StorageOptions,
|
|
||||||
): Promise<void> {
|
|
||||||
const account = await this.getAccount(
|
|
||||||
this.reconcileOptions(options, await this.defaultInMemoryOptions()),
|
|
||||||
);
|
|
||||||
account.send = value;
|
|
||||||
await this.saveAccount(
|
|
||||||
account,
|
|
||||||
this.reconcileOptions(options, await this.defaultInMemoryOptions()),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
async getBrowserSendTypeComponentState(options?: StorageOptions): Promise<BrowserComponentState> {
|
|
||||||
return (
|
|
||||||
await this.getAccount(this.reconcileOptions(options, await this.defaultInMemoryOptions()))
|
|
||||||
)?.sendType;
|
|
||||||
}
|
|
||||||
|
|
||||||
async setBrowserSendTypeComponentState(
|
|
||||||
value: BrowserComponentState,
|
|
||||||
options?: StorageOptions,
|
|
||||||
): Promise<void> {
|
|
||||||
const account = await this.getAccount(
|
|
||||||
this.reconcileOptions(options, await this.defaultInMemoryOptions()),
|
|
||||||
);
|
|
||||||
account.sendType = value;
|
|
||||||
await this.saveAccount(
|
|
||||||
account,
|
|
||||||
this.reconcileOptions(options, await this.defaultInMemoryOptions()),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Overriding the base class to prevent deleting the cache on save. We register a storage listener
|
// Overriding the base class to prevent deleting the cache on save. We register a storage listener
|
||||||
// to delete the cache in the constructor above.
|
// to delete the cache in the constructor above.
|
||||||
protected override async saveAccountToDisk(
|
protected override async saveAccountToDisk(
|
||||||
@@ -12,6 +12,7 @@ import { BrowserApi } from "../platform/browser/browser-api";
|
|||||||
import { ZonedMessageListenerService } from "../platform/browser/zoned-message-listener.service";
|
import { ZonedMessageListenerService } from "../platform/browser/zoned-message-listener.service";
|
||||||
import { BrowserStateService } from "../platform/services/abstractions/browser-state.service";
|
import { BrowserStateService } from "../platform/services/abstractions/browser-state.service";
|
||||||
import { ForegroundPlatformUtilsService } from "../platform/services/platform-utils/foreground-platform-utils.service";
|
import { ForegroundPlatformUtilsService } from "../platform/services/platform-utils/foreground-platform-utils.service";
|
||||||
|
import { BrowserSendStateService } from "../tools/popup/services/browser-send-state.service";
|
||||||
import { VaultBrowserStateService } from "../vault/services/vault-browser-state.service";
|
import { VaultBrowserStateService } from "../vault/services/vault-browser-state.service";
|
||||||
|
|
||||||
import { routerTransition } from "./app-routing.animations";
|
import { routerTransition } from "./app-routing.animations";
|
||||||
@@ -38,6 +39,7 @@ export class AppComponent implements OnInit, OnDestroy {
|
|||||||
private i18nService: I18nService,
|
private i18nService: I18nService,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private stateService: BrowserStateService,
|
private stateService: BrowserStateService,
|
||||||
|
private browserSendStateService: BrowserSendStateService,
|
||||||
private vaultBrowserStateService: VaultBrowserStateService,
|
private vaultBrowserStateService: VaultBrowserStateService,
|
||||||
private changeDetectorRef: ChangeDetectorRef,
|
private changeDetectorRef: ChangeDetectorRef,
|
||||||
private ngZone: NgZone,
|
private ngZone: NgZone,
|
||||||
@@ -231,8 +233,8 @@ export class AppComponent implements OnInit, OnDestroy {
|
|||||||
await Promise.all([
|
await Promise.all([
|
||||||
this.vaultBrowserStateService.setBrowserGroupingsComponentState(null),
|
this.vaultBrowserStateService.setBrowserGroupingsComponentState(null),
|
||||||
this.vaultBrowserStateService.setBrowserVaultItemsComponentState(null),
|
this.vaultBrowserStateService.setBrowserVaultItemsComponentState(null),
|
||||||
this.stateService.setBrowserSendComponentState(null),
|
this.browserSendStateService.setBrowserSendComponentState(null),
|
||||||
this.stateService.setBrowserSendTypeComponentState(null),
|
this.browserSendStateService.setBrowserSendTypeComponentState(null),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -99,11 +99,12 @@ import { BrowserEnvironmentService } from "../../platform/services/browser-envir
|
|||||||
import BrowserLocalStorageService from "../../platform/services/browser-local-storage.service";
|
import BrowserLocalStorageService from "../../platform/services/browser-local-storage.service";
|
||||||
import BrowserMessagingPrivateModePopupService from "../../platform/services/browser-messaging-private-mode-popup.service";
|
import BrowserMessagingPrivateModePopupService from "../../platform/services/browser-messaging-private-mode-popup.service";
|
||||||
import BrowserMessagingService from "../../platform/services/browser-messaging.service";
|
import BrowserMessagingService from "../../platform/services/browser-messaging.service";
|
||||||
import { BrowserStateService } from "../../platform/services/browser-state.service";
|
import { DefaultBrowserStateService } from "../../platform/services/default-browser-state.service";
|
||||||
import I18nService from "../../platform/services/i18n.service";
|
import I18nService from "../../platform/services/i18n.service";
|
||||||
import { ForegroundPlatformUtilsService } from "../../platform/services/platform-utils/foreground-platform-utils.service";
|
import { ForegroundPlatformUtilsService } from "../../platform/services/platform-utils/foreground-platform-utils.service";
|
||||||
import { ForegroundDerivedStateProvider } from "../../platform/state/foreground-derived-state.provider";
|
import { ForegroundDerivedStateProvider } from "../../platform/state/foreground-derived-state.provider";
|
||||||
import { ForegroundMemoryStorageService } from "../../platform/storage/foreground-memory-storage.service";
|
import { ForegroundMemoryStorageService } from "../../platform/storage/foreground-memory-storage.service";
|
||||||
|
import { BrowserSendStateService } from "../../tools/popup/services/browser-send-state.service";
|
||||||
import { FilePopoutUtilsService } from "../../tools/popup/services/file-popout-utils.service";
|
import { FilePopoutUtilsService } from "../../tools/popup/services/file-popout-utils.service";
|
||||||
import { VaultBrowserStateService } from "../../vault/services/vault-browser-state.service";
|
import { VaultBrowserStateService } from "../../vault/services/vault-browser-state.service";
|
||||||
import { VaultFilterService } from "../../vault/services/vault-filter.service";
|
import { VaultFilterService } from "../../vault/services/vault-filter.service";
|
||||||
@@ -412,7 +413,7 @@ const safeProviders: SafeProvider[] = [
|
|||||||
tokenService: TokenService,
|
tokenService: TokenService,
|
||||||
migrationRunner: MigrationRunner,
|
migrationRunner: MigrationRunner,
|
||||||
) => {
|
) => {
|
||||||
return new BrowserStateService(
|
return new DefaultBrowserStateService(
|
||||||
storageService,
|
storageService,
|
||||||
secureStorageService,
|
secureStorageService,
|
||||||
memoryStorageService,
|
memoryStorageService,
|
||||||
@@ -487,6 +488,11 @@ const safeProviders: SafeProvider[] = [
|
|||||||
useClass: UserNotificationSettingsService,
|
useClass: UserNotificationSettingsService,
|
||||||
deps: [StateProvider],
|
deps: [StateProvider],
|
||||||
}),
|
}),
|
||||||
|
safeProvider({
|
||||||
|
provide: BrowserSendStateService,
|
||||||
|
useClass: BrowserSendStateService,
|
||||||
|
deps: [StateProvider],
|
||||||
|
}),
|
||||||
];
|
];
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import { DialogService } from "@bitwarden/components";
|
|||||||
|
|
||||||
import { BrowserSendComponentState } from "../../../models/browserSendComponentState";
|
import { BrowserSendComponentState } from "../../../models/browserSendComponentState";
|
||||||
import BrowserPopupUtils from "../../../platform/popup/browser-popup-utils";
|
import BrowserPopupUtils from "../../../platform/popup/browser-popup-utils";
|
||||||
import { BrowserStateService } from "../../../platform/services/abstractions/browser-state.service";
|
import { BrowserSendStateService } from "../services/browser-send-state.service";
|
||||||
|
|
||||||
const ComponentId = "SendComponent";
|
const ComponentId = "SendComponent";
|
||||||
|
|
||||||
@@ -43,7 +43,7 @@ export class SendGroupingsComponent extends BaseSendComponent {
|
|||||||
ngZone: NgZone,
|
ngZone: NgZone,
|
||||||
policyService: PolicyService,
|
policyService: PolicyService,
|
||||||
searchService: SearchService,
|
searchService: SearchService,
|
||||||
private stateService: BrowserStateService,
|
private stateService: BrowserSendStateService,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private syncService: SyncService,
|
private syncService: SyncService,
|
||||||
private changeDetectorRef: ChangeDetectorRef,
|
private changeDetectorRef: ChangeDetectorRef,
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import { DialogService } from "@bitwarden/components";
|
|||||||
|
|
||||||
import { BrowserComponentState } from "../../../models/browserComponentState";
|
import { BrowserComponentState } from "../../../models/browserComponentState";
|
||||||
import BrowserPopupUtils from "../../../platform/popup/browser-popup-utils";
|
import BrowserPopupUtils from "../../../platform/popup/browser-popup-utils";
|
||||||
import { BrowserStateService } from "../../../platform/services/abstractions/browser-state.service";
|
import { BrowserSendStateService } from "../services/browser-send-state.service";
|
||||||
|
|
||||||
const ComponentId = "SendTypeComponent";
|
const ComponentId = "SendTypeComponent";
|
||||||
|
|
||||||
@@ -42,7 +42,7 @@ export class SendTypeComponent extends BaseSendComponent {
|
|||||||
ngZone: NgZone,
|
ngZone: NgZone,
|
||||||
policyService: PolicyService,
|
policyService: PolicyService,
|
||||||
searchService: SearchService,
|
searchService: SearchService,
|
||||||
private stateService: BrowserStateService,
|
private stateService: BrowserSendStateService,
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
private location: Location,
|
private location: Location,
|
||||||
private changeDetectorRef: ChangeDetectorRef,
|
private changeDetectorRef: ChangeDetectorRef,
|
||||||
|
|||||||
@@ -0,0 +1,61 @@
|
|||||||
|
import {
|
||||||
|
FakeAccountService,
|
||||||
|
mockAccountServiceWith,
|
||||||
|
} from "@bitwarden/common/../spec/fake-account-service";
|
||||||
|
import { FakeStateProvider } from "@bitwarden/common/../spec/fake-state-provider";
|
||||||
|
import { awaitAsync } from "@bitwarden/common/../spec/utils";
|
||||||
|
|
||||||
|
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
||||||
|
import { SendType } from "@bitwarden/common/tools/send/enums/send-type";
|
||||||
|
import { UserId } from "@bitwarden/common/types/guid";
|
||||||
|
|
||||||
|
import { BrowserComponentState } from "../../../models/browserComponentState";
|
||||||
|
import { BrowserSendComponentState } from "../../../models/browserSendComponentState";
|
||||||
|
|
||||||
|
import { BrowserSendStateService } from "./browser-send-state.service";
|
||||||
|
|
||||||
|
describe("Browser Send State Service", () => {
|
||||||
|
let stateProvider: FakeStateProvider;
|
||||||
|
|
||||||
|
let accountService: FakeAccountService;
|
||||||
|
let stateService: BrowserSendStateService;
|
||||||
|
const mockUserId = Utils.newGuid() as UserId;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
accountService = mockAccountServiceWith(mockUserId);
|
||||||
|
stateProvider = new FakeStateProvider(accountService);
|
||||||
|
|
||||||
|
stateService = new BrowserSendStateService(stateProvider);
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("getBrowserSendComponentState", () => {
|
||||||
|
it("should return BrowserSendComponentState", async () => {
|
||||||
|
const state = new BrowserSendComponentState();
|
||||||
|
state.scrollY = 0;
|
||||||
|
state.searchText = "test";
|
||||||
|
state.typeCounts = new Map<SendType, number>().set(SendType.File, 1);
|
||||||
|
|
||||||
|
await stateService.setBrowserSendComponentState(state);
|
||||||
|
|
||||||
|
await awaitAsync();
|
||||||
|
|
||||||
|
const actual = await stateService.getBrowserSendComponentState();
|
||||||
|
expect(actual).toStrictEqual(state);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("getBrowserSendTypeComponentState", () => {
|
||||||
|
it("should return BrowserComponentState", async () => {
|
||||||
|
const state = new BrowserComponentState();
|
||||||
|
state.scrollY = 0;
|
||||||
|
state.searchText = "test";
|
||||||
|
|
||||||
|
await stateService.setBrowserSendTypeComponentState(state);
|
||||||
|
|
||||||
|
await awaitAsync();
|
||||||
|
|
||||||
|
const actual = await stateService.getBrowserSendTypeComponentState();
|
||||||
|
expect(actual).toStrictEqual(state);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
import { Observable, firstValueFrom } from "rxjs";
|
||||||
|
|
||||||
|
import { ActiveUserState, StateProvider } from "@bitwarden/common/platform/state";
|
||||||
|
|
||||||
|
import { BrowserComponentState } from "../../../models/browserComponentState";
|
||||||
|
import { BrowserSendComponentState } from "../../../models/browserSendComponentState";
|
||||||
|
|
||||||
|
import { BROWSER_SEND_COMPONENT, BROWSER_SEND_TYPE_COMPONENT } from "./key-definitions";
|
||||||
|
|
||||||
|
/** Get or set the active user's component state for the Send browser component
|
||||||
|
*/
|
||||||
|
export class BrowserSendStateService {
|
||||||
|
/** Observable that contains the current state for active user Sends including the send data and type counts
|
||||||
|
* along with the search text and scroll position
|
||||||
|
*/
|
||||||
|
browserSendComponentState$: Observable<BrowserSendComponentState>;
|
||||||
|
|
||||||
|
/** Observable that contains the current state for active user Sends that only includes the search text
|
||||||
|
* and scroll position
|
||||||
|
*/
|
||||||
|
browserSendTypeComponentState$: Observable<BrowserComponentState>;
|
||||||
|
|
||||||
|
private activeUserBrowserSendComponentState: ActiveUserState<BrowserSendComponentState>;
|
||||||
|
private activeUserBrowserSendTypeComponentState: ActiveUserState<BrowserComponentState>;
|
||||||
|
|
||||||
|
constructor(protected stateProvider: StateProvider) {
|
||||||
|
this.activeUserBrowserSendComponentState = this.stateProvider.getActive(BROWSER_SEND_COMPONENT);
|
||||||
|
this.browserSendComponentState$ = this.activeUserBrowserSendComponentState.state$;
|
||||||
|
|
||||||
|
this.activeUserBrowserSendTypeComponentState = this.stateProvider.getActive(
|
||||||
|
BROWSER_SEND_TYPE_COMPONENT,
|
||||||
|
);
|
||||||
|
this.browserSendTypeComponentState$ = this.activeUserBrowserSendTypeComponentState.state$;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get the active user's browser send component state
|
||||||
|
* @returns { BrowserSendComponentState } contains the sends and type counts along with the scroll position and search text for the
|
||||||
|
* send component on the browser
|
||||||
|
*/
|
||||||
|
async getBrowserSendComponentState(): Promise<BrowserSendComponentState> {
|
||||||
|
return await firstValueFrom(this.browserSendComponentState$);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Set the active user's browser send component state
|
||||||
|
* @param { BrowserSendComponentState } value sets the sends and type counts along with the scroll position and search text for
|
||||||
|
* the send component on the browser
|
||||||
|
*/
|
||||||
|
async setBrowserSendComponentState(value: BrowserSendComponentState): Promise<void> {
|
||||||
|
await this.activeUserBrowserSendComponentState.update(() => value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get the active user's browser component state
|
||||||
|
* @returns { BrowserComponentState } contains the scroll position and search text for the sends menu on the browser
|
||||||
|
*/
|
||||||
|
async getBrowserSendTypeComponentState(): Promise<BrowserComponentState> {
|
||||||
|
return await firstValueFrom(this.browserSendTypeComponentState$);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Set the active user's browser component state
|
||||||
|
* @param { BrowserComponentState } value set the scroll position and search text for the send component on the browser
|
||||||
|
*/
|
||||||
|
async setBrowserSendTypeComponentState(value: BrowserComponentState): Promise<void> {
|
||||||
|
await this.activeUserBrowserSendTypeComponentState.update(() => value);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
import { Jsonify } from "type-fest";
|
||||||
|
|
||||||
|
import { SendType } from "@bitwarden/common/tools/send/enums/send-type";
|
||||||
|
|
||||||
|
import { BrowserSendComponentState } from "../../../models/browserSendComponentState";
|
||||||
|
|
||||||
|
import { BROWSER_SEND_COMPONENT, BROWSER_SEND_TYPE_COMPONENT } from "./key-definitions";
|
||||||
|
|
||||||
|
describe("Key definitions", () => {
|
||||||
|
describe("BROWSER_SEND_COMPONENT", () => {
|
||||||
|
it("should deserialize BrowserSendComponentState", () => {
|
||||||
|
const keyDef = BROWSER_SEND_COMPONENT;
|
||||||
|
|
||||||
|
const expectedState = {
|
||||||
|
typeCounts: new Map<SendType, number>(),
|
||||||
|
};
|
||||||
|
|
||||||
|
const result = keyDef.deserializer(
|
||||||
|
JSON.parse(JSON.stringify(expectedState)) as Jsonify<BrowserSendComponentState>,
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(result).toEqual(expectedState);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("BROWSER_SEND_TYPE_COMPONENT", () => {
|
||||||
|
it("should deserialize BrowserComponentState", () => {
|
||||||
|
const keyDef = BROWSER_SEND_TYPE_COMPONENT;
|
||||||
|
|
||||||
|
const expectedState = {
|
||||||
|
scrollY: 0,
|
||||||
|
searchText: "test",
|
||||||
|
};
|
||||||
|
|
||||||
|
const result = keyDef.deserializer(JSON.parse(JSON.stringify(expectedState)));
|
||||||
|
|
||||||
|
expect(result).toEqual(expectedState);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
23
apps/browser/src/tools/popup/services/key-definitions.ts
Normal file
23
apps/browser/src/tools/popup/services/key-definitions.ts
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
import { Jsonify } from "type-fest";
|
||||||
|
|
||||||
|
import { BROWSER_SEND_MEMORY, KeyDefinition } from "@bitwarden/common/platform/state";
|
||||||
|
|
||||||
|
import { BrowserComponentState } from "../../../models/browserComponentState";
|
||||||
|
import { BrowserSendComponentState } from "../../../models/browserSendComponentState";
|
||||||
|
|
||||||
|
export const BROWSER_SEND_COMPONENT = new KeyDefinition<BrowserSendComponentState>(
|
||||||
|
BROWSER_SEND_MEMORY,
|
||||||
|
"browser_send_component",
|
||||||
|
{
|
||||||
|
deserializer: (obj: Jsonify<BrowserSendComponentState>) =>
|
||||||
|
BrowserSendComponentState.fromJSON(obj),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
export const BROWSER_SEND_TYPE_COMPONENT = new KeyDefinition<BrowserComponentState>(
|
||||||
|
BROWSER_SEND_MEMORY,
|
||||||
|
"browser_send_type_component",
|
||||||
|
{
|
||||||
|
deserializer: (obj: Jsonify<BrowserComponentState>) => BrowserComponentState.fromJSON(obj),
|
||||||
|
},
|
||||||
|
);
|
||||||
@@ -7,11 +7,11 @@ import {
|
|||||||
} from "@bitwarden/common/platform/misc/flags";
|
} from "@bitwarden/common/platform/misc/flags";
|
||||||
|
|
||||||
// required to avoid linting errors when there are no flags
|
// required to avoid linting errors when there are no flags
|
||||||
/* eslint-disable-next-line @typescript-eslint/ban-types */
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||||
export type Flags = {} & SharedFlags;
|
export type Flags = {} & SharedFlags;
|
||||||
|
|
||||||
// required to avoid linting errors when there are no flags
|
// required to avoid linting errors when there are no flags
|
||||||
/* eslint-disable-next-line @typescript-eslint/ban-types */
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||||
export type DevFlags = {} & SharedDevFlags;
|
export type DevFlags = {} & SharedDevFlags;
|
||||||
|
|
||||||
export function flagEnabled(flag: keyof Flags): boolean {
|
export function flagEnabled(flag: keyof Flags): boolean {
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
{
|
{
|
||||||
"devFlags": {},
|
"devFlags": {},
|
||||||
"flags": {
|
"flags": {
|
||||||
"showDDGSetting": true,
|
|
||||||
"enableCipherKeyEncryption": false
|
"enableCipherKeyEncryption": false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
{
|
{
|
||||||
"flags": {
|
"flags": {
|
||||||
"showDDGSetting": true,
|
|
||||||
"enableCipherKeyEncryption": false
|
"enableCipherKeyEncryption": false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ import { DialogService } from "@bitwarden/components";
|
|||||||
|
|
||||||
import { SetPinComponent } from "../../auth/components/set-pin.component";
|
import { SetPinComponent } from "../../auth/components/set-pin.component";
|
||||||
import { DesktopAutofillSettingsService } from "../../autofill/services/desktop-autofill-settings.service";
|
import { DesktopAutofillSettingsService } from "../../autofill/services/desktop-autofill-settings.service";
|
||||||
import { flagEnabled } from "../../platform/flags";
|
|
||||||
import { DesktopSettingsService } from "../../platform/services/desktop-settings.service";
|
import { DesktopSettingsService } from "../../platform/services/desktop-settings.service";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@@ -146,7 +145,7 @@ export class SettingsComponent implements OnInit {
|
|||||||
this.startToTrayDescText = this.i18nService.t(startToTrayKey + "Desc");
|
this.startToTrayDescText = this.i18nService.t(startToTrayKey + "Desc");
|
||||||
|
|
||||||
// DuckDuckGo browser is only for macos initially
|
// DuckDuckGo browser is only for macos initially
|
||||||
this.showDuckDuckGoIntegrationOption = flagEnabled("showDDGSetting") && isMac;
|
this.showDuckDuckGoIntegrationOption = isMac;
|
||||||
|
|
||||||
this.vaultTimeoutOptions = [
|
this.vaultTimeoutOptions = [
|
||||||
// { name: i18nService.t('immediately'), value: 0 },
|
// { name: i18nService.t('immediately'), value: 0 },
|
||||||
|
|||||||
@@ -7,13 +7,11 @@ import {
|
|||||||
} from "@bitwarden/common/platform/misc/flags";
|
} from "@bitwarden/common/platform/misc/flags";
|
||||||
|
|
||||||
// required to avoid linting errors when there are no flags
|
// required to avoid linting errors when there are no flags
|
||||||
/* eslint-disable-next-line @typescript-eslint/ban-types */
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||||
export type Flags = {
|
export type Flags = {} & SharedFlags;
|
||||||
showDDGSetting?: boolean;
|
|
||||||
} & SharedFlags;
|
|
||||||
|
|
||||||
// required to avoid linting errors when there are no flags
|
// required to avoid linting errors when there are no flags
|
||||||
/* eslint-disable-next-line @typescript-eslint/ban-types */
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||||
export type DevFlags = {} & SharedDevFlags;
|
export type DevFlags = {} & SharedDevFlags;
|
||||||
|
|
||||||
export function flagEnabled(flag: keyof Flags): boolean {
|
export function flagEnabled(flag: keyof Flags): boolean {
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
"allowedHosts": "auto"
|
"allowedHosts": "auto"
|
||||||
},
|
},
|
||||||
"flags": {
|
"flags": {
|
||||||
"secretsManager": false,
|
|
||||||
"showPasswordless": false,
|
"showPasswordless": false,
|
||||||
"enableCipherKeyEncryption": false
|
"enableCipherKeyEncryption": false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,6 @@
|
|||||||
"proxyNotifications": "https://notifications.bitwarden.com"
|
"proxyNotifications": "https://notifications.bitwarden.com"
|
||||||
},
|
},
|
||||||
"flags": {
|
"flags": {
|
||||||
"secretsManager": true,
|
|
||||||
"showPasswordless": true,
|
"showPasswordless": true,
|
||||||
"enableCipherKeyEncryption": false
|
"enableCipherKeyEncryption": false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,6 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"flags": {
|
"flags": {
|
||||||
"secretsManager": true,
|
|
||||||
"showPasswordless": true,
|
"showPasswordless": true,
|
||||||
"enableCipherKeyEncryption": false
|
"enableCipherKeyEncryption": false
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
"buttonAction": "https://www.paypal.com/cgi-bin/webscr"
|
"buttonAction": "https://www.paypal.com/cgi-bin/webscr"
|
||||||
},
|
},
|
||||||
"flags": {
|
"flags": {
|
||||||
"secretsManager": true,
|
|
||||||
"showPasswordless": true,
|
"showPasswordless": true,
|
||||||
"enableCipherKeyEncryption": false
|
"enableCipherKeyEncryption": false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,6 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"flags": {
|
"flags": {
|
||||||
"secretsManager": true,
|
|
||||||
"showPasswordless": true
|
"showPasswordless": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,6 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"flags": {
|
"flags": {
|
||||||
"secretsManager": true,
|
|
||||||
"showPasswordless": true,
|
"showPasswordless": true,
|
||||||
"enableCipherKeyEncryption": false
|
"enableCipherKeyEncryption": false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@
|
|||||||
"port": 8081
|
"port": 8081
|
||||||
},
|
},
|
||||||
"flags": {
|
"flags": {
|
||||||
"secretsManager": true,
|
|
||||||
"showPasswordless": true,
|
"showPasswordless": true,
|
||||||
"enableCipherKeyEncryption": false
|
"enableCipherKeyEncryption": false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
"scim": "https://scim.usdev.bitwarden.pw"
|
"scim": "https://scim.usdev.bitwarden.pw"
|
||||||
},
|
},
|
||||||
"flags": {
|
"flags": {
|
||||||
"secretsManager": true,
|
|
||||||
"showPasswordless": true
|
"showPasswordless": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@bitwarden/web-vault",
|
"name": "@bitwarden/web-vault",
|
||||||
"version": "2024.3.1",
|
"version": "2024.4.0",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build:oss": "webpack",
|
"build:oss": "webpack",
|
||||||
"build:bit": "webpack -c ../../bitwarden_license/bit-web/webpack.config.js",
|
"build:bit": "webpack -c ../../bitwarden_license/bit-web/webpack.config.js",
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
"build:bit:watch": "webpack serve -c ../../bitwarden_license/bit-web/webpack.config.js",
|
"build:bit:watch": "webpack serve -c ../../bitwarden_license/bit-web/webpack.config.js",
|
||||||
"build:bit:dev": "cross-env ENV=development npm run build:bit",
|
"build:bit:dev": "cross-env ENV=development npm run build:bit",
|
||||||
"build:bit:dev:analyze": "cross-env LOGGING=false webpack -c ../../bitwarden_license/bit-web/webpack.config.js --profile --json > stats.json && npx webpack-bundle-analyzer stats.json build/",
|
"build:bit:dev:analyze": "cross-env LOGGING=false webpack -c ../../bitwarden_license/bit-web/webpack.config.js --profile --json > stats.json && npx webpack-bundle-analyzer stats.json build/",
|
||||||
"build:bit:dev:watch": "cross-env ENV=development npm run build:bit:watch",
|
"build:bit:dev:watch": "cross-env ENV=development NODE_OPTIONS=\"--max-old-space-size=8192\" npm run build:bit:watch",
|
||||||
"build:bit:qa": "cross-env NODE_ENV=production ENV=qa npm run build:bit",
|
"build:bit:qa": "cross-env NODE_ENV=production ENV=qa npm run build:bit",
|
||||||
"build:bit:euprd": "cross-env NODE_ENV=production ENV=euprd npm run build:bit",
|
"build:bit:euprd": "cross-env NODE_ENV=production ENV=euprd npm run build:bit",
|
||||||
"build:bit:euqa": "cross-env NODE_ENV=production ENV=euqa npm run build:bit",
|
"build:bit:euqa": "cross-env NODE_ENV=production ENV=euqa npm run build:bit",
|
||||||
|
|||||||
@@ -52,7 +52,6 @@ import { Collection } from "@bitwarden/common/vault/models/domain/collection";
|
|||||||
import { CollectionDetailsResponse } from "@bitwarden/common/vault/models/response/collection.response";
|
import { CollectionDetailsResponse } from "@bitwarden/common/vault/models/response/collection.response";
|
||||||
import { DialogService, SimpleDialogOptions } from "@bitwarden/components";
|
import { DialogService, SimpleDialogOptions } from "@bitwarden/components";
|
||||||
|
|
||||||
import { flagEnabled } from "../../../../utils/flags";
|
|
||||||
import { openEntityEventsDialog } from "../../../admin-console/organizations/manage/entity-events.component";
|
import { openEntityEventsDialog } from "../../../admin-console/organizations/manage/entity-events.component";
|
||||||
import { BasePeopleComponent } from "../../common/base.people.component";
|
import { BasePeopleComponent } from "../../common/base.people.component";
|
||||||
import { GroupService } from "../core";
|
import { GroupService } from "../core";
|
||||||
@@ -148,9 +147,7 @@ export class PeopleComponent
|
|||||||
shareReplay({ refCount: true, bufferSize: 1 }),
|
shareReplay({ refCount: true, bufferSize: 1 }),
|
||||||
);
|
);
|
||||||
|
|
||||||
this.canUseSecretsManager$ = organization$.pipe(
|
this.canUseSecretsManager$ = organization$.pipe(map((org) => org.useSecretsManager));
|
||||||
map((org) => org.useSecretsManager && flagEnabled("secretsManager")),
|
|
||||||
);
|
|
||||||
|
|
||||||
const policies$ = organization$.pipe(
|
const policies$ = organization$.pipe(
|
||||||
switchMap((organization) => {
|
switchMap((organization) => {
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
<ng-template [ngIf]="isEnabled">
|
<button
|
||||||
<button
|
type="button"
|
||||||
type="button"
|
bitIconButton="bwi bwi-fw bwi-filter"
|
||||||
bitIconButton="bwi bwi-fw bwi-filter"
|
[bitMenuTriggerFor]="content?.menu"
|
||||||
[bitMenuTriggerFor]="content?.menu"
|
[buttonType]="buttonType"
|
||||||
[buttonType]="buttonType"
|
[attr.aria-label]="'switchProducts' | i18n"
|
||||||
[attr.aria-label]="'switchProducts' | i18n"
|
></button>
|
||||||
></button>
|
<product-switcher-content #content></product-switcher-content>
|
||||||
<product-switcher-content #content></product-switcher-content>
|
|
||||||
</ng-template>
|
|
||||||
|
|||||||
@@ -1,16 +1,11 @@
|
|||||||
import { AfterViewInit, ChangeDetectorRef, Component, Input } from "@angular/core";
|
import { AfterViewInit, ChangeDetectorRef, Component, Input } from "@angular/core";
|
||||||
|
|
||||||
import { IconButtonType } from "@bitwarden/components/src/icon-button/icon-button.component";
|
import { IconButtonType } from "@bitwarden/components/src/icon-button/icon-button.component";
|
||||||
|
|
||||||
import { flagEnabled } from "../../../utils/flags";
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: "product-switcher",
|
selector: "product-switcher",
|
||||||
templateUrl: "./product-switcher.component.html",
|
templateUrl: "./product-switcher.component.html",
|
||||||
})
|
})
|
||||||
export class ProductSwitcherComponent implements AfterViewInit {
|
export class ProductSwitcherComponent implements AfterViewInit {
|
||||||
protected isEnabled = flagEnabled("secretsManager");
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Passed to the product switcher's `bitIconButton`
|
* Passed to the product switcher's `bitIconButton`
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -7,14 +7,13 @@ import {
|
|||||||
} from "@bitwarden/common/platform/misc/flags";
|
} from "@bitwarden/common/platform/misc/flags";
|
||||||
|
|
||||||
// required to avoid linting errors when there are no flags
|
// required to avoid linting errors when there are no flags
|
||||||
/* eslint-disable-next-line @typescript-eslint/ban-types */
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||||
export type Flags = {
|
export type Flags = {
|
||||||
secretsManager?: boolean;
|
|
||||||
showPasswordless?: boolean;
|
showPasswordless?: boolean;
|
||||||
} & SharedFlags;
|
} & SharedFlags;
|
||||||
|
|
||||||
// required to avoid linting errors when there are no flags
|
// required to avoid linting errors when there are no flags
|
||||||
/* eslint-disable-next-line @typescript-eslint/ban-types */
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||||
export type DevFlags = {} & SharedDevFlags;
|
export type DevFlags = {} & SharedDevFlags;
|
||||||
|
|
||||||
export function flagEnabled(flag: keyof Flags): boolean {
|
export function flagEnabled(flag: keyof Flags): boolean {
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import { NgModule } from "@angular/core";
|
|||||||
import { RouterModule, Routes } from "@angular/router";
|
import { RouterModule, Routes } from "@angular/router";
|
||||||
|
|
||||||
import { AuthGuard } from "@bitwarden/angular/auth/guards";
|
import { AuthGuard } from "@bitwarden/angular/auth/guards";
|
||||||
import { buildFlaggedRoute } from "@bitwarden/web-vault/app/oss-routing.module";
|
|
||||||
|
|
||||||
import { organizationEnabledGuard } from "./guards/sm-org-enabled.guard";
|
import { organizationEnabledGuard } from "./guards/sm-org-enabled.guard";
|
||||||
import { canActivateSM } from "./guards/sm.guard";
|
import { canActivateSM } from "./guards/sm.guard";
|
||||||
@@ -17,7 +16,7 @@ import { OrgSuspendedComponent } from "./shared/org-suspended.component";
|
|||||||
import { TrashModule } from "./trash/trash.module";
|
import { TrashModule } from "./trash/trash.module";
|
||||||
|
|
||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
buildFlaggedRoute("secretsManager", {
|
{
|
||||||
path: "",
|
path: "",
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
@@ -86,7 +85,7 @@ const routes: Routes = [
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
}),
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// required to avoid linting errors when there are no flags
|
// required to avoid linting errors when there are no flags
|
||||||
/* eslint-disable @typescript-eslint/ban-types */
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||||
export type SharedFlags = {
|
export type SharedFlags = {
|
||||||
multithreadDecryption: boolean;
|
multithreadDecryption: boolean;
|
||||||
showPasswordless?: boolean;
|
showPasswordless?: boolean;
|
||||||
@@ -7,7 +7,7 @@ export type SharedFlags = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// required to avoid linting errors when there are no flags
|
// required to avoid linting errors when there are no flags
|
||||||
/* eslint-disable @typescript-eslint/ban-types */
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||||
export type SharedDevFlags = {
|
export type SharedDevFlags = {
|
||||||
noopNotifications: boolean;
|
noopNotifications: boolean;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -102,6 +102,7 @@ export const SM_ONBOARDING_DISK = new StateDefinition("smOnboarding", "disk", {
|
|||||||
|
|
||||||
export const GENERATOR_DISK = new StateDefinition("generator", "disk");
|
export const GENERATOR_DISK = new StateDefinition("generator", "disk");
|
||||||
export const GENERATOR_MEMORY = new StateDefinition("generator", "memory");
|
export const GENERATOR_MEMORY = new StateDefinition("generator", "memory");
|
||||||
|
export const BROWSER_SEND_MEMORY = new StateDefinition("sendBrowser", "memory");
|
||||||
export const EVENT_COLLECTION_DISK = new StateDefinition("eventCollection", "disk");
|
export const EVENT_COLLECTION_DISK = new StateDefinition("eventCollection", "disk");
|
||||||
export const SEND_DISK = new StateDefinition("encryptedSend", "disk", {
|
export const SEND_DISK = new StateDefinition("encryptedSend", "disk", {
|
||||||
web: "memory",
|
web: "memory",
|
||||||
|
|||||||
2
package-lock.json
generated
2
package-lock.json
generated
@@ -247,7 +247,7 @@
|
|||||||
},
|
},
|
||||||
"apps/web": {
|
"apps/web": {
|
||||||
"name": "@bitwarden/web-vault",
|
"name": "@bitwarden/web-vault",
|
||||||
"version": "2024.3.1"
|
"version": "2024.4.0"
|
||||||
},
|
},
|
||||||
"libs/admin-console": {
|
"libs/admin-console": {
|
||||||
"name": "@bitwarden/admin-console",
|
"name": "@bitwarden/admin-console",
|
||||||
|
|||||||
Reference in New Issue
Block a user