1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-11 13:53:34 +00:00

[PM-19632] Remove security task flag - step 1 (#14904)

* Step 1- remove business logic

* removed dependency

* removed leftover flags
This commit is contained in:
SmithThe4th
2025-06-03 12:20:29 -04:00
committed by GitHub
parent 8a29df64d9
commit 2e66addd6a
6 changed files with 4 additions and 45 deletions

View File

@@ -1203,7 +1203,6 @@ export default class MainBackground {
this.stateProvider, this.stateProvider,
this.apiService, this.apiService,
this.organizationService, this.organizationService,
this.configService,
this.authService, this.authService,
this.notificationsService, this.notificationsService,
messageListener, messageListener,
@@ -1423,9 +1422,7 @@ export default class MainBackground {
this.backgroundSyncService.init(); this.backgroundSyncService.init();
this.notificationsService.startListening(); this.notificationsService.startListening();
if (await this.configService.getFeatureFlag(FeatureFlag.SecurityTasks)) { this.taskService.listenForTaskNotifications();
this.taskService.listenForTaskNotifications();
}
if (await this.configService.getFeatureFlag(FeatureFlag.EndUserNotifications)) { if (await this.configService.getFeatureFlag(FeatureFlag.EndUserNotifications)) {
this.endUserNotificationService.listenForEndUserNotifications(); this.endUserNotificationService.listenForEndUserNotifications();

View File

@@ -53,9 +53,7 @@
</ul> </ul>
</bit-spotlight> </bit-spotlight>
</div> </div>
<vault-at-risk-password-callout <vault-at-risk-password-callout></vault-at-risk-password-callout>
*appIfFeature="FeatureFlag.SecurityTasks"
></vault-at-risk-password-callout>
<app-vault-header-v2></app-vault-header-v2> <app-vault-header-v2></app-vault-header-v2>
</ng-container> </ng-container>
</ng-container> </ng-container>

View File

@@ -1511,7 +1511,6 @@ const safeProviders: SafeProvider[] = [
StateProvider, StateProvider,
ApiServiceAbstraction, ApiServiceAbstraction,
OrganizationServiceAbstraction, OrganizationServiceAbstraction,
ConfigService,
AuthServiceAbstraction, AuthServiceAbstraction,
NotificationsService, NotificationsService,
MessageListener, MessageListener,

View File

@@ -51,7 +51,6 @@ export enum FeatureFlag {
/* Vault */ /* Vault */
PM8851_BrowserOnboardingNudge = "pm-8851-browser-onboarding-nudge", PM8851_BrowserOnboardingNudge = "pm-8851-browser-onboarding-nudge",
PM9111ExtensionPersistAddEditForm = "pm-9111-extension-persist-add-edit-form", PM9111ExtensionPersistAddEditForm = "pm-9111-extension-persist-add-edit-form",
SecurityTasks = "security-tasks",
PM19941MigrateCipherDomainToSdk = "pm-19941-migrate-cipher-domain-to-sdk", PM19941MigrateCipherDomainToSdk = "pm-19941-migrate-cipher-domain-to-sdk",
CipherKeyEncryption = "cipher-key-encryption", CipherKeyEncryption = "cipher-key-encryption",
PM18520_UpdateDesktopCipherForm = "pm-18520-desktop-cipher-forms", PM18520_UpdateDesktopCipherForm = "pm-18520-desktop-cipher-forms",
@@ -98,7 +97,6 @@ export const DefaultFeatureFlagValue = {
/* Vault */ /* Vault */
[FeatureFlag.PM8851_BrowserOnboardingNudge]: FALSE, [FeatureFlag.PM8851_BrowserOnboardingNudge]: FALSE,
[FeatureFlag.PM9111ExtensionPersistAddEditForm]: FALSE, [FeatureFlag.PM9111ExtensionPersistAddEditForm]: FALSE,
[FeatureFlag.SecurityTasks]: FALSE,
[FeatureFlag.CipherKeyEncryption]: FALSE, [FeatureFlag.CipherKeyEncryption]: FALSE,
[FeatureFlag.PM18520_UpdateDesktopCipherForm]: FALSE, [FeatureFlag.PM18520_UpdateDesktopCipherForm]: FALSE,
[FeatureFlag.EndUserNotifications]: FALSE, [FeatureFlag.EndUserNotifications]: FALSE,

View File

@@ -7,7 +7,6 @@ import { AuthService } from "@bitwarden/common/auth/abstractions/auth.service";
import { AuthenticationStatus } from "@bitwarden/common/auth/enums/authentication-status"; import { AuthenticationStatus } from "@bitwarden/common/auth/enums/authentication-status";
import { NotificationType } from "@bitwarden/common/enums"; import { NotificationType } from "@bitwarden/common/enums";
import { NotificationResponse } from "@bitwarden/common/models/response/notification.response"; import { NotificationResponse } from "@bitwarden/common/models/response/notification.response";
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
import { Message, MessageListener } from "@bitwarden/common/platform/messaging"; import { Message, MessageListener } from "@bitwarden/common/platform/messaging";
import { NotificationsService } from "@bitwarden/common/platform/notifications"; import { NotificationsService } from "@bitwarden/common/platform/notifications";
import { SecurityTaskId, UserId } from "@bitwarden/common/types/guid"; import { SecurityTaskId, UserId } from "@bitwarden/common/types/guid";
@@ -25,7 +24,6 @@ describe("Default task service", () => {
const userId = "user-id" as UserId; const userId = "user-id" as UserId;
const mockApiSend = jest.fn(); const mockApiSend = jest.fn();
const mockGetAllOrgs$ = jest.fn(); const mockGetAllOrgs$ = jest.fn();
const mockGetFeatureFlag$ = jest.fn();
const mockAuthStatuses$ = new BehaviorSubject<Record<UserId, AuthenticationStatus>>({}); const mockAuthStatuses$ = new BehaviorSubject<Record<UserId, AuthenticationStatus>>({});
const mockNotifications$ = new Subject<readonly [NotificationResponse, UserId]>(); const mockNotifications$ = new Subject<readonly [NotificationResponse, UserId]>();
const mockMessages$ = new Subject<Message<Record<string, unknown>>>(); const mockMessages$ = new Subject<Message<Record<string, unknown>>>();
@@ -34,14 +32,12 @@ describe("Default task service", () => {
beforeEach(async () => { beforeEach(async () => {
mockApiSend.mockClear(); mockApiSend.mockClear();
mockGetAllOrgs$.mockClear(); mockGetAllOrgs$.mockClear();
mockGetFeatureFlag$.mockClear();
fakeStateProvider = new FakeStateProvider(mockAccountServiceWith(userId)); fakeStateProvider = new FakeStateProvider(mockAccountServiceWith(userId));
service = new DefaultTaskService( service = new DefaultTaskService(
fakeStateProvider, fakeStateProvider,
{ send: mockApiSend } as unknown as ApiService, { send: mockApiSend } as unknown as ApiService,
{ organizations$: mockGetAllOrgs$ } as unknown as OrganizationService, { organizations$: mockGetAllOrgs$ } as unknown as OrganizationService,
{ getFeatureFlag$: mockGetFeatureFlag$ } as unknown as ConfigService,
{ authStatuses$: mockAuthStatuses$.asObservable() } as unknown as AuthService, { authStatuses$: mockAuthStatuses$.asObservable() } as unknown as AuthService,
{ notifications$: mockNotifications$.asObservable() } as unknown as NotificationsService, { notifications$: mockNotifications$.asObservable() } as unknown as NotificationsService,
{ allMessages$: mockMessages$.asObservable() } as unknown as MessageListener, { allMessages$: mockMessages$.asObservable() } as unknown as MessageListener,
@@ -50,7 +46,6 @@ describe("Default task service", () => {
describe("tasksEnabled$", () => { describe("tasksEnabled$", () => {
it("should emit true if any organization uses risk insights", async () => { it("should emit true if any organization uses risk insights", async () => {
mockGetFeatureFlag$.mockReturnValue(new BehaviorSubject(true));
mockGetAllOrgs$.mockReturnValue( mockGetAllOrgs$.mockReturnValue(
new BehaviorSubject([ new BehaviorSubject([
{ {
@@ -70,7 +65,6 @@ describe("Default task service", () => {
}); });
it("should emit false if no organization uses risk insights", async () => { it("should emit false if no organization uses risk insights", async () => {
mockGetFeatureFlag$.mockReturnValue(new BehaviorSubject(true));
mockGetAllOrgs$.mockReturnValue( mockGetAllOrgs$.mockReturnValue(
new BehaviorSubject([ new BehaviorSubject([
{ {
@@ -88,28 +82,10 @@ describe("Default task service", () => {
expect(result).toBe(false); expect(result).toBe(false);
}); });
it("should emit false if the feature flag is off", async () => {
mockGetFeatureFlag$.mockReturnValue(new BehaviorSubject(false));
mockGetAllOrgs$.mockReturnValue(
new BehaviorSubject([
{
useRiskInsights: true,
},
] as Organization[]),
);
const { tasksEnabled$ } = service;
const result = await firstValueFrom(tasksEnabled$("user-id" as UserId));
expect(result).toBe(false);
});
}); });
describe("tasks$", () => { describe("tasks$", () => {
beforeEach(() => { beforeEach(() => {
mockGetFeatureFlag$.mockReturnValue(new BehaviorSubject(true));
mockGetAllOrgs$.mockReturnValue( mockGetAllOrgs$.mockReturnValue(
new BehaviorSubject([ new BehaviorSubject([
{ {
@@ -182,7 +158,6 @@ describe("Default task service", () => {
describe("pendingTasks$", () => { describe("pendingTasks$", () => {
beforeEach(() => { beforeEach(() => {
mockGetFeatureFlag$.mockReturnValue(new BehaviorSubject(true));
mockGetAllOrgs$.mockReturnValue( mockGetAllOrgs$.mockReturnValue(
new BehaviorSubject([ new BehaviorSubject([
{ {

View File

@@ -15,9 +15,7 @@ import { OrganizationService } from "@bitwarden/common/admin-console/abstraction
import { AuthService } from "@bitwarden/common/auth/abstractions/auth.service"; import { AuthService } from "@bitwarden/common/auth/abstractions/auth.service";
import { AuthenticationStatus } from "@bitwarden/common/auth/enums/authentication-status"; import { AuthenticationStatus } from "@bitwarden/common/auth/enums/authentication-status";
import { NotificationType } from "@bitwarden/common/enums"; import { NotificationType } from "@bitwarden/common/enums";
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
import { ListResponse } from "@bitwarden/common/models/response/list.response"; import { ListResponse } from "@bitwarden/common/models/response/list.response";
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
import { MessageListener } from "@bitwarden/common/platform/messaging"; import { MessageListener } from "@bitwarden/common/platform/messaging";
import { NotificationsService } from "@bitwarden/common/platform/notifications"; import { NotificationsService } from "@bitwarden/common/platform/notifications";
import { StateProvider } from "@bitwarden/common/platform/state"; import { StateProvider } from "@bitwarden/common/platform/state";
@@ -43,20 +41,14 @@ export class DefaultTaskService implements TaskService {
private stateProvider: StateProvider, private stateProvider: StateProvider,
private apiService: ApiService, private apiService: ApiService,
private organizationService: OrganizationService, private organizationService: OrganizationService,
private configService: ConfigService,
private authService: AuthService, private authService: AuthService,
private notificationService: NotificationsService, private notificationService: NotificationsService,
private messageListener: MessageListener, private messageListener: MessageListener,
) {} ) {}
tasksEnabled$ = perUserCache$((userId) => { tasksEnabled$ = perUserCache$((userId) => {
return combineLatest([ return this.organizationService.organizations$(userId).pipe(
this.organizationService map((orgs) => orgs.some((o) => o.useRiskInsights)),
.organizations$(userId)
.pipe(map((orgs) => orgs.some((o) => o.useRiskInsights))),
this.configService.getFeatureFlag$(FeatureFlag.SecurityTasks),
]).pipe(
map(([atLeastOneOrgEnabled, flagEnabled]) => atLeastOneOrgEnabled && flagEnabled),
distinctUntilChanged(), distinctUntilChanged(),
); );
}); });