mirror of
https://github.com/bitwarden/browser
synced 2025-12-12 06:13:38 +00:00
[PM-17563] [PM-19754] Migrate Security Task Module to libs/common (#14036)
* [PM-17563] Remove references to Angular from TaskService * [PM-17563] Move Task module to libs/common/vault to avoid Angular dependency * [PM-17563] Fix bad imports * [PM-17563] Fix a few more missed imports
This commit is contained in:
@@ -4,8 +4,9 @@ import { switchMap, tap } from "rxjs";
|
|||||||
|
|
||||||
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
||||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||||
|
import { TaskService } from "@bitwarden/common/vault/tasks";
|
||||||
|
import { filterOutNullish } from "@bitwarden/common/vault/utils/observable-utilities";
|
||||||
import { ToastService } from "@bitwarden/components";
|
import { ToastService } from "@bitwarden/components";
|
||||||
import { filterOutNullish, TaskService } from "@bitwarden/vault";
|
|
||||||
|
|
||||||
export const canAccessAtRiskPasswords: CanActivateFn = () => {
|
export const canAccessAtRiskPasswords: CanActivateFn = () => {
|
||||||
const accountService = inject(AccountService);
|
const accountService = inject(AccountService);
|
||||||
|
|||||||
@@ -4,9 +4,10 @@ import { RouterModule } from "@angular/router";
|
|||||||
import { map, switchMap } from "rxjs";
|
import { map, switchMap } from "rxjs";
|
||||||
|
|
||||||
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
||||||
|
import { SecurityTaskType, TaskService } from "@bitwarden/common/vault/tasks";
|
||||||
|
import { filterOutNullish } from "@bitwarden/common/vault/utils/observable-utilities";
|
||||||
import { AnchorLinkDirective, CalloutModule } from "@bitwarden/components";
|
import { AnchorLinkDirective, CalloutModule } from "@bitwarden/components";
|
||||||
import { I18nPipe } from "@bitwarden/ui-common";
|
import { I18nPipe } from "@bitwarden/ui-common";
|
||||||
import { filterOutNullish, SecurityTaskType, TaskService } from "@bitwarden/vault";
|
|
||||||
|
|
||||||
// TODO: This component will need to be reworked to use the new EndUserNotificationService in PM-10609
|
// TODO: This component will need to be reworked to use the new EndUserNotificationService in PM-10609
|
||||||
|
|
||||||
|
|||||||
@@ -16,14 +16,12 @@ import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.servic
|
|||||||
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
||||||
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
|
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
|
||||||
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
|
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
|
||||||
|
import { SecurityTask, SecurityTaskType, TaskService } from "@bitwarden/common/vault/tasks";
|
||||||
import { DialogService, ToastService } from "@bitwarden/components";
|
import { DialogService, ToastService } from "@bitwarden/components";
|
||||||
import {
|
import {
|
||||||
ChangeLoginPasswordService,
|
ChangeLoginPasswordService,
|
||||||
DefaultChangeLoginPasswordService,
|
DefaultChangeLoginPasswordService,
|
||||||
PasswordRepromptService,
|
PasswordRepromptService,
|
||||||
SecurityTask,
|
|
||||||
SecurityTaskType,
|
|
||||||
TaskService,
|
|
||||||
} from "@bitwarden/vault";
|
} from "@bitwarden/vault";
|
||||||
|
|
||||||
import { PopupHeaderComponent } from "../../../../platform/popup/layout/popup-header.component";
|
import { PopupHeaderComponent } from "../../../../platform/popup/layout/popup-header.component";
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.servic
|
|||||||
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
||||||
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
|
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
|
||||||
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
|
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
|
||||||
|
import { SecurityTaskType, TaskService } from "@bitwarden/common/vault/tasks";
|
||||||
|
import { filterOutNullish } from "@bitwarden/common/vault/utils/observable-utilities";
|
||||||
import {
|
import {
|
||||||
BadgeModule,
|
BadgeModule,
|
||||||
ButtonModule,
|
ButtonModule,
|
||||||
@@ -28,10 +30,7 @@ import {
|
|||||||
import {
|
import {
|
||||||
ChangeLoginPasswordService,
|
ChangeLoginPasswordService,
|
||||||
DefaultChangeLoginPasswordService,
|
DefaultChangeLoginPasswordService,
|
||||||
filterOutNullish,
|
|
||||||
PasswordRepromptService,
|
PasswordRepromptService,
|
||||||
SecurityTaskType,
|
|
||||||
TaskService,
|
|
||||||
VaultCarouselModule,
|
VaultCarouselModule,
|
||||||
} from "@bitwarden/vault";
|
} from "@bitwarden/vault";
|
||||||
|
|
||||||
|
|||||||
@@ -33,19 +33,17 @@ import { CipherAuthorizationService } from "@bitwarden/common/vault/services/cip
|
|||||||
import {
|
import {
|
||||||
AsyncActionsModule,
|
AsyncActionsModule,
|
||||||
ButtonModule,
|
ButtonModule,
|
||||||
|
CalloutModule,
|
||||||
DialogService,
|
DialogService,
|
||||||
IconButtonModule,
|
IconButtonModule,
|
||||||
SearchModule,
|
SearchModule,
|
||||||
ToastService,
|
ToastService,
|
||||||
CalloutModule,
|
|
||||||
} from "@bitwarden/components";
|
} from "@bitwarden/components";
|
||||||
import {
|
import {
|
||||||
ChangeLoginPasswordService,
|
ChangeLoginPasswordService,
|
||||||
CipherViewComponent,
|
CipherViewComponent,
|
||||||
CopyCipherFieldService,
|
CopyCipherFieldService,
|
||||||
DefaultChangeLoginPasswordService,
|
DefaultChangeLoginPasswordService,
|
||||||
DefaultTaskService,
|
|
||||||
TaskService,
|
|
||||||
} from "@bitwarden/vault";
|
} from "@bitwarden/vault";
|
||||||
|
|
||||||
import { BrowserApi } from "../../../../../platform/browser/browser-api";
|
import { BrowserApi } from "../../../../../platform/browser/browser-api";
|
||||||
@@ -95,7 +93,6 @@ type LoadAction =
|
|||||||
providers: [
|
providers: [
|
||||||
{ provide: ViewPasswordHistoryService, useClass: BrowserViewPasswordHistoryService },
|
{ provide: ViewPasswordHistoryService, useClass: BrowserViewPasswordHistoryService },
|
||||||
{ provide: PremiumUpgradePromptService, useClass: BrowserPremiumUpgradePromptService },
|
{ provide: PremiumUpgradePromptService, useClass: BrowserPremiumUpgradePromptService },
|
||||||
{ provide: TaskService, useClass: DefaultTaskService },
|
|
||||||
{ provide: ChangeLoginPasswordService, useClass: DefaultChangeLoginPasswordService },
|
{ provide: ChangeLoginPasswordService, useClass: DefaultChangeLoginPasswordService },
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -17,8 +17,9 @@ import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.servi
|
|||||||
import { FolderService } from "@bitwarden/common/vault/abstractions/folder/folder.service.abstraction";
|
import { FolderService } from "@bitwarden/common/vault/abstractions/folder/folder.service.abstraction";
|
||||||
import { CipherType } from "@bitwarden/common/vault/enums";
|
import { CipherType } from "@bitwarden/common/vault/enums";
|
||||||
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
|
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
|
||||||
|
import { TaskService } from "@bitwarden/common/vault/tasks";
|
||||||
import { DialogService } from "@bitwarden/components";
|
import { DialogService } from "@bitwarden/components";
|
||||||
import { ChangeLoginPasswordService, TaskService } from "@bitwarden/vault";
|
import { ChangeLoginPasswordService } from "@bitwarden/vault";
|
||||||
|
|
||||||
import { EmergencyViewDialogComponent } from "./emergency-view-dialog.component";
|
import { EmergencyViewDialogComponent } from "./emergency-view-dialog.component";
|
||||||
|
|
||||||
@@ -55,6 +56,7 @@ describe("EmergencyViewDialogComponent", () => {
|
|||||||
{ provide: DialogRef, useValue: { close } },
|
{ provide: DialogRef, useValue: { close } },
|
||||||
{ provide: DIALOG_DATA, useValue: { cipher: mockCipher } },
|
{ provide: DIALOG_DATA, useValue: { cipher: mockCipher } },
|
||||||
{ provide: AccountService, useValue: accountService },
|
{ provide: AccountService, useValue: accountService },
|
||||||
|
{ provide: TaskService, useValue: mock<TaskService>() },
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
.overrideComponent(EmergencyViewDialogComponent, {
|
.overrideComponent(EmergencyViewDialogComponent, {
|
||||||
@@ -71,10 +73,6 @@ describe("EmergencyViewDialogComponent", () => {
|
|||||||
},
|
},
|
||||||
add: {
|
add: {
|
||||||
providers: [
|
providers: [
|
||||||
{
|
|
||||||
provide: TaskService,
|
|
||||||
useValue: mock<TaskService>(),
|
|
||||||
},
|
|
||||||
{ provide: PlatformUtilsService, useValue: mock<PlatformUtilsService>() },
|
{ provide: PlatformUtilsService, useValue: mock<PlatformUtilsService>() },
|
||||||
{
|
{
|
||||||
provide: ChangeLoginPasswordService,
|
provide: ChangeLoginPasswordService,
|
||||||
|
|||||||
@@ -13,8 +13,6 @@ import {
|
|||||||
ChangeLoginPasswordService,
|
ChangeLoginPasswordService,
|
||||||
CipherViewComponent,
|
CipherViewComponent,
|
||||||
DefaultChangeLoginPasswordService,
|
DefaultChangeLoginPasswordService,
|
||||||
DefaultTaskService,
|
|
||||||
TaskService,
|
|
||||||
} from "@bitwarden/vault";
|
} from "@bitwarden/vault";
|
||||||
|
|
||||||
import { WebViewPasswordHistoryService } from "../../../../vault/services/web-view-password-history.service";
|
import { WebViewPasswordHistoryService } from "../../../../vault/services/web-view-password-history.service";
|
||||||
@@ -39,7 +37,6 @@ class PremiumUpgradePromptNoop implements PremiumUpgradePromptService {
|
|||||||
providers: [
|
providers: [
|
||||||
{ provide: ViewPasswordHistoryService, useClass: WebViewPasswordHistoryService },
|
{ provide: ViewPasswordHistoryService, useClass: WebViewPasswordHistoryService },
|
||||||
{ provide: PremiumUpgradePromptService, useClass: PremiumUpgradePromptNoop },
|
{ provide: PremiumUpgradePromptService, useClass: PremiumUpgradePromptNoop },
|
||||||
{ provide: TaskService, useClass: DefaultTaskService },
|
|
||||||
{ provide: ChangeLoginPasswordService, useClass: DefaultChangeLoginPasswordService },
|
{ provide: ChangeLoginPasswordService, useClass: DefaultChangeLoginPasswordService },
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ import {
|
|||||||
} from "@bitwarden/components";
|
} from "@bitwarden/components";
|
||||||
import {
|
import {
|
||||||
ChangeLoginPasswordService,
|
ChangeLoginPasswordService,
|
||||||
CipherAttachmentsComponent,
|
|
||||||
CipherFormComponent,
|
CipherFormComponent,
|
||||||
CipherFormConfig,
|
CipherFormConfig,
|
||||||
CipherFormGenerationService,
|
CipherFormGenerationService,
|
||||||
@@ -47,8 +46,6 @@ import {
|
|||||||
CipherViewComponent,
|
CipherViewComponent,
|
||||||
DecryptionFailureDialogComponent,
|
DecryptionFailureDialogComponent,
|
||||||
DefaultChangeLoginPasswordService,
|
DefaultChangeLoginPasswordService,
|
||||||
DefaultTaskService,
|
|
||||||
TaskService,
|
|
||||||
} from "@bitwarden/vault";
|
} from "@bitwarden/vault";
|
||||||
|
|
||||||
import { SharedModule } from "../../../shared/shared.module";
|
import { SharedModule } from "../../../shared/shared.module";
|
||||||
@@ -132,17 +129,14 @@ export enum VaultItemDialogResult {
|
|||||||
CommonModule,
|
CommonModule,
|
||||||
SharedModule,
|
SharedModule,
|
||||||
CipherFormModule,
|
CipherFormModule,
|
||||||
CipherAttachmentsComponent,
|
|
||||||
AsyncActionsModule,
|
AsyncActionsModule,
|
||||||
ItemModule,
|
ItemModule,
|
||||||
DecryptionFailureDialogComponent,
|
|
||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
{ provide: PremiumUpgradePromptService, useClass: WebVaultPremiumUpgradePromptService },
|
{ provide: PremiumUpgradePromptService, useClass: WebVaultPremiumUpgradePromptService },
|
||||||
{ provide: ViewPasswordHistoryService, useClass: WebViewPasswordHistoryService },
|
{ provide: ViewPasswordHistoryService, useClass: WebViewPasswordHistoryService },
|
||||||
{ provide: CipherFormGenerationService, useClass: WebCipherFormGenerationService },
|
{ provide: CipherFormGenerationService, useClass: WebCipherFormGenerationService },
|
||||||
RoutedVaultFilterService,
|
RoutedVaultFilterService,
|
||||||
{ provide: TaskService, useClass: DefaultTaskService },
|
|
||||||
{ provide: ChangeLoginPasswordService, useClass: DefaultChangeLoginPasswordService },
|
{ provide: ChangeLoginPasswordService, useClass: DefaultChangeLoginPasswordService },
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -20,9 +20,10 @@ import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.servi
|
|||||||
import { FolderService } from "@bitwarden/common/vault/abstractions/folder/folder.service.abstraction";
|
import { FolderService } from "@bitwarden/common/vault/abstractions/folder/folder.service.abstraction";
|
||||||
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
|
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
|
||||||
import { CipherAuthorizationService } from "@bitwarden/common/vault/services/cipher-authorization.service";
|
import { CipherAuthorizationService } from "@bitwarden/common/vault/services/cipher-authorization.service";
|
||||||
|
import { TaskService } from "@bitwarden/common/vault/tasks";
|
||||||
import { DialogService, ToastService } from "@bitwarden/components";
|
import { DialogService, ToastService } from "@bitwarden/components";
|
||||||
import { KeyService } from "@bitwarden/key-management";
|
import { KeyService } from "@bitwarden/key-management";
|
||||||
import { ChangeLoginPasswordService, DefaultTaskService, TaskService } from "@bitwarden/vault";
|
import { ChangeLoginPasswordService } from "@bitwarden/vault";
|
||||||
|
|
||||||
import { ViewCipherDialogParams, ViewCipherDialogResult, ViewComponent } from "./view.component";
|
import { ViewCipherDialogParams, ViewCipherDialogResult, ViewComponent } from "./view.component";
|
||||||
|
|
||||||
@@ -83,12 +84,12 @@ describe("ViewComponent", () => {
|
|||||||
canDeleteCipher$: jest.fn().mockReturnValue(true),
|
canDeleteCipher$: jest.fn().mockReturnValue(true),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{ provide: TaskService, useValue: mock<TaskService>() },
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
.overrideComponent(ViewComponent, {
|
.overrideComponent(ViewComponent, {
|
||||||
remove: {
|
remove: {
|
||||||
providers: [
|
providers: [
|
||||||
{ provide: TaskService, useClass: DefaultTaskService },
|
|
||||||
{ provide: PlatformUtilsService, useValue: PlatformUtilsService },
|
{ provide: PlatformUtilsService, useValue: PlatformUtilsService },
|
||||||
{
|
{
|
||||||
provide: ChangeLoginPasswordService,
|
provide: ChangeLoginPasswordService,
|
||||||
@@ -98,10 +99,6 @@ describe("ViewComponent", () => {
|
|||||||
},
|
},
|
||||||
add: {
|
add: {
|
||||||
providers: [
|
providers: [
|
||||||
{
|
|
||||||
provide: TaskService,
|
|
||||||
useValue: mock<TaskService>(),
|
|
||||||
},
|
|
||||||
{ provide: PlatformUtilsService, useValue: mock<PlatformUtilsService>() },
|
{ provide: PlatformUtilsService, useValue: mock<PlatformUtilsService>() },
|
||||||
{
|
{
|
||||||
provide: ChangeLoginPasswordService,
|
provide: ChangeLoginPasswordService,
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
import { DIALOG_DATA, DialogConfig, DialogRef } from "@angular/cdk/dialog";
|
import { DIALOG_DATA, DialogConfig, DialogRef } from "@angular/cdk/dialog";
|
||||||
import { CommonModule } from "@angular/common";
|
import { CommonModule } from "@angular/common";
|
||||||
import { Component, EventEmitter, Inject, OnInit } from "@angular/core";
|
import { Component, EventEmitter, Inject, OnInit } from "@angular/core";
|
||||||
import { Observable, firstValueFrom, map } from "rxjs";
|
import { firstValueFrom, map, Observable } from "rxjs";
|
||||||
|
|
||||||
import { CollectionView } from "@bitwarden/admin-console/common";
|
import { CollectionView } from "@bitwarden/admin-console/common";
|
||||||
import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
|
import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
|
||||||
@@ -26,7 +26,7 @@ import {
|
|||||||
DialogService,
|
DialogService,
|
||||||
ToastService,
|
ToastService,
|
||||||
} from "@bitwarden/components";
|
} from "@bitwarden/components";
|
||||||
import { CipherViewComponent, DefaultTaskService, TaskService } from "@bitwarden/vault";
|
import { CipherViewComponent } from "@bitwarden/vault";
|
||||||
|
|
||||||
import { SharedModule } from "../../shared/shared.module";
|
import { SharedModule } from "../../shared/shared.module";
|
||||||
import { WebVaultPremiumUpgradePromptService } from "../services/web-premium-upgrade-prompt.service";
|
import { WebVaultPremiumUpgradePromptService } from "../services/web-premium-upgrade-prompt.service";
|
||||||
@@ -74,7 +74,6 @@ export interface ViewCipherDialogCloseResult {
|
|||||||
providers: [
|
providers: [
|
||||||
{ provide: ViewPasswordHistoryService, useClass: WebViewPasswordHistoryService },
|
{ provide: ViewPasswordHistoryService, useClass: WebViewPasswordHistoryService },
|
||||||
{ provide: PremiumUpgradePromptService, useClass: WebVaultPremiumUpgradePromptService },
|
{ provide: PremiumUpgradePromptService, useClass: WebVaultPremiumUpgradePromptService },
|
||||||
{ provide: TaskService, useClass: DefaultTaskService },
|
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
export class ViewComponent implements OnInit {
|
export class ViewComponent implements OnInit {
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
|
|||||||
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
||||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||||
import { CipherId, OrganizationId } from "@bitwarden/common/types/guid";
|
import { CipherId, OrganizationId } from "@bitwarden/common/types/guid";
|
||||||
|
import { SecurityTaskType } from "@bitwarden/common/vault/tasks";
|
||||||
import {
|
import {
|
||||||
Icons,
|
Icons,
|
||||||
NoItemsModule,
|
NoItemsModule,
|
||||||
@@ -27,7 +28,6 @@ import {
|
|||||||
ToastService,
|
ToastService,
|
||||||
} from "@bitwarden/components";
|
} from "@bitwarden/components";
|
||||||
import { CardComponent } from "@bitwarden/tools-card";
|
import { CardComponent } from "@bitwarden/tools-card";
|
||||||
import { SecurityTaskType } from "@bitwarden/vault";
|
|
||||||
import { HeaderModule } from "@bitwarden/web-vault/app/layouts/header/header.module";
|
import { HeaderModule } from "@bitwarden/web-vault/app/layouts/header/header.module";
|
||||||
import { SharedModule } from "@bitwarden/web-vault/app/shared";
|
import { SharedModule } from "@bitwarden/web-vault/app/shared";
|
||||||
import { PipesModule } from "@bitwarden/web-vault/app/vault/individual-vault/pipes/pipes.module";
|
import { PipesModule } from "@bitwarden/web-vault/app/vault/individual-vault/pipes/pipes.module";
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { CipherId, OrganizationId } from "@bitwarden/common/types/guid";
|
import { CipherId, OrganizationId } from "@bitwarden/common/types/guid";
|
||||||
import { SecurityTask, SecurityTaskStatus, SecurityTaskType } from "@bitwarden/vault";
|
import { SecurityTask, SecurityTaskStatus, SecurityTaskType } from "@bitwarden/common/vault/tasks";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Request type for creating tasks.
|
* Request type for creating tasks.
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { MockProxy, mock } from "jest-mock-extended";
|
import { mock, MockProxy } from "jest-mock-extended";
|
||||||
|
|
||||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||||
import { CipherId, OrganizationId } from "@bitwarden/common/types/guid";
|
import { CipherId, OrganizationId } from "@bitwarden/common/types/guid";
|
||||||
import { SecurityTaskStatus, SecurityTaskType } from "@bitwarden/vault";
|
import { SecurityTaskStatus, SecurityTaskType } from "@bitwarden/common/vault/tasks";
|
||||||
|
|
||||||
import { CreateTasksRequest } from "./abstractions/admin-task.abstraction";
|
import { CreateTasksRequest } from "./abstractions/admin-task.abstraction";
|
||||||
import { DefaultAdminTaskService } from "./default-admin-task.service";
|
import { DefaultAdminTaskService } from "./default-admin-task.service";
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import {
|
|||||||
SecurityTaskData,
|
SecurityTaskData,
|
||||||
SecurityTaskResponse,
|
SecurityTaskResponse,
|
||||||
SecurityTaskStatus,
|
SecurityTaskStatus,
|
||||||
} from "@bitwarden/vault";
|
} from "@bitwarden/common/vault/tasks";
|
||||||
|
|
||||||
import { AdminTaskService, CreateTasksRequest } from "./abstractions/admin-task.abstraction";
|
import { AdminTaskService, CreateTasksRequest } from "./abstractions/admin-task.abstraction";
|
||||||
|
|
||||||
|
|||||||
@@ -4,48 +4,48 @@ import { ErrorHandler, LOCALE_ID, NgModule } from "@angular/core";
|
|||||||
import { Subject } from "rxjs";
|
import { Subject } from "rxjs";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
OrganizationUserApiService,
|
|
||||||
DefaultOrganizationUserApiService,
|
|
||||||
CollectionService,
|
CollectionService,
|
||||||
DefaultCollectionService,
|
DefaultCollectionService,
|
||||||
|
DefaultOrganizationUserApiService,
|
||||||
|
OrganizationUserApiService,
|
||||||
} from "@bitwarden/admin-console/common";
|
} from "@bitwarden/admin-console/common";
|
||||||
import {
|
import {
|
||||||
SetPasswordJitService,
|
|
||||||
DefaultSetPasswordJitService,
|
|
||||||
RegistrationFinishService as RegistrationFinishServiceAbstraction,
|
|
||||||
DefaultRegistrationFinishService,
|
|
||||||
AnonLayoutWrapperDataService,
|
AnonLayoutWrapperDataService,
|
||||||
DefaultAnonLayoutWrapperDataService,
|
DefaultAnonLayoutWrapperDataService,
|
||||||
LoginComponentService,
|
DefaultLoginApprovalComponentService,
|
||||||
DefaultLoginComponentService,
|
DefaultLoginComponentService,
|
||||||
LoginDecryptionOptionsService,
|
|
||||||
DefaultLoginDecryptionOptionsService,
|
DefaultLoginDecryptionOptionsService,
|
||||||
TwoFactorAuthComponentService,
|
DefaultRegistrationFinishService,
|
||||||
|
DefaultSetPasswordJitService,
|
||||||
DefaultTwoFactorAuthComponentService,
|
DefaultTwoFactorAuthComponentService,
|
||||||
DefaultTwoFactorAuthEmailComponentService,
|
DefaultTwoFactorAuthEmailComponentService,
|
||||||
TwoFactorAuthEmailComponentService,
|
|
||||||
DefaultTwoFactorAuthWebAuthnComponentService,
|
DefaultTwoFactorAuthWebAuthnComponentService,
|
||||||
|
LoginComponentService,
|
||||||
|
LoginDecryptionOptionsService,
|
||||||
|
RegistrationFinishService as RegistrationFinishServiceAbstraction,
|
||||||
|
SetPasswordJitService,
|
||||||
|
TwoFactorAuthComponentService,
|
||||||
|
TwoFactorAuthEmailComponentService,
|
||||||
TwoFactorAuthWebAuthnComponentService,
|
TwoFactorAuthWebAuthnComponentService,
|
||||||
DefaultLoginApprovalComponentService,
|
|
||||||
} from "@bitwarden/auth/angular";
|
} from "@bitwarden/auth/angular";
|
||||||
import {
|
import {
|
||||||
AuthRequestServiceAbstraction,
|
|
||||||
AuthRequestService,
|
|
||||||
PinServiceAbstraction,
|
|
||||||
PinService,
|
|
||||||
LoginStrategyServiceAbstraction,
|
|
||||||
LoginStrategyService,
|
|
||||||
LoginEmailServiceAbstraction,
|
|
||||||
LoginEmailService,
|
|
||||||
InternalUserDecryptionOptionsServiceAbstraction,
|
|
||||||
UserDecryptionOptionsService,
|
|
||||||
UserDecryptionOptionsServiceAbstraction,
|
|
||||||
LogoutReason,
|
|
||||||
AuthRequestApiService,
|
AuthRequestApiService,
|
||||||
|
AuthRequestService,
|
||||||
|
AuthRequestServiceAbstraction,
|
||||||
DefaultAuthRequestApiService,
|
DefaultAuthRequestApiService,
|
||||||
DefaultLoginSuccessHandlerService,
|
DefaultLoginSuccessHandlerService,
|
||||||
LoginSuccessHandlerService,
|
InternalUserDecryptionOptionsServiceAbstraction,
|
||||||
LoginApprovalComponentServiceAbstraction,
|
LoginApprovalComponentServiceAbstraction,
|
||||||
|
LoginEmailService,
|
||||||
|
LoginEmailServiceAbstraction,
|
||||||
|
LoginStrategyService,
|
||||||
|
LoginStrategyServiceAbstraction,
|
||||||
|
LoginSuccessHandlerService,
|
||||||
|
LogoutReason,
|
||||||
|
PinService,
|
||||||
|
PinServiceAbstraction,
|
||||||
|
UserDecryptionOptionsService,
|
||||||
|
UserDecryptionOptionsServiceAbstraction,
|
||||||
} from "@bitwarden/auth/common";
|
} from "@bitwarden/auth/common";
|
||||||
import { ApiService as ApiServiceAbstraction } from "@bitwarden/common/abstractions/api.service";
|
import { ApiService as ApiServiceAbstraction } from "@bitwarden/common/abstractions/api.service";
|
||||||
import { AuditService as AuditServiceAbstraction } from "@bitwarden/common/abstractions/audit.service";
|
import { AuditService as AuditServiceAbstraction } from "@bitwarden/common/abstractions/audit.service";
|
||||||
@@ -118,16 +118,16 @@ import { WebAuthnLoginApiService } from "@bitwarden/common/auth/services/webauth
|
|||||||
import { WebAuthnLoginPrfKeyService } from "@bitwarden/common/auth/services/webauthn-login/webauthn-login-prf-key.service";
|
import { WebAuthnLoginPrfKeyService } from "@bitwarden/common/auth/services/webauthn-login/webauthn-login-prf-key.service";
|
||||||
import { WebAuthnLoginService } from "@bitwarden/common/auth/services/webauthn-login/webauthn-login.service";
|
import { WebAuthnLoginService } from "@bitwarden/common/auth/services/webauthn-login/webauthn-login.service";
|
||||||
import {
|
import {
|
||||||
AutofillSettingsServiceAbstraction,
|
|
||||||
AutofillSettingsService,
|
AutofillSettingsService,
|
||||||
|
AutofillSettingsServiceAbstraction,
|
||||||
} from "@bitwarden/common/autofill/services/autofill-settings.service";
|
} from "@bitwarden/common/autofill/services/autofill-settings.service";
|
||||||
import {
|
import {
|
||||||
BadgeSettingsServiceAbstraction,
|
|
||||||
BadgeSettingsService,
|
BadgeSettingsService,
|
||||||
|
BadgeSettingsServiceAbstraction,
|
||||||
} from "@bitwarden/common/autofill/services/badge-settings.service";
|
} from "@bitwarden/common/autofill/services/badge-settings.service";
|
||||||
import {
|
import {
|
||||||
DomainSettingsService,
|
|
||||||
DefaultDomainSettingsService,
|
DefaultDomainSettingsService,
|
||||||
|
DomainSettingsService,
|
||||||
} from "@bitwarden/common/autofill/services/domain-settings.service";
|
} from "@bitwarden/common/autofill/services/domain-settings.service";
|
||||||
import {
|
import {
|
||||||
BillingApiServiceAbstraction,
|
BillingApiServiceAbstraction,
|
||||||
@@ -200,8 +200,8 @@ import {
|
|||||||
WebPushNotificationsApiService,
|
WebPushNotificationsApiService,
|
||||||
} from "@bitwarden/common/platform/notifications/internal";
|
} from "@bitwarden/common/platform/notifications/internal";
|
||||||
import {
|
import {
|
||||||
TaskSchedulerService,
|
|
||||||
DefaultTaskSchedulerService,
|
DefaultTaskSchedulerService,
|
||||||
|
TaskSchedulerService,
|
||||||
} from "@bitwarden/common/platform/scheduling";
|
} from "@bitwarden/common/platform/scheduling";
|
||||||
import { AppIdService } from "@bitwarden/common/platform/services/app-id.service";
|
import { AppIdService } from "@bitwarden/common/platform/services/app-id.service";
|
||||||
import { ConfigApiService } from "@bitwarden/common/platform/services/config/config-api.service";
|
import { ConfigApiService } from "@bitwarden/common/platform/services/config/config-api.service";
|
||||||
@@ -222,10 +222,10 @@ import { ValidationService } from "@bitwarden/common/platform/services/validatio
|
|||||||
import { WebCryptoFunctionService } from "@bitwarden/common/platform/services/web-crypto-function.service";
|
import { WebCryptoFunctionService } from "@bitwarden/common/platform/services/web-crypto-function.service";
|
||||||
import {
|
import {
|
||||||
ActiveUserStateProvider,
|
ActiveUserStateProvider,
|
||||||
|
DerivedStateProvider,
|
||||||
GlobalStateProvider,
|
GlobalStateProvider,
|
||||||
SingleUserStateProvider,
|
SingleUserStateProvider,
|
||||||
StateProvider,
|
StateProvider,
|
||||||
DerivedStateProvider,
|
|
||||||
} from "@bitwarden/common/platform/state";
|
} from "@bitwarden/common/platform/state";
|
||||||
/* eslint-disable import/no-restricted-paths -- We need the implementations to inject, but generally these should not be accessed */
|
/* eslint-disable import/no-restricted-paths -- We need the implementations to inject, but generally these should not be accessed */
|
||||||
import { DefaultActiveUserStateProvider } from "@bitwarden/common/platform/state/implementations/default-active-user-state.provider";
|
import { DefaultActiveUserStateProvider } from "@bitwarden/common/platform/state/implementations/default-active-user-state.provider";
|
||||||
@@ -280,6 +280,7 @@ import { FolderApiService } from "@bitwarden/common/vault/services/folder/folder
|
|||||||
import { FolderService } from "@bitwarden/common/vault/services/folder/folder.service";
|
import { FolderService } from "@bitwarden/common/vault/services/folder/folder.service";
|
||||||
import { TotpService } from "@bitwarden/common/vault/services/totp.service";
|
import { TotpService } from "@bitwarden/common/vault/services/totp.service";
|
||||||
import { VaultSettingsService } from "@bitwarden/common/vault/services/vault-settings/vault-settings.service";
|
import { VaultSettingsService } from "@bitwarden/common/vault/services/vault-settings/vault-settings.service";
|
||||||
|
import { DefaultTaskService, TaskService } from "@bitwarden/common/vault/tasks";
|
||||||
import { ToastService } from "@bitwarden/components";
|
import { ToastService } from "@bitwarden/components";
|
||||||
import {
|
import {
|
||||||
GeneratorHistoryService,
|
GeneratorHistoryService,
|
||||||
@@ -292,34 +293,32 @@ import {
|
|||||||
UsernameGenerationServiceAbstraction,
|
UsernameGenerationServiceAbstraction,
|
||||||
} from "@bitwarden/generator-legacy";
|
} from "@bitwarden/generator-legacy";
|
||||||
import {
|
import {
|
||||||
KeyService,
|
BiometricsService,
|
||||||
DefaultKeyService,
|
|
||||||
BiometricStateService,
|
BiometricStateService,
|
||||||
DefaultBiometricStateService,
|
DefaultBiometricStateService,
|
||||||
BiometricsService,
|
|
||||||
DefaultKdfConfigService,
|
DefaultKdfConfigService,
|
||||||
KdfConfigService,
|
DefaultKeyService,
|
||||||
UserAsymmetricKeysRegenerationService,
|
|
||||||
DefaultUserAsymmetricKeysRegenerationService,
|
|
||||||
UserAsymmetricKeysRegenerationApiService,
|
|
||||||
DefaultUserAsymmetricKeysRegenerationApiService,
|
DefaultUserAsymmetricKeysRegenerationApiService,
|
||||||
|
DefaultUserAsymmetricKeysRegenerationService,
|
||||||
|
KdfConfigService,
|
||||||
|
KeyService,
|
||||||
|
UserAsymmetricKeysRegenerationApiService,
|
||||||
|
UserAsymmetricKeysRegenerationService,
|
||||||
} from "@bitwarden/key-management";
|
} from "@bitwarden/key-management";
|
||||||
import { SafeInjectionToken } from "@bitwarden/ui-common";
|
import { SafeInjectionToken } from "@bitwarden/ui-common";
|
||||||
import {
|
import {
|
||||||
DefaultTaskService,
|
|
||||||
DefaultEndUserNotificationService,
|
DefaultEndUserNotificationService,
|
||||||
EndUserNotificationService,
|
EndUserNotificationService,
|
||||||
NewDeviceVerificationNoticeService,
|
NewDeviceVerificationNoticeService,
|
||||||
PasswordRepromptService,
|
PasswordRepromptService,
|
||||||
TaskService,
|
|
||||||
} from "@bitwarden/vault";
|
} from "@bitwarden/vault";
|
||||||
import {
|
import {
|
||||||
VaultExportService,
|
|
||||||
VaultExportServiceAbstraction,
|
|
||||||
OrganizationVaultExportService,
|
|
||||||
OrganizationVaultExportServiceAbstraction,
|
|
||||||
IndividualVaultExportService,
|
IndividualVaultExportService,
|
||||||
IndividualVaultExportServiceAbstraction,
|
IndividualVaultExportServiceAbstraction,
|
||||||
|
OrganizationVaultExportService,
|
||||||
|
OrganizationVaultExportServiceAbstraction,
|
||||||
|
VaultExportService,
|
||||||
|
VaultExportServiceAbstraction,
|
||||||
} from "@bitwarden/vault-export-core";
|
} from "@bitwarden/vault-export-core";
|
||||||
|
|
||||||
import { DeviceTrustToastService as DeviceTrustToastServiceAbstraction } from "../auth/services/device-trust-toast.service.abstraction";
|
import { DeviceTrustToastService as DeviceTrustToastServiceAbstraction } from "../auth/services/device-trust-toast.service.abstraction";
|
||||||
@@ -334,24 +333,24 @@ import { AbstractThemingService } from "../platform/services/theming/theming.ser
|
|||||||
import { safeProvider, SafeProvider } from "../platform/utils/safe-provider";
|
import { safeProvider, SafeProvider } from "../platform/utils/safe-provider";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
CLIENT_TYPE,
|
||||||
|
DEFAULT_VAULT_TIMEOUT,
|
||||||
|
ENV_ADDITIONAL_REGIONS,
|
||||||
|
INTRAPROCESS_MESSAGING_SUBJECT,
|
||||||
LOCALES_DIRECTORY,
|
LOCALES_DIRECTORY,
|
||||||
LOCKED_CALLBACK,
|
LOCKED_CALLBACK,
|
||||||
LOGOUT_CALLBACK,
|
|
||||||
LOG_MAC_FAILURES,
|
LOG_MAC_FAILURES,
|
||||||
|
LOGOUT_CALLBACK,
|
||||||
MEMORY_STORAGE,
|
MEMORY_STORAGE,
|
||||||
OBSERVABLE_DISK_STORAGE,
|
OBSERVABLE_DISK_STORAGE,
|
||||||
OBSERVABLE_MEMORY_STORAGE,
|
OBSERVABLE_MEMORY_STORAGE,
|
||||||
|
REFRESH_ACCESS_TOKEN_ERROR_CALLBACK,
|
||||||
SECURE_STORAGE,
|
SECURE_STORAGE,
|
||||||
STATE_FACTORY,
|
STATE_FACTORY,
|
||||||
SUPPORTS_SECURE_STORAGE,
|
SUPPORTS_SECURE_STORAGE,
|
||||||
SYSTEM_LANGUAGE,
|
SYSTEM_LANGUAGE,
|
||||||
SYSTEM_THEME_OBSERVABLE,
|
SYSTEM_THEME_OBSERVABLE,
|
||||||
WINDOW,
|
WINDOW,
|
||||||
DEFAULT_VAULT_TIMEOUT,
|
|
||||||
INTRAPROCESS_MESSAGING_SUBJECT,
|
|
||||||
CLIENT_TYPE,
|
|
||||||
REFRESH_ACCESS_TOKEN_ERROR_CALLBACK,
|
|
||||||
ENV_ADDITIONAL_REGIONS,
|
|
||||||
} from "./injection-tokens";
|
} from "./injection-tokens";
|
||||||
import { ModalService } from "./modal.service";
|
import { ModalService } from "./modal.service";
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import { Observable } from "rxjs";
|
import { Observable } from "rxjs";
|
||||||
|
|
||||||
import { SecurityTaskId, UserId } from "@bitwarden/common/types/guid";
|
import { SecurityTaskId, UserId } from "@bitwarden/common/types/guid";
|
||||||
import { SecurityTask } from "@bitwarden/vault";
|
|
||||||
|
import { SecurityTask } from "../models";
|
||||||
|
|
||||||
export abstract class TaskService {
|
export abstract class TaskService {
|
||||||
/**
|
/**
|
||||||
@@ -1,19 +1,18 @@
|
|||||||
import { TestBed } from "@angular/core/testing";
|
|
||||||
import { BehaviorSubject, firstValueFrom } from "rxjs";
|
import { BehaviorSubject, firstValueFrom } from "rxjs";
|
||||||
|
|
||||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||||
import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
|
import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
|
||||||
import { Organization } from "@bitwarden/common/admin-console/models/domain/organization";
|
import { Organization } from "@bitwarden/common/admin-console/models/domain/organization";
|
||||||
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
||||||
import { StateProvider } from "@bitwarden/common/platform/state";
|
|
||||||
import { SecurityTaskId, UserId } from "@bitwarden/common/types/guid";
|
import { SecurityTaskId, UserId } from "@bitwarden/common/types/guid";
|
||||||
import { DefaultTaskService, SecurityTaskStatus } from "@bitwarden/vault";
|
|
||||||
|
|
||||||
import { FakeStateProvider, mockAccountServiceWith } from "../../../../common/spec";
|
import { FakeStateProvider, mockAccountServiceWith } from "../../../../spec";
|
||||||
import { SecurityTaskData } from "../models/security-task.data";
|
import { SecurityTaskStatus } from "../enums";
|
||||||
import { SecurityTaskResponse } from "../models/security-task.response";
|
import { SecurityTaskData, SecurityTaskResponse } from "../models";
|
||||||
import { SECURITY_TASKS } from "../state/security-task.state";
|
import { SECURITY_TASKS } from "../state/security-task.state";
|
||||||
|
|
||||||
|
import { DefaultTaskService } from "./default-task.service";
|
||||||
|
|
||||||
describe("Default task service", () => {
|
describe("Default task service", () => {
|
||||||
let fakeStateProvider: FakeStateProvider;
|
let fakeStateProvider: FakeStateProvider;
|
||||||
|
|
||||||
@@ -21,7 +20,7 @@ describe("Default task service", () => {
|
|||||||
const mockGetAllOrgs$ = jest.fn();
|
const mockGetAllOrgs$ = jest.fn();
|
||||||
const mockGetFeatureFlag$ = jest.fn();
|
const mockGetFeatureFlag$ = jest.fn();
|
||||||
|
|
||||||
let testBed: TestBed;
|
let service: DefaultTaskService;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
mockApiSend.mockClear();
|
mockApiSend.mockClear();
|
||||||
@@ -29,34 +28,12 @@ describe("Default task service", () => {
|
|||||||
mockGetFeatureFlag$.mockClear();
|
mockGetFeatureFlag$.mockClear();
|
||||||
|
|
||||||
fakeStateProvider = new FakeStateProvider(mockAccountServiceWith("user-id" as UserId));
|
fakeStateProvider = new FakeStateProvider(mockAccountServiceWith("user-id" as UserId));
|
||||||
testBed = TestBed.configureTestingModule({
|
service = new DefaultTaskService(
|
||||||
imports: [],
|
fakeStateProvider,
|
||||||
providers: [
|
{ send: mockApiSend } as unknown as ApiService,
|
||||||
DefaultTaskService,
|
{ organizations$: mockGetAllOrgs$ } as unknown as OrganizationService,
|
||||||
{
|
{ getFeatureFlag$: mockGetFeatureFlag$ } as unknown as ConfigService,
|
||||||
provide: ConfigService,
|
);
|
||||||
useValue: {
|
|
||||||
getFeatureFlag$: mockGetFeatureFlag$,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
provide: StateProvider,
|
|
||||||
useValue: fakeStateProvider,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
provide: ApiService,
|
|
||||||
useValue: {
|
|
||||||
send: mockApiSend,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
provide: OrganizationService,
|
|
||||||
useValue: {
|
|
||||||
organizations$: mockGetAllOrgs$,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("tasksEnabled$", () => {
|
describe("tasksEnabled$", () => {
|
||||||
@@ -73,7 +50,7 @@ describe("Default task service", () => {
|
|||||||
] as Organization[]),
|
] as Organization[]),
|
||||||
);
|
);
|
||||||
|
|
||||||
const { tasksEnabled$ } = testBed.inject(DefaultTaskService);
|
const { tasksEnabled$ } = service;
|
||||||
|
|
||||||
const result = await firstValueFrom(tasksEnabled$("user-id" as UserId));
|
const result = await firstValueFrom(tasksEnabled$("user-id" as UserId));
|
||||||
|
|
||||||
@@ -93,7 +70,7 @@ describe("Default task service", () => {
|
|||||||
] as Organization[]),
|
] as Organization[]),
|
||||||
);
|
);
|
||||||
|
|
||||||
const { tasksEnabled$ } = testBed.inject(DefaultTaskService);
|
const { tasksEnabled$ } = service;
|
||||||
|
|
||||||
const result = await firstValueFrom(tasksEnabled$("user-id" as UserId));
|
const result = await firstValueFrom(tasksEnabled$("user-id" as UserId));
|
||||||
|
|
||||||
@@ -110,7 +87,7 @@ describe("Default task service", () => {
|
|||||||
] as Organization[]),
|
] as Organization[]),
|
||||||
);
|
);
|
||||||
|
|
||||||
const { tasksEnabled$ } = testBed.inject(DefaultTaskService);
|
const { tasksEnabled$ } = service;
|
||||||
|
|
||||||
const result = await firstValueFrom(tasksEnabled$("user-id" as UserId));
|
const result = await firstValueFrom(tasksEnabled$("user-id" as UserId));
|
||||||
|
|
||||||
@@ -130,7 +107,7 @@ describe("Default task service", () => {
|
|||||||
|
|
||||||
fakeStateProvider.singleUser.mockFor("user-id" as UserId, SECURITY_TASKS, null as any);
|
fakeStateProvider.singleUser.mockFor("user-id" as UserId, SECURITY_TASKS, null as any);
|
||||||
|
|
||||||
const { tasks$ } = testBed.inject(DefaultTaskService);
|
const { tasks$ } = service;
|
||||||
|
|
||||||
const result = await firstValueFrom(tasks$("user-id" as UserId));
|
const result = await firstValueFrom(tasks$("user-id" as UserId));
|
||||||
|
|
||||||
@@ -145,7 +122,7 @@ describe("Default task service", () => {
|
|||||||
} as SecurityTaskData,
|
} as SecurityTaskData,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const { tasks$ } = testBed.inject(DefaultTaskService);
|
const { tasks$ } = service;
|
||||||
|
|
||||||
const result = await firstValueFrom(tasks$("user-id" as UserId));
|
const result = await firstValueFrom(tasks$("user-id" as UserId));
|
||||||
|
|
||||||
@@ -154,7 +131,7 @@ describe("Default task service", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should share the same observable for the same user", async () => {
|
it("should share the same observable for the same user", async () => {
|
||||||
const { tasks$ } = testBed.inject(DefaultTaskService);
|
const { tasks$ } = service;
|
||||||
|
|
||||||
const first = tasks$("user-id" as UserId);
|
const first = tasks$("user-id" as UserId);
|
||||||
const second = tasks$("user-id" as UserId);
|
const second = tasks$("user-id" as UserId);
|
||||||
@@ -176,7 +153,7 @@ describe("Default task service", () => {
|
|||||||
},
|
},
|
||||||
] as SecurityTaskData[]);
|
] as SecurityTaskData[]);
|
||||||
|
|
||||||
const { pendingTasks$ } = testBed.inject(DefaultTaskService);
|
const { pendingTasks$ } = service;
|
||||||
|
|
||||||
const result = await firstValueFrom(pendingTasks$("user-id" as UserId));
|
const result = await firstValueFrom(pendingTasks$("user-id" as UserId));
|
||||||
|
|
||||||
@@ -195,8 +172,6 @@ describe("Default task service", () => {
|
|||||||
] as SecurityTaskResponse[],
|
] as SecurityTaskResponse[],
|
||||||
});
|
});
|
||||||
|
|
||||||
const service = testBed.inject(DefaultTaskService);
|
|
||||||
|
|
||||||
await service.refreshTasks("user-id" as UserId);
|
await service.refreshTasks("user-id" as UserId);
|
||||||
|
|
||||||
expect(mockApiSend).toHaveBeenCalledWith("GET", "/tasks", null, true, true);
|
expect(mockApiSend).toHaveBeenCalledWith("GET", "/tasks", null, true, true);
|
||||||
@@ -217,8 +192,6 @@ describe("Default task service", () => {
|
|||||||
null as any,
|
null as any,
|
||||||
);
|
);
|
||||||
|
|
||||||
const service = testBed.inject(DefaultTaskService);
|
|
||||||
|
|
||||||
await service.refreshTasks("user-id" as UserId);
|
await service.refreshTasks("user-id" as UserId);
|
||||||
|
|
||||||
expect(mock.nextMock).toHaveBeenCalledWith([
|
expect(mock.nextMock).toHaveBeenCalledWith([
|
||||||
@@ -237,8 +210,6 @@ describe("Default task service", () => {
|
|||||||
} as SecurityTaskData,
|
} as SecurityTaskData,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const service = testBed.inject(DefaultTaskService);
|
|
||||||
|
|
||||||
await service.clear("user-id" as UserId);
|
await service.clear("user-id" as UserId);
|
||||||
|
|
||||||
expect(mock.nextMock).toHaveBeenCalledWith([]);
|
expect(mock.nextMock).toHaveBeenCalledWith([]);
|
||||||
@@ -247,8 +218,6 @@ describe("Default task service", () => {
|
|||||||
|
|
||||||
describe("markAsComplete()", () => {
|
describe("markAsComplete()", () => {
|
||||||
it("should send an API request to mark the task as complete", async () => {
|
it("should send an API request to mark the task as complete", async () => {
|
||||||
const service = testBed.inject(DefaultTaskService);
|
|
||||||
|
|
||||||
await service.markAsComplete("task-id" as SecurityTaskId, "user-id" as UserId);
|
await service.markAsComplete("task-id" as SecurityTaskId, "user-id" as UserId);
|
||||||
|
|
||||||
expect(mockApiSend).toHaveBeenCalledWith(
|
expect(mockApiSend).toHaveBeenCalledWith(
|
||||||
@@ -278,8 +247,6 @@ describe("Default task service", () => {
|
|||||||
} as SecurityTaskData,
|
} as SecurityTaskData,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const service = testBed.inject(DefaultTaskService);
|
|
||||||
|
|
||||||
await service.markAsComplete("task-id" as SecurityTaskId, "user-id" as UserId);
|
await service.markAsComplete("task-id" as SecurityTaskId, "user-id" as UserId);
|
||||||
|
|
||||||
expect(mockApiSend).toHaveBeenCalledWith("GET", "/tasks", null, true, true);
|
expect(mockApiSend).toHaveBeenCalledWith("GET", "/tasks", null, true, true);
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
import { Injectable } from "@angular/core";
|
|
||||||
import { combineLatest, map, switchMap } from "rxjs";
|
import { combineLatest, map, switchMap } from "rxjs";
|
||||||
|
|
||||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||||
@@ -8,14 +7,13 @@ import { ListResponse } from "@bitwarden/common/models/response/list.response";
|
|||||||
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
||||||
import { StateProvider } from "@bitwarden/common/platform/state";
|
import { StateProvider } from "@bitwarden/common/platform/state";
|
||||||
import { SecurityTaskId, UserId } from "@bitwarden/common/types/guid";
|
import { SecurityTaskId, UserId } from "@bitwarden/common/types/guid";
|
||||||
import { SecurityTask, SecurityTaskStatus, TaskService } from "@bitwarden/vault";
|
|
||||||
|
|
||||||
import { filterOutNullish, perUserCache$ } from "../../utils/observable-utilities";
|
import { filterOutNullish, perUserCache$ } from "../../utils/observable-utilities";
|
||||||
import { SecurityTaskData } from "../models/security-task.data";
|
import { TaskService } from "../abstractions/task.service";
|
||||||
import { SecurityTaskResponse } from "../models/security-task.response";
|
import { SecurityTaskStatus } from "../enums";
|
||||||
|
import { SecurityTask, SecurityTaskData, SecurityTaskResponse } from "../models";
|
||||||
import { SECURITY_TASKS } from "../state/security-task.state";
|
import { SECURITY_TASKS } from "../state/security-task.state";
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class DefaultTaskService implements TaskService {
|
export class DefaultTaskService implements TaskService {
|
||||||
constructor(
|
constructor(
|
||||||
private stateProvider: StateProvider,
|
private stateProvider: StateProvider,
|
||||||
@@ -20,10 +20,10 @@ import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.servi
|
|||||||
import { FolderService } from "@bitwarden/common/vault/abstractions/folder/folder.service.abstraction";
|
import { FolderService } from "@bitwarden/common/vault/abstractions/folder/folder.service.abstraction";
|
||||||
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
|
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
|
||||||
import { FolderView } from "@bitwarden/common/vault/models/view/folder.view";
|
import { FolderView } from "@bitwarden/common/vault/models/view/folder.view";
|
||||||
|
import { SecurityTaskType, TaskService } from "@bitwarden/common/vault/tasks";
|
||||||
import { AnchorLinkDirective, CalloutModule, SearchModule } from "@bitwarden/components";
|
import { AnchorLinkDirective, CalloutModule, SearchModule } from "@bitwarden/components";
|
||||||
|
|
||||||
import { ChangeLoginPasswordService } from "../abstractions/change-login-password.service";
|
import { ChangeLoginPasswordService } from "../abstractions/change-login-password.service";
|
||||||
import { TaskService, SecurityTaskType } from "../tasks";
|
|
||||||
|
|
||||||
import { AdditionalOptionsComponent } from "./additional-options/additional-options.component";
|
import { AdditionalOptionsComponent } from "./additional-options/additional-options.component";
|
||||||
import { AttachmentsV2ViewComponent } from "./attachments/attachments-v2-view.component";
|
import { AttachmentsV2ViewComponent } from "./attachments/attachments-v2-view.component";
|
||||||
|
|||||||
@@ -6,8 +6,6 @@ export { OrgIconDirective } from "./components/org-icon.directive";
|
|||||||
export { CanDeleteCipherDirective } from "./components/can-delete-cipher.directive";
|
export { CanDeleteCipherDirective } from "./components/can-delete-cipher.directive";
|
||||||
export { DarkImageSourceDirective } from "./components/dark-image-source.directive";
|
export { DarkImageSourceDirective } from "./components/dark-image-source.directive";
|
||||||
|
|
||||||
export * from "./utils/observable-utilities";
|
|
||||||
|
|
||||||
export * from "./cipher-view";
|
export * from "./cipher-view";
|
||||||
export * from "./cipher-form";
|
export * from "./cipher-form";
|
||||||
export {
|
export {
|
||||||
@@ -25,7 +23,6 @@ export * from "./components/add-edit-folder-dialog/add-edit-folder-dialog.compon
|
|||||||
export * from "./components/carousel";
|
export * from "./components/carousel";
|
||||||
|
|
||||||
export * as VaultIcons from "./icons";
|
export * as VaultIcons from "./icons";
|
||||||
export * from "./tasks";
|
|
||||||
export * from "./notifications";
|
export * from "./notifications";
|
||||||
|
|
||||||
export { DefaultSshImportPromptService } from "./services/default-ssh-import-prompt.service";
|
export { DefaultSshImportPromptService } from "./services/default-ssh-import-prompt.service";
|
||||||
|
|||||||
@@ -7,8 +7,11 @@ import { ListResponse } from "@bitwarden/common/models/response/list.response";
|
|||||||
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";
|
||||||
import { UserId } from "@bitwarden/common/types/guid";
|
import { UserId } from "@bitwarden/common/types/guid";
|
||||||
|
import {
|
||||||
|
filterOutNullish,
|
||||||
|
perUserCache$,
|
||||||
|
} from "@bitwarden/common/vault/utils/observable-utilities";
|
||||||
|
|
||||||
import { filterOutNullish, perUserCache$ } from "../../utils/observable-utilities";
|
|
||||||
import { EndUserNotificationService } from "../abstractions/end-user-notification.service";
|
import { EndUserNotificationService } from "../abstractions/end-user-notification.service";
|
||||||
import { NotificationView, NotificationViewData, NotificationViewResponse } from "../models";
|
import { NotificationView, NotificationViewData, NotificationViewResponse } from "../models";
|
||||||
import { NOTIFICATIONS } from "../state/end-user-notification.state";
|
import { NOTIFICATIONS } from "../state/end-user-notification.state";
|
||||||
|
|||||||
Reference in New Issue
Block a user