2018-04-10 22:20:49 +02:00
|
|
|
import { Component, ElementRef, OnInit, ViewChild } from "@angular/core";
|
2023-04-15 01:11:33 +02:00
|
|
|
import { FormBuilder } from "@angular/forms";
|
2018-04-10 22:20:49 +02:00
|
|
|
import { Router } from "@angular/router";
|
2023-04-15 01:11:33 +02:00
|
|
|
import { concatMap, filter, map, Observable, Subject, takeUntil, tap } from "rxjs";
|
2022-03-15 13:13:39 +01:00
|
|
|
import Swal from "sweetalert2";
|
2018-04-10 22:20:49 +02:00
|
|
|
|
2022-06-14 17:10:53 +02:00
|
|
|
import { ModalService } from "@bitwarden/angular/services/modal.service";
|
|
|
|
import { CryptoService } from "@bitwarden/common/abstractions/crypto.service";
|
|
|
|
import { EnvironmentService } from "@bitwarden/common/abstractions/environment.service";
|
|
|
|
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
|
|
|
import { MessagingService } from "@bitwarden/common/abstractions/messaging.service";
|
|
|
|
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.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";
|
2022-08-30 22:30:43 +02:00
|
|
|
import { VaultTimeoutSettingsService } from "@bitwarden/common/abstractions/vaultTimeout/vaultTimeoutSettings.service";
|
2023-04-15 01:11:33 +02:00
|
|
|
import { PolicyService } from "@bitwarden/common/admin-console/abstractions/policy/policy.service.abstraction";
|
|
|
|
import { PolicyType } from "@bitwarden/common/admin-console/enums";
|
2023-02-06 22:53:37 +01:00
|
|
|
import { KeyConnectorService } from "@bitwarden/common/auth/abstractions/key-connector.service";
|
[AC-1266] Enums filename conventions (#5140)
* refactor: update clientType enum
* refactor: update deviceType filename
* refactor: update encryptedExportType filename
* refactor: update encryptionType filename
* refactor: update eventType filename
* refactor: update fieldType filename
* refactor: update fileUploadType filename
* refactor: update hashPurpose filename
* refactor: update htmlStorageLocation filename
* refactor: update kdfType filename
* refactor: update keySuffixOptions filename
* refactor: update linkedIdType filename
* refactor: update logLevelType filename
* refactor: update nativeMessagingVersion filename
* refactor: update notificationType filename
* refactor: update productType filename
* refactor: update secureNoteType filename
* refactor: update stateVersion filename
* refactor: update storageLocation filename
* refactor: update themeType filename
* refactor: update uriMatchType filename
* fix: update kdfType classes missed in initial pass, refs AC-1266
* fix: missing import update for device-type
* refactor: add barrel file for enums and update pathed import statements, refs AC-1266
* fix: incorrect import statements for web, refs AC-1266
* fix: missed import statement updates (browser), refs AC-1266
* fix: missed import statement changes (cli), refs AC-1266
* fix: missed import statement changes (desktop), refs AC-1266
* fix: prettier, refs AC-1266
* refactor: (libs) update relative paths to use barrel file, refs AC-1266
* fix: missed find/replace import statements for SecureNoteType, refs AC-1266
* refactor: apply .enum suffix to enums folder and modify leftover relative paths, refs AC-1266
* fix: find/replace errors for native-messaging-version, refs AC-1266
2023-04-05 05:42:21 +02:00
|
|
|
import { DeviceType } from "@bitwarden/common/enums";
|
2023-04-15 01:11:33 +02:00
|
|
|
import { VaultTimeoutAction } from "@bitwarden/common/enums/vault-timeout-action.enum";
|
2021-09-15 21:56:29 +02:00
|
|
|
|
2022-02-24 18:14:04 +01:00
|
|
|
import { BrowserApi } from "../../browser/browserApi";
|
2022-03-15 13:13:39 +01:00
|
|
|
import { BiometricErrors, BiometricErrorTypes } from "../../models/biometricErrors";
|
2021-09-15 21:56:29 +02:00
|
|
|
import { SetPinComponent } from "../components/set-pin.component";
|
2022-02-24 18:14:04 +01:00
|
|
|
import { PopupUtilsService } from "../services/popup-utils.service";
|
2021-09-15 21:56:29 +02:00
|
|
|
|
2022-09-08 14:27:19 +02:00
|
|
|
import { AboutComponent } from "./about.component";
|
|
|
|
|
2018-04-10 22:20:49 +02:00
|
|
|
const RateUrls = {
|
2018-07-09 15:12:41 +02:00
|
|
|
[DeviceType.ChromeExtension]:
|
2018-04-10 22:20:49 +02:00
|
|
|
"https://chrome.google.com/webstore/detail/bitwarden-free-password-m/nngceckbapebfimnlniiiahkandclblb/reviews",
|
2018-07-09 15:12:41 +02:00
|
|
|
[DeviceType.FirefoxExtension]:
|
2018-04-10 22:20:49 +02:00
|
|
|
"https://addons.mozilla.org/en-US/firefox/addon/bitwarden-password-manager/#reviews",
|
2018-07-09 15:12:41 +02:00
|
|
|
[DeviceType.OperaExtension]:
|
2018-04-10 22:20:49 +02:00
|
|
|
"https://addons.opera.com/en/extensions/details/bitwarden-free-password-manager/#feedback-container",
|
2018-07-09 15:12:41 +02:00
|
|
|
[DeviceType.EdgeExtension]:
|
2020-03-03 14:48:11 +01:00
|
|
|
"https://microsoftedge.microsoft.com/addons/detail/jbkfoedolllekgbhcbcoahefnbanhhlh",
|
2018-07-09 15:12:41 +02:00
|
|
|
[DeviceType.VivaldiExtension]:
|
2018-04-10 22:20:49 +02:00
|
|
|
"https://chrome.google.com/webstore/detail/bitwarden-free-password-m/nngceckbapebfimnlniiiahkandclblb/reviews",
|
2019-08-21 16:05:17 +02:00
|
|
|
[DeviceType.SafariExtension]: "https://apps.apple.com/app/bitwarden/id1352778147",
|
2018-04-10 22:20:49 +02:00
|
|
|
};
|
2018-04-09 23:35:16 +02:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: "app-settings",
|
|
|
|
templateUrl: "settings.component.html",
|
|
|
|
})
|
2022-08-26 18:09:28 +02:00
|
|
|
// eslint-disable-next-line rxjs-angular/prefer-takeuntil
|
2018-04-10 22:20:49 +02:00
|
|
|
export class SettingsComponent implements OnInit {
|
2020-08-18 22:13:37 +02:00
|
|
|
@ViewChild("vaultTimeoutActionSelect", { read: ElementRef, static: true })
|
|
|
|
vaultTimeoutActionSelectRef: ElementRef;
|
2023-04-15 01:11:33 +02:00
|
|
|
vaultTimeoutOptions: any[];
|
|
|
|
vaultTimeoutActionOptions: any[];
|
|
|
|
vaultTimeoutPolicyCallout: Observable<{
|
|
|
|
timeout: { hours: number; minutes: number };
|
|
|
|
action: VaultTimeoutAction;
|
|
|
|
}>;
|
2021-01-25 21:23:18 +01:00
|
|
|
supportsBiometric: boolean;
|
2020-04-06 17:40:16 +02:00
|
|
|
previousVaultTimeout: number = null;
|
2021-11-09 18:59:51 +01:00
|
|
|
showChangeMasterPass = true;
|
2021-12-21 15:43:35 +01:00
|
|
|
|
2023-04-15 01:11:33 +02:00
|
|
|
form = this.formBuilder.group({
|
|
|
|
vaultTimeout: [null as number | null],
|
|
|
|
vaultTimeoutAction: [VaultTimeoutAction.Lock],
|
|
|
|
pin: [null as boolean | null],
|
|
|
|
biometric: false,
|
|
|
|
enableAutoBiometricsPrompt: true,
|
|
|
|
});
|
|
|
|
|
|
|
|
private destroy$ = new Subject<void>();
|
2021-12-21 15:43:35 +01:00
|
|
|
|
2018-04-10 22:20:49 +02:00
|
|
|
constructor(
|
2023-04-15 01:11:33 +02:00
|
|
|
private policyService: PolicyService,
|
|
|
|
private formBuilder: FormBuilder,
|
2018-04-10 22:20:49 +02:00
|
|
|
private platformUtilsService: PlatformUtilsService,
|
|
|
|
private i18nService: I18nService,
|
2021-04-14 23:43:09 +02:00
|
|
|
private vaultTimeoutService: VaultTimeoutService,
|
2022-08-30 22:30:43 +02:00
|
|
|
private vaultTimeoutSettingsService: VaultTimeoutSettingsService,
|
2021-04-14 23:43:09 +02:00
|
|
|
public messagingService: MessagingService,
|
|
|
|
private router: Router,
|
|
|
|
private environmentService: EnvironmentService,
|
|
|
|
private cryptoService: CryptoService,
|
2022-01-27 22:22:51 +01:00
|
|
|
private stateService: StateService,
|
2021-09-14 13:36:34 +02:00
|
|
|
private popupUtilsService: PopupUtilsService,
|
2021-12-07 20:42:18 +01:00
|
|
|
private modalService: ModalService,
|
2021-11-09 18:59:51 +01:00
|
|
|
private keyConnectorService: KeyConnectorService
|
2021-12-21 15:43:35 +01:00
|
|
|
) {}
|
|
|
|
|
2018-04-10 22:20:49 +02:00
|
|
|
async ngOnInit() {
|
2023-04-15 01:11:33 +02:00
|
|
|
this.vaultTimeoutPolicyCallout = this.policyService.get$(PolicyType.MaximumVaultTimeout).pipe(
|
|
|
|
filter((policy) => policy != null),
|
|
|
|
map((policy) => {
|
|
|
|
let timeout;
|
|
|
|
if (policy.data?.minutes) {
|
|
|
|
timeout = {
|
|
|
|
hours: Math.floor(policy.data?.minutes / 60),
|
|
|
|
minutes: policy.data?.minutes % 60,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
return { timeout: timeout, action: policy.data?.action };
|
|
|
|
}),
|
|
|
|
tap((policy) => {
|
|
|
|
if (policy.action) {
|
|
|
|
this.form.controls.vaultTimeoutAction.disable({ emitEvent: false });
|
|
|
|
} else {
|
|
|
|
this.form.controls.vaultTimeoutAction.enable({ emitEvent: false });
|
|
|
|
}
|
|
|
|
})
|
|
|
|
);
|
|
|
|
|
2020-09-15 16:50:45 +02:00
|
|
|
const showOnLocked =
|
|
|
|
!this.platformUtilsService.isFirefox() && !this.platformUtilsService.isSafari();
|
2021-12-21 15:43:35 +01:00
|
|
|
|
2023-04-15 01:11:33 +02:00
|
|
|
this.vaultTimeoutOptions = [
|
2018-04-10 22:20:49 +02:00
|
|
|
{ name: this.i18nService.t("immediately"), value: 0 },
|
|
|
|
{ name: this.i18nService.t("oneMinute"), value: 1 },
|
|
|
|
{ name: this.i18nService.t("fiveMinutes"), value: 5 },
|
|
|
|
{ name: this.i18nService.t("fifteenMinutes"), value: 15 },
|
|
|
|
{ name: this.i18nService.t("thirtyMinutes"), value: 30 },
|
|
|
|
{ name: this.i18nService.t("oneHour"), value: 60 },
|
|
|
|
{ name: this.i18nService.t("fourHours"), value: 240 },
|
|
|
|
// { name: i18nService.t('onIdle'), value: -4 },
|
|
|
|
// { name: i18nService.t('onSleep'), value: -3 },
|
2021-12-21 15:43:35 +01:00
|
|
|
];
|
|
|
|
|
2021-11-09 18:59:51 +01:00
|
|
|
if (showOnLocked) {
|
2023-04-15 01:11:33 +02:00
|
|
|
this.vaultTimeoutOptions.push({ name: this.i18nService.t("onLocked"), value: -2 });
|
2018-04-10 22:20:49 +02:00
|
|
|
}
|
|
|
|
|
2023-04-15 01:11:33 +02:00
|
|
|
this.vaultTimeoutOptions.push({ name: this.i18nService.t("onRestart"), value: -1 });
|
|
|
|
this.vaultTimeoutOptions.push({ name: this.i18nService.t("never"), value: null });
|
2021-09-14 13:36:34 +02:00
|
|
|
|
2023-04-15 01:11:33 +02:00
|
|
|
this.vaultTimeoutActionOptions = [
|
|
|
|
{ name: this.i18nService.t(VaultTimeoutAction.Lock), value: VaultTimeoutAction.Lock },
|
|
|
|
{ name: this.i18nService.t(VaultTimeoutAction.LogOut), value: VaultTimeoutAction.LogOut },
|
2020-04-06 17:40:16 +02:00
|
|
|
];
|
2019-02-13 05:53:04 +01:00
|
|
|
|
2022-08-30 22:30:43 +02:00
|
|
|
let timeout = await this.vaultTimeoutSettingsService.getVaultTimeout();
|
2023-04-15 01:11:33 +02:00
|
|
|
if (timeout === -2 && !showOnLocked) {
|
|
|
|
timeout = -1;
|
2018-04-10 22:20:49 +02:00
|
|
|
}
|
2022-08-30 22:30:43 +02:00
|
|
|
const pinSet = await this.vaultTimeoutSettingsService.isPinLockSet();
|
2021-12-21 15:43:35 +01:00
|
|
|
|
2023-04-15 01:11:33 +02:00
|
|
|
const initialValues = {
|
|
|
|
vaultTimeout: timeout,
|
|
|
|
vaultTimeoutAction: await this.vaultTimeoutSettingsService.getVaultTimeoutAction(),
|
|
|
|
pin: pinSet[0] || pinSet[1],
|
|
|
|
biometric: await this.vaultTimeoutSettingsService.isBiometricLockSet(),
|
|
|
|
enableAutoBiometricsPrompt: !(await this.stateService.getDisableAutoBiometricsPrompt()),
|
|
|
|
};
|
|
|
|
this.form.setValue(initialValues, { emitEvent: false });
|
|
|
|
|
|
|
|
this.previousVaultTimeout = timeout;
|
2021-09-14 13:36:34 +02:00
|
|
|
this.supportsBiometric = await this.platformUtilsService.supportsBiometric();
|
2021-12-07 20:42:18 +01:00
|
|
|
this.showChangeMasterPass = !(await this.keyConnectorService.getUsesKeyConnector());
|
2023-04-15 01:11:33 +02:00
|
|
|
|
|
|
|
this.form.controls.vaultTimeout.valueChanges
|
|
|
|
.pipe(
|
|
|
|
concatMap(async (value) => {
|
|
|
|
await this.saveVaultTimeout(value);
|
|
|
|
}),
|
|
|
|
takeUntil(this.destroy$)
|
|
|
|
)
|
|
|
|
.subscribe();
|
|
|
|
|
|
|
|
this.form.controls.vaultTimeoutAction.valueChanges
|
|
|
|
.pipe(
|
|
|
|
concatMap(async (action) => {
|
|
|
|
await this.saveVaultTimeoutAction(action);
|
|
|
|
}),
|
|
|
|
takeUntil(this.destroy$)
|
|
|
|
)
|
|
|
|
.subscribe();
|
|
|
|
|
|
|
|
this.form.controls.biometric.valueChanges
|
|
|
|
.pipe(takeUntil(this.destroy$))
|
|
|
|
.subscribe((enabled) => {
|
|
|
|
if (enabled) {
|
|
|
|
this.form.controls.enableAutoBiometricsPrompt.enable();
|
|
|
|
} else {
|
|
|
|
this.form.controls.enableAutoBiometricsPrompt.disable();
|
|
|
|
}
|
|
|
|
});
|
2021-09-14 13:36:34 +02:00
|
|
|
}
|
2021-12-21 15:43:35 +01:00
|
|
|
|
2020-04-06 17:40:16 +02:00
|
|
|
async saveVaultTimeout(newValue: number) {
|
2019-02-13 05:53:04 +01:00
|
|
|
if (newValue == null) {
|
2021-09-15 21:56:29 +02:00
|
|
|
const confirmed = await this.platformUtilsService.showDialog(
|
2019-02-13 05:53:04 +01:00
|
|
|
this.i18nService.t("neverLockWarning"),
|
2021-12-21 15:43:35 +01:00
|
|
|
null,
|
2021-09-15 21:56:29 +02:00
|
|
|
this.i18nService.t("yes"),
|
2019-08-29 15:41:04 +02:00
|
|
|
this.i18nService.t("cancel"),
|
|
|
|
"warning"
|
|
|
|
);
|
|
|
|
if (!confirmed) {
|
2023-04-15 01:11:33 +02:00
|
|
|
this.form.controls.vaultTimeout.setValue(this.previousVaultTimeout);
|
2021-12-21 15:43:35 +01:00
|
|
|
return;
|
2019-02-13 05:53:04 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-06-25 00:19:55 +02:00
|
|
|
// The minTimeoutError does not apply to browser because it supports Immediately
|
|
|
|
// So only check for the policyError
|
2023-04-15 01:11:33 +02:00
|
|
|
if (this.form.controls.vaultTimeout.hasError("policyError")) {
|
2022-06-25 00:19:55 +02:00
|
|
|
this.platformUtilsService.showToast(
|
|
|
|
"error",
|
|
|
|
null,
|
|
|
|
this.i18nService.t("vaultTimeoutTooLarge")
|
|
|
|
);
|
2020-10-12 18:01:34 +02:00
|
|
|
return;
|
2020-10-09 17:16:15 +02:00
|
|
|
}
|
|
|
|
|
2023-04-15 01:11:33 +02:00
|
|
|
this.previousVaultTimeout = this.form.value.vaultTimeout;
|
2021-09-17 10:22:46 +02:00
|
|
|
|
2022-08-30 22:30:43 +02:00
|
|
|
await this.vaultTimeoutSettingsService.setVaultTimeoutOptions(
|
2023-04-15 01:11:33 +02:00
|
|
|
newValue,
|
|
|
|
this.form.value.vaultTimeoutAction
|
2020-04-06 17:40:16 +02:00
|
|
|
);
|
|
|
|
if (this.previousVaultTimeout == null) {
|
2018-10-04 04:46:11 +02:00
|
|
|
this.messagingService.send("bgReseedStorage");
|
2018-04-10 22:20:49 +02:00
|
|
|
}
|
2021-12-21 15:43:35 +01:00
|
|
|
}
|
|
|
|
|
2023-04-15 01:11:33 +02:00
|
|
|
async saveVaultTimeoutAction(newValue: VaultTimeoutAction) {
|
|
|
|
if (newValue === VaultTimeoutAction.LogOut) {
|
2018-04-10 22:20:49 +02:00
|
|
|
const confirmed = await this.platformUtilsService.showDialog(
|
|
|
|
this.i18nService.t("vaultTimeoutLogOutConfirmation"),
|
|
|
|
this.i18nService.t("vaultTimeoutLogOutConfirmationTitle"),
|
|
|
|
this.i18nService.t("yes"),
|
|
|
|
this.i18nService.t("cancel"),
|
2021-12-21 15:43:35 +01:00
|
|
|
"warning"
|
2018-04-10 22:20:49 +02:00
|
|
|
);
|
|
|
|
if (!confirmed) {
|
2023-04-15 01:11:33 +02:00
|
|
|
this.vaultTimeoutActionOptions.forEach((option: any, i) => {
|
|
|
|
if (option.value === this.form.value.vaultTimeoutAction) {
|
2018-04-10 22:20:49 +02:00
|
|
|
this.vaultTimeoutActionSelectRef.nativeElement.value =
|
2023-04-15 01:11:33 +02:00
|
|
|
i + ": " + this.form.value.vaultTimeoutAction;
|
2021-12-21 15:43:35 +01:00
|
|
|
}
|
2018-04-10 22:20:49 +02:00
|
|
|
});
|
2023-04-15 01:11:33 +02:00
|
|
|
this.form.controls.vaultTimeoutAction.patchValue(VaultTimeoutAction.Lock, {
|
|
|
|
emitEvent: false,
|
|
|
|
});
|
2021-12-21 15:43:35 +01:00
|
|
|
return;
|
2018-04-10 22:20:49 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-04-15 01:11:33 +02:00
|
|
|
if (this.form.controls.vaultTimeout.hasError("policyError")) {
|
2022-06-25 00:19:55 +02:00
|
|
|
this.platformUtilsService.showToast(
|
|
|
|
"error",
|
|
|
|
null,
|
|
|
|
this.i18nService.t("vaultTimeoutTooLarge")
|
|
|
|
);
|
2018-04-10 22:20:49 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-08-30 22:30:43 +02:00
|
|
|
await this.vaultTimeoutSettingsService.setVaultTimeoutOptions(
|
2023-04-15 01:11:33 +02:00
|
|
|
this.form.value.vaultTimeout,
|
|
|
|
newValue
|
2021-12-21 15:43:35 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2018-04-10 22:20:49 +02:00
|
|
|
async updatePin() {
|
2023-04-15 01:11:33 +02:00
|
|
|
if (this.form.value.pin) {
|
2018-04-10 22:20:49 +02:00
|
|
|
const ref = this.modalService.open(SetPinComponent, { allowMultipleModals: true });
|
2021-12-21 15:43:35 +01:00
|
|
|
|
2021-09-15 21:56:29 +02:00
|
|
|
if (ref == null) {
|
2023-04-15 01:11:33 +02:00
|
|
|
this.form.controls.pin.setValue(false);
|
2021-12-21 15:43:35 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-04-15 01:11:33 +02:00
|
|
|
this.form.controls.pin.setValue(await ref.onClosedPromise());
|
2018-04-10 22:20:49 +02:00
|
|
|
} else {
|
|
|
|
await this.cryptoService.clearPinProtectedKey();
|
2022-08-30 22:30:43 +02:00
|
|
|
await this.vaultTimeoutSettingsService.clear();
|
2018-04-10 22:20:49 +02:00
|
|
|
}
|
2021-12-21 15:43:35 +01:00
|
|
|
}
|
|
|
|
|
2018-04-10 22:20:49 +02:00
|
|
|
async updateBiometric() {
|
2023-04-15 01:11:33 +02:00
|
|
|
if (this.form.value.biometric && this.supportsBiometric) {
|
2021-03-10 21:27:05 +01:00
|
|
|
let granted;
|
2021-12-21 15:43:35 +01:00
|
|
|
try {
|
2018-04-17 19:19:58 +02:00
|
|
|
granted = await BrowserApi.requestPermission({ permissions: ["nativeMessaging"] });
|
|
|
|
} catch (e) {
|
2022-02-24 18:14:04 +01:00
|
|
|
// eslint-disable-next-line
|
2018-04-17 19:19:58 +02:00
|
|
|
console.error(e);
|
2021-12-21 15:43:35 +01:00
|
|
|
|
2018-04-17 19:19:58 +02:00
|
|
|
if (this.platformUtilsService.isFirefox() && this.popupUtilsService.inSidebar(window)) {
|
|
|
|
await this.platformUtilsService.showDialog(
|
2021-06-22 22:44:06 +02:00
|
|
|
this.i18nService.t("nativeMessaginPermissionSidebarDesc"),
|
|
|
|
this.i18nService.t("nativeMessaginPermissionSidebarTitle"),
|
2018-04-17 19:19:58 +02:00
|
|
|
this.i18nService.t("ok"),
|
2021-12-21 15:43:35 +01:00
|
|
|
null
|
2018-04-17 19:19:58 +02:00
|
|
|
);
|
2023-04-15 01:11:33 +02:00
|
|
|
this.form.controls.biometric.setValue(false);
|
2018-04-17 19:19:58 +02:00
|
|
|
return;
|
|
|
|
}
|
2021-12-21 15:43:35 +01:00
|
|
|
}
|
|
|
|
|
2021-03-10 21:27:05 +01:00
|
|
|
if (!granted) {
|
|
|
|
await this.platformUtilsService.showDialog(
|
|
|
|
this.i18nService.t("nativeMessaginPermissionErrorDesc"),
|
|
|
|
this.i18nService.t("nativeMessaginPermissionErrorTitle"),
|
|
|
|
this.i18nService.t("ok"),
|
2021-12-21 15:43:35 +01:00
|
|
|
null
|
|
|
|
);
|
2023-04-15 01:11:33 +02:00
|
|
|
this.form.controls.biometric.setValue(false);
|
2021-12-21 15:43:35 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-10-09 17:16:15 +02:00
|
|
|
const submitted = Swal.fire({
|
|
|
|
heightAuto: false,
|
|
|
|
buttonsStyling: false,
|
2021-05-13 21:22:49 +02:00
|
|
|
titleText: this.i18nService.t("awaitDesktop"),
|
2020-10-12 18:01:34 +02:00
|
|
|
text: this.i18nService.t("awaitDesktopDesc"),
|
|
|
|
icon: "info",
|
2022-01-28 11:53:06 +01:00
|
|
|
iconHtml: '<i class="swal-custom-icon bwi bwi-info-circle text-info"></i>',
|
2020-10-09 17:16:15 +02:00
|
|
|
showCancelButton: true,
|
|
|
|
cancelButtonText: this.i18nService.t("cancel"),
|
|
|
|
showConfirmButton: false,
|
2020-10-12 18:01:34 +02:00
|
|
|
allowOutsideClick: false,
|
2021-12-21 15:43:35 +01:00
|
|
|
});
|
|
|
|
|
2022-01-27 22:22:51 +01:00
|
|
|
await this.stateService.setBiometricAwaitingAcceptance(true);
|
2020-10-12 18:01:34 +02:00
|
|
|
await this.cryptoService.toggleKey();
|
2021-12-21 15:43:35 +01:00
|
|
|
|
2020-10-12 18:01:34 +02:00
|
|
|
await Promise.race([
|
2022-01-27 22:22:51 +01:00
|
|
|
submitted.then(async (result) => {
|
2020-10-12 18:01:34 +02:00
|
|
|
if (result.dismiss === Swal.DismissReason.cancel) {
|
2023-04-15 01:11:33 +02:00
|
|
|
this.form.controls.biometric.setValue(false);
|
2022-01-27 22:22:51 +01:00
|
|
|
await this.stateService.setBiometricAwaitingAcceptance(null);
|
2021-12-21 15:43:35 +01:00
|
|
|
}
|
|
|
|
}),
|
2020-09-15 16:50:45 +02:00
|
|
|
this.platformUtilsService
|
2021-03-02 19:31:52 +01:00
|
|
|
.authenticateBiometric()
|
|
|
|
.then((result) => {
|
2023-04-15 01:11:33 +02:00
|
|
|
this.form.controls.biometric.setValue(result);
|
2021-12-21 15:43:35 +01:00
|
|
|
|
2020-10-12 18:01:34 +02:00
|
|
|
Swal.close();
|
2023-04-15 01:11:33 +02:00
|
|
|
if (this.form.value.biometric === false) {
|
2020-10-21 17:18:04 +02:00
|
|
|
this.platformUtilsService.showToast(
|
2021-12-21 15:43:35 +01:00
|
|
|
"error",
|
2020-10-21 17:18:04 +02:00
|
|
|
this.i18nService.t("errorEnableBiometricTitle"),
|
|
|
|
this.i18nService.t("errorEnableBiometricDesc")
|
2021-12-21 15:43:35 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
})
|
2021-03-02 19:31:52 +01:00
|
|
|
.catch((e) => {
|
2020-11-30 13:41:08 +01:00
|
|
|
// Handle connection errors
|
2023-04-15 01:11:33 +02:00
|
|
|
this.form.controls.biometric.setValue(false);
|
2022-03-15 13:13:39 +01:00
|
|
|
|
|
|
|
const error = BiometricErrors[e as BiometricErrorTypes];
|
|
|
|
|
|
|
|
this.platformUtilsService.showDialog(
|
|
|
|
this.i18nService.t(error.description),
|
|
|
|
this.i18nService.t(error.title),
|
|
|
|
this.i18nService.t("ok"),
|
|
|
|
null,
|
|
|
|
"error"
|
|
|
|
);
|
2021-12-21 15:43:35 +01:00
|
|
|
}),
|
|
|
|
]);
|
|
|
|
} else {
|
2022-01-27 22:22:51 +01:00
|
|
|
await this.stateService.setBiometricUnlock(null);
|
2022-08-05 20:04:27 +02:00
|
|
|
await this.stateService.setBiometricFingerprintValidated(false);
|
2018-04-17 19:19:58 +02:00
|
|
|
}
|
2021-12-21 15:43:35 +01:00
|
|
|
}
|
|
|
|
|
2021-09-17 10:22:46 +02:00
|
|
|
async updateAutoBiometricsPrompt() {
|
2023-04-15 01:11:33 +02:00
|
|
|
await this.stateService.setDisableAutoBiometricsPrompt(
|
|
|
|
!this.form.value.enableAutoBiometricsPrompt
|
|
|
|
);
|
2021-12-21 15:43:35 +01:00
|
|
|
}
|
|
|
|
|
2018-04-10 22:20:49 +02:00
|
|
|
async lock() {
|
2022-08-25 19:09:27 +02:00
|
|
|
await this.vaultTimeoutService.lock();
|
2021-12-21 15:43:35 +01:00
|
|
|
}
|
|
|
|
|
2018-04-17 19:19:58 +02:00
|
|
|
async logOut() {
|
2021-07-23 22:32:42 +02:00
|
|
|
const confirmed = await this.platformUtilsService.showDialog(
|
|
|
|
this.i18nService.t("logOutConfirmation"),
|
2023-04-15 01:11:33 +02:00
|
|
|
this.i18nService.t(VaultTimeoutAction.LogOut),
|
2018-04-10 22:20:49 +02:00
|
|
|
this.i18nService.t("yes"),
|
2018-04-17 19:19:58 +02:00
|
|
|
this.i18nService.t("cancel")
|
2021-07-23 22:32:42 +02:00
|
|
|
);
|
2018-04-17 19:19:58 +02:00
|
|
|
if (confirmed) {
|
2018-06-25 14:06:38 +02:00
|
|
|
this.messagingService.send("logout");
|
2018-04-10 22:20:49 +02:00
|
|
|
}
|
2021-12-21 15:43:35 +01:00
|
|
|
}
|
|
|
|
|
2018-04-10 22:20:49 +02:00
|
|
|
async changePassword() {
|
2018-10-04 04:46:11 +02:00
|
|
|
const confirmed = await this.platformUtilsService.showDialog(
|
2018-04-10 22:20:49 +02:00
|
|
|
this.i18nService.t("changeMasterPasswordConfirmation"),
|
|
|
|
this.i18nService.t("changeMasterPassword"),
|
|
|
|
this.i18nService.t("yes"),
|
2020-03-04 17:42:21 +01:00
|
|
|
this.i18nService.t("cancel")
|
2021-12-21 15:43:35 +01:00
|
|
|
);
|
2018-04-10 22:20:49 +02:00
|
|
|
if (confirmed) {
|
2022-02-09 00:44:56 +01:00
|
|
|
BrowserApi.createNewTab(
|
|
|
|
"https://bitwarden.com/help/master-password/#change-your-master-password"
|
|
|
|
);
|
2018-04-10 22:20:49 +02:00
|
|
|
}
|
2021-12-21 15:43:35 +01:00
|
|
|
}
|
|
|
|
|
2018-04-14 04:18:21 +02:00
|
|
|
async twoStep() {
|
|
|
|
const confirmed = await this.platformUtilsService.showDialog(
|
2018-04-10 22:20:49 +02:00
|
|
|
this.i18nService.t("twoStepLoginConfirmation"),
|
|
|
|
this.i18nService.t("twoStepLogin"),
|
|
|
|
this.i18nService.t("yes"),
|
2020-03-04 17:42:21 +01:00
|
|
|
this.i18nService.t("cancel")
|
2021-12-21 15:43:35 +01:00
|
|
|
);
|
2018-04-17 19:19:58 +02:00
|
|
|
if (confirmed) {
|
2022-02-09 00:44:56 +01:00
|
|
|
BrowserApi.createNewTab("https://bitwarden.com/help/setup-two-step-login/");
|
2018-04-14 04:18:21 +02:00
|
|
|
}
|
2021-12-21 15:43:35 +01:00
|
|
|
}
|
|
|
|
|
2018-04-12 23:28:33 +02:00
|
|
|
async share() {
|
2018-10-04 04:46:11 +02:00
|
|
|
const confirmed = await this.platformUtilsService.showDialog(
|
2020-03-04 17:42:21 +01:00
|
|
|
this.i18nService.t("learnOrgConfirmation"),
|
|
|
|
this.i18nService.t("learnOrg"),
|
2018-04-10 22:20:49 +02:00
|
|
|
this.i18nService.t("yes"),
|
2018-04-12 23:28:33 +02:00
|
|
|
this.i18nService.t("cancel")
|
2021-12-21 15:43:35 +01:00
|
|
|
);
|
2018-04-17 19:19:58 +02:00
|
|
|
if (confirmed) {
|
2022-02-09 00:44:56 +01:00
|
|
|
BrowserApi.createNewTab("https://bitwarden.com/help/about-organizations/");
|
2018-04-12 23:28:33 +02:00
|
|
|
}
|
2021-12-21 15:43:35 +01:00
|
|
|
}
|
|
|
|
|
2020-04-06 17:40:16 +02:00
|
|
|
async webVault() {
|
|
|
|
const url = this.environmentService.getWebVaultUrl();
|
2020-03-03 14:48:11 +01:00
|
|
|
BrowserApi.createNewTab(url);
|
2021-12-21 15:43:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
import() {
|
2022-02-09 00:44:56 +01:00
|
|
|
BrowserApi.createNewTab("https://bitwarden.com/help/import-data/");
|
2021-12-21 15:43:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export() {
|
2018-04-14 04:18:21 +02:00
|
|
|
this.router.navigate(["/export"]);
|
2021-12-21 15:43:35 +01:00
|
|
|
}
|
|
|
|
|
2018-04-12 23:28:33 +02:00
|
|
|
about() {
|
2022-09-08 14:27:19 +02:00
|
|
|
this.modalService.open(AboutComponent);
|
2021-12-21 15:43:35 +01:00
|
|
|
}
|
|
|
|
|
2018-11-16 17:08:36 +01:00
|
|
|
async fingerprint() {
|
2022-01-27 22:22:51 +01:00
|
|
|
const fingerprint = await this.cryptoService.getFingerprint(
|
|
|
|
await this.stateService.getUserId()
|
|
|
|
);
|
2018-11-16 17:08:36 +01:00
|
|
|
const p = document.createElement("p");
|
|
|
|
p.innerText = this.i18nService.t("yourAccountsFingerprint") + ":";
|
|
|
|
const p2 = document.createElement("p");
|
|
|
|
p2.innerText = fingerprint.join("-");
|
|
|
|
const div = document.createElement("div");
|
|
|
|
div.appendChild(p);
|
|
|
|
div.appendChild(p2);
|
2021-12-21 15:43:35 +01:00
|
|
|
|
2020-03-04 17:42:21 +01:00
|
|
|
const result = await Swal.fire({
|
|
|
|
heightAuto: false,
|
|
|
|
buttonsStyling: false,
|
|
|
|
html: div,
|
|
|
|
showCancelButton: true,
|
|
|
|
cancelButtonText: this.i18nService.t("close"),
|
|
|
|
showConfirmButton: true,
|
|
|
|
confirmButtonText: this.i18nService.t("learnMore"),
|
2018-04-12 23:28:33 +02:00
|
|
|
});
|
2021-12-21 15:43:35 +01:00
|
|
|
|
2020-03-04 17:42:21 +01:00
|
|
|
if (result.value) {
|
2022-02-09 00:44:56 +01:00
|
|
|
this.platformUtilsService.launchUri("https://bitwarden.com/help/fingerprint-phrase/");
|
2018-04-12 23:28:33 +02:00
|
|
|
}
|
2021-12-21 15:43:35 +01:00
|
|
|
}
|
2018-04-12 23:28:33 +02:00
|
|
|
|
2018-11-16 17:08:36 +01:00
|
|
|
rate() {
|
|
|
|
const deviceType = this.platformUtilsService.getDevice();
|
2020-03-03 14:48:11 +01:00
|
|
|
BrowserApi.createNewTab((RateUrls as any)[deviceType]);
|
2018-04-10 22:20:49 +02:00
|
|
|
}
|
2023-04-15 01:11:33 +02:00
|
|
|
|
|
|
|
ngOnDestroy() {
|
|
|
|
this.destroy$.next();
|
|
|
|
this.destroy$.complete();
|
|
|
|
}
|
2018-04-10 22:20:49 +02:00
|
|
|
}
|