mirror of
https://github.com/bitwarden/browser
synced 2026-02-21 03:43:58 +00:00
add and implement undetermined-cipher-scenario-logic feature flag
This commit is contained in:
@@ -21,8 +21,8 @@ export type LoginSecurityTaskInfo = {
|
||||
/**
|
||||
* Distinguished from `NotificationTypes` in that this represents the
|
||||
* pre-resolved notification scenario, vs the notification component
|
||||
* (e.g. "Add" and "Cipher" will be removed post-`useFullCipherTriggeringLogic`
|
||||
* migration)
|
||||
* (e.g. "Add" and "Change" will be removed
|
||||
* post-`useUndeterminedCipherScenarioTriggeringLogic` migration)
|
||||
*/
|
||||
export const NotificationScenarios = {
|
||||
...NotificationTypes,
|
||||
|
||||
@@ -22,6 +22,7 @@ import {
|
||||
import { DomainSettingsService } from "@bitwarden/common/autofill/services/domain-settings.service";
|
||||
import { UserNotificationSettingsServiceAbstraction } from "@bitwarden/common/autofill/services/user-notification-settings.service";
|
||||
import { ProductTierType } from "@bitwarden/common/billing/enums/product-tier-type.enum";
|
||||
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
|
||||
import { NeverDomains } from "@bitwarden/common/models/domain/domain-service";
|
||||
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
||||
import { ServerConfig } from "@bitwarden/common/platform/abstractions/config/server-config";
|
||||
@@ -176,6 +177,10 @@ export default class NotificationBackground {
|
||||
this.cleanupNotificationQueue();
|
||||
}
|
||||
|
||||
useUndeterminedCipherScenarioTriggeringLogic$ = this.configService.getFeatureFlag$(
|
||||
FeatureFlag.UseUndeterminedCipherScenarioTriggeringLogic,
|
||||
);
|
||||
|
||||
/**
|
||||
* Gets the enableChangedPasswordPrompt setting from the user notification settings service.
|
||||
*/
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { mock, MockProxy } from "jest-mock-extended";
|
||||
import { of } from "rxjs";
|
||||
|
||||
import { CLEAR_NOTIFICATION_LOGIN_DATA_DURATION } from "@bitwarden/common/autofill/constants";
|
||||
import { ServerConfig } from "@bitwarden/common/platform/abstractions/config/server-config";
|
||||
@@ -32,6 +33,7 @@ describe("OverlayNotificationsBackground", () => {
|
||||
jest.useFakeTimers();
|
||||
logService = mock<LogService>();
|
||||
notificationBackground = mock<NotificationBackground>();
|
||||
notificationBackground.useUndeterminedCipherScenarioTriggeringLogic$ = of(false);
|
||||
getEnableChangedPasswordPromptSpy = jest
|
||||
.spyOn(notificationBackground, "getEnableChangedPasswordPrompt")
|
||||
.mockResolvedValue(true);
|
||||
@@ -458,7 +460,7 @@ describe("OverlayNotificationsBackground", () => {
|
||||
const pageDetails = mock<AutofillPageDetails>({ fields: [mock<AutofillField>()] });
|
||||
|
||||
beforeEach(async () => {
|
||||
overlayNotificationsBackground["useUndiscoveredCipherScenarioTriggeringLogic"] = false;
|
||||
notificationBackground.useUndeterminedCipherScenarioTriggeringLogic$ = of(false);
|
||||
sendMockExtensionMessage(
|
||||
{ command: "collectPageDetailsResponse", details: pageDetails },
|
||||
sender,
|
||||
@@ -522,8 +524,8 @@ describe("OverlayNotificationsBackground", () => {
|
||||
expect(notificationAddLoginSpy).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("with `useUndiscoveredCipherScenarioTriggeringLogic` on, waits for the tab's navigation to complete using the web navigation API before initializing the notification", async () => {
|
||||
overlayNotificationsBackground["useUndiscoveredCipherScenarioTriggeringLogic"] = true;
|
||||
it("with `useUndeterminedCipherScenarioTriggeringLogic` on, waits for the tab's navigation to complete using the web navigation API before initializing the notification", async () => {
|
||||
notificationBackground.useUndeterminedCipherScenarioTriggeringLogic$ = of(true);
|
||||
chrome.tabs.get = jest.fn().mockImplementationOnce((tabId, callback) => {
|
||||
callback(
|
||||
mock<chrome.tabs.Tab>({
|
||||
@@ -593,8 +595,8 @@ describe("OverlayNotificationsBackground", () => {
|
||||
expect(notificationAddLoginSpy).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("with `useUndiscoveredCipherScenarioTriggeringLogic` on, initializes the notification immediately when the tab's navigation is complete", async () => {
|
||||
overlayNotificationsBackground["useUndiscoveredCipherScenarioTriggeringLogic"] = true;
|
||||
it("with `useUndeterminedCipherScenarioTriggeringLogic` on, initializes the notification immediately when the tab's navigation is complete", async () => {
|
||||
notificationBackground.useUndeterminedCipherScenarioTriggeringLogic$ = of(true);
|
||||
sendMockExtensionMessage(
|
||||
{
|
||||
command: "formFieldSubmitted",
|
||||
@@ -677,8 +679,8 @@ describe("OverlayNotificationsBackground", () => {
|
||||
expect(notificationChangedPasswordSpy).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("with `useUndiscoveredCipherScenarioTriggeringLogic` on, triggers the notification on the beforeRequest listener when a post-submission redirection is encountered", async () => {
|
||||
overlayNotificationsBackground["useUndiscoveredCipherScenarioTriggeringLogic"] = true;
|
||||
it("with `useUndeterminedCipherScenarioTriggeringLogic` on, triggers the notification on the beforeRequest listener when a post-submission redirection is encountered", async () => {
|
||||
notificationBackground.useUndeterminedCipherScenarioTriggeringLogic$ = of(true);
|
||||
sender.tab = mock<chrome.tabs.Tab>({ id: 4 });
|
||||
sendMockExtensionMessage(
|
||||
{ command: "collectPageDetailsResponse", details: pageDetails },
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Subject, switchMap, timer } from "rxjs";
|
||||
import { firstValueFrom, Subject, switchMap, timer } from "rxjs";
|
||||
|
||||
import { CLEAR_NOTIFICATION_LOGIN_DATA_DURATION } from "@bitwarden/common/autofill/constants";
|
||||
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
|
||||
@@ -33,9 +33,6 @@ export class OverlayNotificationsBackground implements OverlayNotificationsBackg
|
||||
collectPageDetailsResponse: ({ message, sender }) =>
|
||||
this.handleCollectPageDetailsResponse(message, sender),
|
||||
};
|
||||
// @TODO update via feature-flag
|
||||
private useUndiscoveredCipherScenarioTriggeringLogic = false;
|
||||
|
||||
constructor(
|
||||
private logService: LogService,
|
||||
private notificationBackground: NotificationBackground,
|
||||
@@ -450,7 +447,11 @@ export class OverlayNotificationsBackground implements OverlayNotificationsBackg
|
||||
tab: chrome.tabs.Tab,
|
||||
config: { skippable: NotificationScenario[] } = { skippable: [] },
|
||||
) => {
|
||||
const notificationCandidates = this.useUndiscoveredCipherScenarioTriggeringLogic
|
||||
const useUndeterminedCipherScenarioTriggeringLogic = await firstValueFrom(
|
||||
this.notificationBackground.useUndeterminedCipherScenarioTriggeringLogic$,
|
||||
);
|
||||
|
||||
const notificationCandidates = useUndeterminedCipherScenarioTriggeringLogic
|
||||
? [
|
||||
{
|
||||
type: NotificationScenarios.Cipher,
|
||||
|
||||
@@ -20,6 +20,7 @@ export enum FeatureFlag {
|
||||
PM23801_PrefetchPasswordPrelogin = "pm-23801-prefetch-password-prelogin",
|
||||
|
||||
/* Autofill */
|
||||
UseUndeterminedCipherScenarioTriggeringLogic = "undetermined-cipher-scenario-logic",
|
||||
MacOsNativeCredentialSync = "macos-native-credential-sync",
|
||||
WindowsDesktopAutotype = "windows-desktop-autotype",
|
||||
WindowsDesktopAutotypeGA = "windows-desktop-autotype-ga",
|
||||
@@ -107,6 +108,7 @@ export const DefaultFeatureFlagValue = {
|
||||
[FeatureFlag.MembersComponentRefactor]: FALSE,
|
||||
|
||||
/* Autofill */
|
||||
[FeatureFlag.UseUndeterminedCipherScenarioTriggeringLogic]: FALSE,
|
||||
[FeatureFlag.MacOsNativeCredentialSync]: FALSE,
|
||||
[FeatureFlag.WindowsDesktopAutotype]: FALSE,
|
||||
[FeatureFlag.WindowsDesktopAutotypeGA]: FALSE,
|
||||
|
||||
Reference in New Issue
Block a user