2022-06-14 17:10:53 +02:00
|
|
|
import { DOCUMENT } from "@angular/common";
|
2022-06-06 19:08:06 +02:00
|
|
|
import { Component, Inject, NgZone, OnDestroy, OnInit, SecurityContext } from "@angular/core";
|
2021-12-17 15:57:11 +01:00
|
|
|
import { DomSanitizer } from "@angular/platform-browser";
|
|
|
|
import { NavigationEnd, Router } from "@angular/router";
|
|
|
|
import * as jq from "jquery";
|
|
|
|
import { IndividualConfig, ToastrService } from "ngx-toastr";
|
2022-07-12 15:02:19 +02:00
|
|
|
import { Subject, takeUntil } from "rxjs";
|
2021-12-17 15:57:11 +01:00
|
|
|
import Swal from "sweetalert2";
|
2018-06-05 05:10:41 +02:00
|
|
|
|
2023-05-02 18:46:03 +02:00
|
|
|
import { DialogServiceAbstraction, SimpleDialogType } from "@bitwarden/angular/services/dialog";
|
2022-06-14 17:10:53 +02:00
|
|
|
import { BroadcasterService } from "@bitwarden/common/abstractions/broadcaster.service";
|
2023-04-26 16:30:39 +02:00
|
|
|
import { ConfigServiceAbstraction } from "@bitwarden/common/abstractions/config/config.service.abstraction";
|
2022-06-14 17:10:53 +02:00
|
|
|
import { CryptoService } from "@bitwarden/common/abstractions/crypto.service";
|
2022-12-06 14:47:42 +01:00
|
|
|
import { EventUploadService } from "@bitwarden/common/abstractions/event/event-upload.service";
|
2022-06-14 17:10:53 +02:00
|
|
|
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
|
|
|
import { NotificationsService } from "@bitwarden/common/abstractions/notifications.service";
|
|
|
|
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
|
|
|
import { SearchService } from "@bitwarden/common/abstractions/search.service";
|
|
|
|
import { SettingsService } from "@bitwarden/common/abstractions/settings.service";
|
|
|
|
import { StateService } from "@bitwarden/common/abstractions/state.service";
|
2022-08-30 16:11:19 +02:00
|
|
|
import { VaultTimeoutService } from "@bitwarden/common/abstractions/vaultTimeout/vaultTimeout.service";
|
[AC-1011] Admin Console / Billing code ownership (#4973)
* refactor: move SCIM component to admin-console, refs EC-1011
* refactor: move scimProviderType to admin-console, refs EC-1011
* refactor: move scim-config.api to admin-console, refs EC-1011
* refactor: create models folder and nest existing api contents, refs EC-1011
* refactor: move scim-config to admin-console models, refs EC-1011
* refactor: move billing.component to billing, refs EC-1011
* refactor: remove nested app folder from new billing structure, refs EC-1011
* refactor: move organizations/billing to billing, refs EC-1011
* refactor: move add-credit and adjust-payment to billing/settings, refs EC-1011
* refactor: billing history/sync to billing, refs EC-1011
* refactor: move org plans, payment/method to billing/settings, refs EC-1011
* fix: update legacy file paths for payment-method and tax-info, refs EC-1011
* fix: update imports for scim component, refs EC-1011
* refactor: move subscription and tax-info into billing, refs EC-1011
* refactor: move user-subscription to billing, refs EC-1011
* refactor: move images/cards to billing and update base path, refs EC-1011
* refactor: move payment-method, plan subscription, and plan to billing, refs EC-1011
* refactor: move transaction-type to billing, refs EC-1011
* refactor: move billing-sync-config to billing, refs EC-1011
* refactor: move billing-sync and bit-pay-invoice request to billing, refs EC-1011
* refactor: move org subscription and tax info update requests to billing, refs EC-1011
* fix: broken paths to billing, refs EC-1011
* refactor: move payment request to billing, refs EC-1011
* fix: update remaining imports for payment-request, refs EC-1011
* refactor: move tax-info-update to billing, refs EC-1011
* refactor: move billing-payment, billing-history, and billing responses to billing, refs EC-1011
* refactor: move organization-subscription-responset to billing, refs EC-1011
* refactor: move payment and plan responses to billing, refs EC-1011
* refactor: move subscription response to billing ,refs EC-1011
* refactor: move tax info and rate responses to billing, refs EC-1011
* fix: update remaining path to base response for tax-rate response, refs EC-1011
* refactor: (browser) move organization-service to admin-console, refs EC-1011
* refactor: (browser) move organizaiton-service to admin-console, refs EC-1011
* refactor: (cli) move share command to admin-console, refs EC-1011
* refactor: move organization-collect request model to admin-console, refs EC-1011
* refactor: (web) move organization, collection/user responses to admin-console, refs EC-1011
* refactor: (cli) move selection-read-only to admin-console, refs EC-1011
* refactor: (desktop) move organization-filter to admin-console, refs EC-1011
* refactor: (web) move organization-switcher to admin-console, refs EC-1011
* refactor: (web) move access-selector to admin-console, refs EC-1011
* refactor: (web) move create folder to admin-console, refs EC-1011
* refactor: (web) move org guards folder to admin-console, refs EC-1011
* refactor: (web) move org layout to admin-console, refs EC-1011
* refactor: move manage collections to admin console, refs EC-1011
* refactor: (web) move collection-dialog to admin-console, refs EC-1011
* refactor: (web) move entity users/events and events component to admin-console, refs EC-1011
* refactor: (web) move groups/group-add-edit to admin-console, refs EC-1011
* refactor: (web) move manage, org-manage module, and user-confirm to admin-console, refs EC-1011
* refactor: (web) move people to admin-console, refs EC-1011
* refactor: (web) move reset-password to admin-console, refs EC-1011
* refactor: (web) move organization-routing and module to admin-console, refs EC-1011
* refactor: move admin-console and billing within app scope, refs EC-1011
* fix: update leftover merge conflicts, refs EC-1011
* refactor: (web) member-dialog to admin-console, refs EC-1011
* refactor: (web) move policies to admin-console, refs EC-1011
* refactor: (web) move reporting to admin-console, refs EC-1011
* refactor: (web) move settings to admin-console, refs EC-1011
* refactor: (web) move sponsorships to admin-console, refs EC-1011
* refactor: (web) move tools to admin-console, refs EC-1011
* refactor: (web) move users to admin-console, refs EC-1011
* refactor: (web) move collections to admin-console, refs EC-1011
* refactor: (web) move create-organization to admin-console, refs EC-1011
* refactor: (web) move licensed components to admin-console, refs EC-1011
* refactor: (web) move bit organization modules to admin-console, refs EC-1011
* fix: update leftover import statements for organizations.module, refs EC-1011
* refactor: (web) move personal vault and max timeout to admin-console, refs EC-1011
* refactor: (web) move providers to admin-console, refs EC-1011
* refactor: (libs) move organization service to admin-console, refs EC-1011
* refactor: (libs) move profile org/provider responses and other misc org responses to admin-console, refs EC-1011
* refactor: (libs) move provider request and selectionion-read-only request to admin-console, refs EC-1011
* fix: update missed import path for provider-user-update request, refs EC-1011
* refactor: (libs) move abstractions to admin-console, refs EC-1011
* refactor: (libs) move org/provider enums to admin-console, refs EC-1011
* fix: update downstream import statements from libs changes, refs EC-1011
* refactor: (libs) move data files to admin-console, refs EC-1011
* refactor: (libs) move domain to admin-console, refs EC-1011
* refactor: (libs) move request objects to admin-console, refs EC-1011
* fix: update downstream import changes from libs, refs EC-1011
* refactor: move leftover provider files to admin-console, refs EC-1011
* refactor: (browser) move group policy environment to admin-console, refs EC-1011
* fix: (browser) update downstream import statements, refs EC-1011
* fix: (desktop) update downstream libs moves, refs EC-1011
* fix: (cli) update downstream import changes from libs, refs EC-1011
* refactor: move org-auth related files to admin-console, refs EC-1011
* refactor: (libs) move request objects to admin-console, refs EC-1011
* refactor: move persmissions to admin-console, refs EC-1011
* refactor: move sponsored families to admin-console and fix libs changes, refs EC-1011
* refactor: move collections to admin-console, refs EC-1011
* refactor: move spec file back to spec scope, refs EC-1011
* fix: update downstream imports due to libs changes, refs EC-1011
* fix: udpate downstream import changes due to libs, refs EC-1011
* fix: update downstream imports due to libs changes, refs EC-1011
* fix: update downstream imports from libs changes, refs EC-1011
* fix: update path malformation in jslib-services.module, refs EC-1011
* fix: lint errors from improper casing, refs AC-1011
* fix: update downstream filename changes, refs AC-1011
* fix: (cli) update downstream filename changes, refs AC-1011
* fix: (desktop) update downstream filename changes, refs AC-1011
* fix: (browser) update downstream filename changes, refs AC-1011
* fix: lint errors, refs AC-1011
* fix: prettier, refs AC-1011
* fix: lint fixes for import order, refs AC-1011
* fix: update import path for provider user type, refs AC-1011
* fix: update new codes import paths for admin console structure, refs AC-1011
* fix: lint/prettier, refs AC-1011
* fix: update layout stories path, refs AC-1011
* fix: update comoponents card icons base variable in styles, refs AC-1011
* fix: update provider service path in permissions guard spec, refs AC-1011
* fix: update provider permission guard path, refs AC-1011
* fix: remove unecessary TODO for shared index export statement, refs AC-1011
* refactor: move browser-organization service and cli organization-user response out of admin-console, refs AC-1011
* refactor: move web/browser/desktop collections component to vault domain, refs AC-1011
* refactor: move organization.module out of admin-console scope, refs AC-1011
* fix: prettier, refs AC-1011
* refactor: move organizations-api-key.request out of admin-console scope, refs AC-1011
2023-03-22 16:03:50 +01:00
|
|
|
import { CollectionService } from "@bitwarden/common/admin-console/abstractions/collection.service";
|
|
|
|
import { InternalPolicyService } from "@bitwarden/common/admin-console/abstractions/policy/policy.service.abstraction";
|
2023-02-06 22:53:37 +01:00
|
|
|
import { AuthService } from "@bitwarden/common/auth/abstractions/auth.service";
|
|
|
|
import { KeyConnectorService } from "@bitwarden/common/auth/abstractions/key-connector.service";
|
2023-03-10 21:39:46 +01:00
|
|
|
import { PasswordGenerationServiceAbstraction } from "@bitwarden/common/tools/generator/password";
|
2023-01-31 22:08:37 +01:00
|
|
|
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
|
|
|
|
import { InternalFolderService } from "@bitwarden/common/vault/abstractions/folder/folder.service.abstraction";
|
|
|
|
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
|
2021-06-07 20:13:58 +02:00
|
|
|
|
2022-11-02 17:57:25 +01:00
|
|
|
import {
|
|
|
|
DisableSendPolicy,
|
|
|
|
MasterPasswordPolicy,
|
|
|
|
PasswordGeneratorPolicy,
|
|
|
|
PersonalOwnershipPolicy,
|
|
|
|
RequireSsoPolicy,
|
|
|
|
ResetPasswordPolicy,
|
|
|
|
SendOptionsPolicy,
|
|
|
|
SingleOrgPolicy,
|
|
|
|
TwoFactorAuthenticationPolicy,
|
[AC-1011] Admin Console / Billing code ownership (#4973)
* refactor: move SCIM component to admin-console, refs EC-1011
* refactor: move scimProviderType to admin-console, refs EC-1011
* refactor: move scim-config.api to admin-console, refs EC-1011
* refactor: create models folder and nest existing api contents, refs EC-1011
* refactor: move scim-config to admin-console models, refs EC-1011
* refactor: move billing.component to billing, refs EC-1011
* refactor: remove nested app folder from new billing structure, refs EC-1011
* refactor: move organizations/billing to billing, refs EC-1011
* refactor: move add-credit and adjust-payment to billing/settings, refs EC-1011
* refactor: billing history/sync to billing, refs EC-1011
* refactor: move org plans, payment/method to billing/settings, refs EC-1011
* fix: update legacy file paths for payment-method and tax-info, refs EC-1011
* fix: update imports for scim component, refs EC-1011
* refactor: move subscription and tax-info into billing, refs EC-1011
* refactor: move user-subscription to billing, refs EC-1011
* refactor: move images/cards to billing and update base path, refs EC-1011
* refactor: move payment-method, plan subscription, and plan to billing, refs EC-1011
* refactor: move transaction-type to billing, refs EC-1011
* refactor: move billing-sync-config to billing, refs EC-1011
* refactor: move billing-sync and bit-pay-invoice request to billing, refs EC-1011
* refactor: move org subscription and tax info update requests to billing, refs EC-1011
* fix: broken paths to billing, refs EC-1011
* refactor: move payment request to billing, refs EC-1011
* fix: update remaining imports for payment-request, refs EC-1011
* refactor: move tax-info-update to billing, refs EC-1011
* refactor: move billing-payment, billing-history, and billing responses to billing, refs EC-1011
* refactor: move organization-subscription-responset to billing, refs EC-1011
* refactor: move payment and plan responses to billing, refs EC-1011
* refactor: move subscription response to billing ,refs EC-1011
* refactor: move tax info and rate responses to billing, refs EC-1011
* fix: update remaining path to base response for tax-rate response, refs EC-1011
* refactor: (browser) move organization-service to admin-console, refs EC-1011
* refactor: (browser) move organizaiton-service to admin-console, refs EC-1011
* refactor: (cli) move share command to admin-console, refs EC-1011
* refactor: move organization-collect request model to admin-console, refs EC-1011
* refactor: (web) move organization, collection/user responses to admin-console, refs EC-1011
* refactor: (cli) move selection-read-only to admin-console, refs EC-1011
* refactor: (desktop) move organization-filter to admin-console, refs EC-1011
* refactor: (web) move organization-switcher to admin-console, refs EC-1011
* refactor: (web) move access-selector to admin-console, refs EC-1011
* refactor: (web) move create folder to admin-console, refs EC-1011
* refactor: (web) move org guards folder to admin-console, refs EC-1011
* refactor: (web) move org layout to admin-console, refs EC-1011
* refactor: move manage collections to admin console, refs EC-1011
* refactor: (web) move collection-dialog to admin-console, refs EC-1011
* refactor: (web) move entity users/events and events component to admin-console, refs EC-1011
* refactor: (web) move groups/group-add-edit to admin-console, refs EC-1011
* refactor: (web) move manage, org-manage module, and user-confirm to admin-console, refs EC-1011
* refactor: (web) move people to admin-console, refs EC-1011
* refactor: (web) move reset-password to admin-console, refs EC-1011
* refactor: (web) move organization-routing and module to admin-console, refs EC-1011
* refactor: move admin-console and billing within app scope, refs EC-1011
* fix: update leftover merge conflicts, refs EC-1011
* refactor: (web) member-dialog to admin-console, refs EC-1011
* refactor: (web) move policies to admin-console, refs EC-1011
* refactor: (web) move reporting to admin-console, refs EC-1011
* refactor: (web) move settings to admin-console, refs EC-1011
* refactor: (web) move sponsorships to admin-console, refs EC-1011
* refactor: (web) move tools to admin-console, refs EC-1011
* refactor: (web) move users to admin-console, refs EC-1011
* refactor: (web) move collections to admin-console, refs EC-1011
* refactor: (web) move create-organization to admin-console, refs EC-1011
* refactor: (web) move licensed components to admin-console, refs EC-1011
* refactor: (web) move bit organization modules to admin-console, refs EC-1011
* fix: update leftover import statements for organizations.module, refs EC-1011
* refactor: (web) move personal vault and max timeout to admin-console, refs EC-1011
* refactor: (web) move providers to admin-console, refs EC-1011
* refactor: (libs) move organization service to admin-console, refs EC-1011
* refactor: (libs) move profile org/provider responses and other misc org responses to admin-console, refs EC-1011
* refactor: (libs) move provider request and selectionion-read-only request to admin-console, refs EC-1011
* fix: update missed import path for provider-user-update request, refs EC-1011
* refactor: (libs) move abstractions to admin-console, refs EC-1011
* refactor: (libs) move org/provider enums to admin-console, refs EC-1011
* fix: update downstream import statements from libs changes, refs EC-1011
* refactor: (libs) move data files to admin-console, refs EC-1011
* refactor: (libs) move domain to admin-console, refs EC-1011
* refactor: (libs) move request objects to admin-console, refs EC-1011
* fix: update downstream import changes from libs, refs EC-1011
* refactor: move leftover provider files to admin-console, refs EC-1011
* refactor: (browser) move group policy environment to admin-console, refs EC-1011
* fix: (browser) update downstream import statements, refs EC-1011
* fix: (desktop) update downstream libs moves, refs EC-1011
* fix: (cli) update downstream import changes from libs, refs EC-1011
* refactor: move org-auth related files to admin-console, refs EC-1011
* refactor: (libs) move request objects to admin-console, refs EC-1011
* refactor: move persmissions to admin-console, refs EC-1011
* refactor: move sponsored families to admin-console and fix libs changes, refs EC-1011
* refactor: move collections to admin-console, refs EC-1011
* refactor: move spec file back to spec scope, refs EC-1011
* fix: update downstream imports due to libs changes, refs EC-1011
* fix: udpate downstream import changes due to libs, refs EC-1011
* fix: update downstream imports due to libs changes, refs EC-1011
* fix: update downstream imports from libs changes, refs EC-1011
* fix: update path malformation in jslib-services.module, refs EC-1011
* fix: lint errors from improper casing, refs AC-1011
* fix: update downstream filename changes, refs AC-1011
* fix: (cli) update downstream filename changes, refs AC-1011
* fix: (desktop) update downstream filename changes, refs AC-1011
* fix: (browser) update downstream filename changes, refs AC-1011
* fix: lint errors, refs AC-1011
* fix: prettier, refs AC-1011
* fix: lint fixes for import order, refs AC-1011
* fix: update import path for provider user type, refs AC-1011
* fix: update new codes import paths for admin console structure, refs AC-1011
* fix: lint/prettier, refs AC-1011
* fix: update layout stories path, refs AC-1011
* fix: update comoponents card icons base variable in styles, refs AC-1011
* fix: update provider service path in permissions guard spec, refs AC-1011
* fix: update provider permission guard path, refs AC-1011
* fix: remove unecessary TODO for shared index export statement, refs AC-1011
* refactor: move browser-organization service and cli organization-user response out of admin-console, refs AC-1011
* refactor: move web/browser/desktop collections component to vault domain, refs AC-1011
* refactor: move organization.module out of admin-console scope, refs AC-1011
* fix: prettier, refs AC-1011
* refactor: move organizations-api-key.request out of admin-console scope, refs AC-1011
2023-03-22 16:03:50 +01:00
|
|
|
} from "./admin-console/organizations/policies";
|
|
|
|
import { PolicyListService, RouterService } from "./core";
|
2021-08-25 16:10:17 +02:00
|
|
|
|
2021-12-17 15:57:11 +01:00
|
|
|
const BroadcasterSubscriptionId = "AppComponent";
|
2018-08-23 04:56:00 +02:00
|
|
|
const IdleTimeout = 60000 * 10; // 10 minutes
|
2018-06-08 23:08:19 +02:00
|
|
|
|
2018-06-05 05:10:41 +02:00
|
|
|
@Component({
|
2021-12-17 15:57:11 +01:00
|
|
|
selector: "app-root",
|
|
|
|
templateUrl: "app.component.html",
|
2018-06-05 05:10:41 +02:00
|
|
|
})
|
2018-06-08 23:08:19 +02:00
|
|
|
export class AppComponent implements OnDestroy, OnInit {
|
2021-12-17 15:57:11 +01:00
|
|
|
private lastActivity: number = null;
|
|
|
|
private idleTimer: number = null;
|
|
|
|
private isIdle = false;
|
2022-07-12 15:02:19 +02:00
|
|
|
private destroy$ = new Subject<void>();
|
2021-08-25 16:10:17 +02:00
|
|
|
|
2021-12-17 15:57:11 +01:00
|
|
|
constructor(
|
2022-06-06 19:08:06 +02:00
|
|
|
@Inject(DOCUMENT) private document: Document,
|
2021-12-17 15:57:11 +01:00
|
|
|
private broadcasterService: BroadcasterService,
|
2022-07-08 15:40:31 +02:00
|
|
|
private folderService: InternalFolderService,
|
2021-12-17 15:57:11 +01:00
|
|
|
private settingsService: SettingsService,
|
|
|
|
private syncService: SyncService,
|
2023-03-10 21:39:46 +01:00
|
|
|
private passwordGenerationService: PasswordGenerationServiceAbstraction,
|
2021-12-17 15:57:11 +01:00
|
|
|
private cipherService: CipherService,
|
|
|
|
private authService: AuthService,
|
|
|
|
private router: Router,
|
|
|
|
private toastrService: ToastrService,
|
|
|
|
private i18nService: I18nService,
|
|
|
|
private platformUtilsService: PlatformUtilsService,
|
|
|
|
private ngZone: NgZone,
|
|
|
|
private vaultTimeoutService: VaultTimeoutService,
|
|
|
|
private cryptoService: CryptoService,
|
|
|
|
private collectionService: CollectionService,
|
|
|
|
private sanitizer: DomSanitizer,
|
|
|
|
private searchService: SearchService,
|
|
|
|
private notificationsService: NotificationsService,
|
|
|
|
private routerService: RouterService,
|
|
|
|
private stateService: StateService,
|
2022-12-06 14:47:42 +01:00
|
|
|
private eventUploadService: EventUploadService,
|
2022-08-08 11:04:36 +02:00
|
|
|
private policyService: InternalPolicyService,
|
2021-12-17 15:57:11 +01:00
|
|
|
protected policyListService: PolicyListService,
|
2023-04-26 16:30:39 +02:00
|
|
|
private keyConnectorService: KeyConnectorService,
|
2023-05-02 18:46:03 +02:00
|
|
|
private configService: ConfigServiceAbstraction,
|
|
|
|
private dialogService: DialogServiceAbstraction
|
2021-12-17 15:57:11 +01:00
|
|
|
) {}
|
2018-06-08 23:08:19 +02:00
|
|
|
|
2021-12-17 15:57:11 +01:00
|
|
|
ngOnInit() {
|
2022-07-12 15:02:19 +02:00
|
|
|
this.i18nService.locale$.pipe(takeUntil(this.destroy$)).subscribe((locale) => {
|
|
|
|
this.document.documentElement.lang = locale;
|
|
|
|
});
|
2022-06-06 19:08:06 +02:00
|
|
|
|
2021-12-17 15:57:11 +01:00
|
|
|
this.ngZone.runOutsideAngular(() => {
|
|
|
|
window.onmousemove = () => this.recordActivity();
|
|
|
|
window.onmousedown = () => this.recordActivity();
|
|
|
|
window.ontouchstart = () => this.recordActivity();
|
|
|
|
window.onclick = () => this.recordActivity();
|
|
|
|
window.onscroll = () => this.recordActivity();
|
|
|
|
window.onkeypress = () => this.recordActivity();
|
|
|
|
});
|
2018-06-08 23:08:19 +02:00
|
|
|
|
2021-12-17 15:57:11 +01:00
|
|
|
this.broadcasterService.subscribe(BroadcasterSubscriptionId, async (message: any) => {
|
|
|
|
this.ngZone.run(async () => {
|
|
|
|
switch (message.command) {
|
|
|
|
case "loggedIn":
|
2022-04-25 15:41:44 +02:00
|
|
|
this.notificationsService.updateConnection(false);
|
|
|
|
break;
|
2021-12-17 15:57:11 +01:00
|
|
|
case "loggedOut":
|
2022-04-25 15:41:44 +02:00
|
|
|
this.routerService.setPreviousUrl(null);
|
|
|
|
this.notificationsService.updateConnection(false);
|
|
|
|
break;
|
2021-12-17 15:57:11 +01:00
|
|
|
case "unlocked":
|
|
|
|
this.notificationsService.updateConnection(false);
|
|
|
|
break;
|
|
|
|
case "authBlocked":
|
2022-04-25 15:41:44 +02:00
|
|
|
this.routerService.setPreviousUrl(message.url);
|
2021-12-17 15:57:11 +01:00
|
|
|
this.router.navigate(["/"]);
|
|
|
|
break;
|
|
|
|
case "logout":
|
2022-12-29 17:20:19 +01:00
|
|
|
this.logOut(!!message.expired, message.redirect);
|
2021-12-17 15:57:11 +01:00
|
|
|
break;
|
|
|
|
case "lockVault":
|
|
|
|
await this.vaultTimeoutService.lock();
|
|
|
|
break;
|
|
|
|
case "locked":
|
|
|
|
this.notificationsService.updateConnection(false);
|
|
|
|
this.router.navigate(["lock"]);
|
|
|
|
break;
|
|
|
|
case "lockedUrl":
|
2022-04-25 15:41:44 +02:00
|
|
|
this.routerService.setPreviousUrl(message.url);
|
2021-12-17 15:57:11 +01:00
|
|
|
break;
|
|
|
|
case "syncStarted":
|
|
|
|
break;
|
|
|
|
case "syncCompleted":
|
2023-04-26 16:30:39 +02:00
|
|
|
await this.configService.fetchServerConfig();
|
2021-12-17 15:57:11 +01:00
|
|
|
break;
|
2022-02-24 12:10:07 +01:00
|
|
|
case "upgradeOrganization": {
|
2023-05-02 18:46:03 +02:00
|
|
|
const upgradeConfirmed = await this.dialogService.openSimpleDialog({
|
|
|
|
title: { key: "upgradeOrganization" },
|
|
|
|
content: { key: "upgradeOrganizationDesc" },
|
|
|
|
acceptButtonText: { key: "upgradeOrganization" },
|
|
|
|
type: SimpleDialogType.INFO,
|
|
|
|
});
|
2021-12-17 15:57:11 +01:00
|
|
|
if (upgradeConfirmed) {
|
|
|
|
this.router.navigate([
|
|
|
|
"organizations",
|
|
|
|
message.organizationId,
|
|
|
|
"billing",
|
2023-03-30 22:27:03 +02:00
|
|
|
"subscription",
|
2021-12-17 15:57:11 +01:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
break;
|
2022-02-24 12:10:07 +01:00
|
|
|
}
|
|
|
|
case "premiumRequired": {
|
2023-05-02 18:46:03 +02:00
|
|
|
const premiumConfirmed = await this.dialogService.openSimpleDialog({
|
|
|
|
title: { key: "premiumRequired" },
|
|
|
|
content: { key: "premiumRequiredDesc" },
|
|
|
|
acceptButtonText: { key: "upgrade" },
|
|
|
|
type: SimpleDialogType.SUCCESS,
|
|
|
|
});
|
2021-12-17 15:57:11 +01:00
|
|
|
if (premiumConfirmed) {
|
2022-07-29 16:22:50 +02:00
|
|
|
this.router.navigate(["settings/subscription/premium"]);
|
2021-12-17 15:57:11 +01:00
|
|
|
}
|
|
|
|
break;
|
2022-02-24 12:10:07 +01:00
|
|
|
}
|
|
|
|
case "emailVerificationRequired": {
|
2023-05-02 18:46:03 +02:00
|
|
|
const emailVerificationConfirmed = await this.dialogService.openSimpleDialog({
|
|
|
|
title: { key: "emailVerificationRequired" },
|
|
|
|
content: { key: "emailVerificationRequiredDesc" },
|
|
|
|
acceptButtonText: { key: "learnMore" },
|
|
|
|
type: SimpleDialogType.INFO,
|
|
|
|
});
|
2021-12-17 15:57:11 +01:00
|
|
|
if (emailVerificationConfirmed) {
|
|
|
|
this.platformUtilsService.launchUri(
|
2022-01-31 20:11:27 +01:00
|
|
|
"https://bitwarden.com/help/create-bitwarden-account/"
|
2021-12-17 15:57:11 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
break;
|
2022-02-24 12:10:07 +01:00
|
|
|
}
|
2021-12-17 15:57:11 +01:00
|
|
|
case "showToast":
|
|
|
|
this.showToast(message);
|
|
|
|
break;
|
|
|
|
case "setFullWidth":
|
|
|
|
this.setFullWidth();
|
|
|
|
break;
|
|
|
|
case "convertAccountToKeyConnector":
|
|
|
|
this.router.navigate(["/remove-password"]);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
2018-06-08 23:08:19 +02:00
|
|
|
|
2022-07-12 15:02:19 +02:00
|
|
|
this.router.events.pipe(takeUntil(this.destroy$)).subscribe((event) => {
|
2021-12-17 15:57:11 +01:00
|
|
|
if (event instanceof NavigationEnd) {
|
|
|
|
const modals = Array.from(document.querySelectorAll(".modal"));
|
|
|
|
for (const modal of modals) {
|
|
|
|
(jq(modal) as any).modal("hide");
|
|
|
|
}
|
2018-06-09 19:59:09 +02:00
|
|
|
|
2021-12-17 15:57:11 +01:00
|
|
|
if (document.querySelector(".swal-modal") != null) {
|
|
|
|
Swal.close(undefined);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2018-06-09 19:59:09 +02:00
|
|
|
|
2021-12-17 15:57:11 +01:00
|
|
|
this.policyListService.addPolicies([
|
|
|
|
new TwoFactorAuthenticationPolicy(),
|
|
|
|
new MasterPasswordPolicy(),
|
2022-07-11 12:24:02 +02:00
|
|
|
new ResetPasswordPolicy(),
|
2021-12-17 15:57:11 +01:00
|
|
|
new PasswordGeneratorPolicy(),
|
|
|
|
new SingleOrgPolicy(),
|
|
|
|
new RequireSsoPolicy(),
|
|
|
|
new PersonalOwnershipPolicy(),
|
|
|
|
new DisableSendPolicy(),
|
|
|
|
new SendOptionsPolicy(),
|
|
|
|
]);
|
2022-03-09 17:16:53 +01:00
|
|
|
|
|
|
|
this.setFullWidth();
|
2021-12-17 15:57:11 +01:00
|
|
|
}
|
2021-08-25 16:10:17 +02:00
|
|
|
|
2021-12-17 15:57:11 +01:00
|
|
|
ngOnDestroy() {
|
|
|
|
this.broadcasterService.unsubscribe(BroadcasterSubscriptionId);
|
2022-07-12 15:02:19 +02:00
|
|
|
this.destroy$.next();
|
2022-08-26 18:09:28 +02:00
|
|
|
this.destroy$.complete();
|
2021-12-17 15:57:11 +01:00
|
|
|
}
|
2018-06-08 23:08:19 +02:00
|
|
|
|
2022-12-29 17:20:19 +01:00
|
|
|
private async logOut(expired: boolean, redirect = true) {
|
2022-12-06 14:47:42 +01:00
|
|
|
await this.eventUploadService.uploadEvents();
|
2021-12-17 15:57:11 +01:00
|
|
|
const userId = await this.stateService.getUserId();
|
|
|
|
await Promise.all([
|
|
|
|
this.syncService.setLastSync(new Date(0)),
|
|
|
|
this.cryptoService.clearKeys(),
|
|
|
|
this.settingsService.clear(userId),
|
|
|
|
this.cipherService.clear(userId),
|
|
|
|
this.folderService.clear(userId),
|
|
|
|
this.collectionService.clear(userId),
|
|
|
|
this.policyService.clear(userId),
|
|
|
|
this.passwordGenerationService.clear(),
|
|
|
|
this.keyConnectorService.clear(),
|
|
|
|
]);
|
2018-06-08 23:08:19 +02:00
|
|
|
|
2021-12-17 15:57:11 +01:00
|
|
|
this.searchService.clearIndex();
|
|
|
|
this.authService.logOut(async () => {
|
|
|
|
if (expired) {
|
|
|
|
this.platformUtilsService.showToast(
|
|
|
|
"warning",
|
|
|
|
this.i18nService.t("loggedOut"),
|
|
|
|
this.i18nService.t("loginExpired")
|
|
|
|
);
|
|
|
|
}
|
2018-06-08 23:08:19 +02:00
|
|
|
|
2021-12-17 15:57:11 +01:00
|
|
|
await this.stateService.clean({ userId: userId });
|
|
|
|
Swal.close();
|
2022-12-29 17:20:19 +01:00
|
|
|
if (redirect) {
|
|
|
|
this.router.navigate(["/"]);
|
|
|
|
}
|
2021-12-17 15:57:11 +01:00
|
|
|
});
|
|
|
|
}
|
2020-07-09 22:11:28 +02:00
|
|
|
|
2021-12-17 15:57:11 +01:00
|
|
|
private async recordActivity() {
|
|
|
|
const now = new Date().getTime();
|
|
|
|
if (this.lastActivity != null && now - this.lastActivity < 250) {
|
|
|
|
return;
|
2018-06-08 23:08:19 +02:00
|
|
|
}
|
|
|
|
|
2021-12-17 15:57:11 +01:00
|
|
|
this.lastActivity = now;
|
|
|
|
this.stateService.setLastActive(now);
|
|
|
|
// Idle states
|
|
|
|
if (this.isIdle) {
|
|
|
|
this.isIdle = false;
|
|
|
|
this.idleStateChanged();
|
2018-08-23 04:37:55 +02:00
|
|
|
}
|
2021-12-17 15:57:11 +01:00
|
|
|
if (this.idleTimer != null) {
|
|
|
|
window.clearTimeout(this.idleTimer);
|
|
|
|
this.idleTimer = null;
|
|
|
|
}
|
|
|
|
this.idleTimer = window.setTimeout(() => {
|
|
|
|
if (!this.isIdle) {
|
|
|
|
this.isIdle = true;
|
|
|
|
this.idleStateChanged();
|
|
|
|
}
|
|
|
|
}, IdleTimeout);
|
|
|
|
}
|
2018-08-23 04:37:55 +02:00
|
|
|
|
2021-12-17 15:57:11 +01:00
|
|
|
private showToast(msg: any) {
|
|
|
|
let message = "";
|
2021-12-07 20:41:45 +01:00
|
|
|
|
2021-12-17 15:57:11 +01:00
|
|
|
const options: Partial<IndividualConfig> = {};
|
2021-12-07 20:41:45 +01:00
|
|
|
|
2021-12-17 15:57:11 +01:00
|
|
|
if (typeof msg.text === "string") {
|
|
|
|
message = msg.text;
|
|
|
|
} else if (msg.text.length === 1) {
|
|
|
|
message = msg.text[0];
|
|
|
|
} else {
|
|
|
|
msg.text.forEach(
|
|
|
|
(t: string) =>
|
|
|
|
(message += "<p>" + this.sanitizer.sanitize(SecurityContext.HTML, t) + "</p>")
|
|
|
|
);
|
|
|
|
options.enableHtml = true;
|
|
|
|
}
|
|
|
|
if (msg.options != null) {
|
|
|
|
if (msg.options.trustedHtml === true) {
|
|
|
|
options.enableHtml = true;
|
|
|
|
}
|
|
|
|
if (msg.options.timeout != null && msg.options.timeout > 0) {
|
|
|
|
options.timeOut = msg.options.timeout;
|
|
|
|
}
|
2018-10-03 16:33:04 +02:00
|
|
|
}
|
|
|
|
|
2021-12-17 15:57:11 +01:00
|
|
|
this.toastrService.show(message, msg.title, options, "toast-" + msg.type);
|
|
|
|
}
|
|
|
|
|
|
|
|
private idleStateChanged() {
|
|
|
|
if (this.isIdle) {
|
|
|
|
this.notificationsService.disconnectFromInactivity();
|
|
|
|
} else {
|
|
|
|
this.notificationsService.reconnectFromActivity();
|
2018-06-05 05:10:41 +02:00
|
|
|
}
|
2021-12-17 15:57:11 +01:00
|
|
|
}
|
2020-05-30 10:30:35 +02:00
|
|
|
|
2021-12-17 15:57:11 +01:00
|
|
|
private async setFullWidth() {
|
|
|
|
const enableFullWidth = await this.stateService.getEnableFullWidth();
|
|
|
|
if (enableFullWidth) {
|
|
|
|
document.body.classList.add("full-width");
|
|
|
|
} else {
|
|
|
|
document.body.classList.remove("full-width");
|
2020-05-30 10:30:35 +02:00
|
|
|
}
|
2021-12-17 15:57:11 +01:00
|
|
|
}
|
2018-06-05 05:10:41 +02:00
|
|
|
}
|