1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-09-29 04:17:41 +02:00
bitwarden-browser/apps/browser/src/popup/settings/settings.component.ts

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

417 lines
14 KiB
TypeScript
Raw Normal View History

2018-04-10 22:20:49 +02:00
import { Component, ElementRef, OnInit, ViewChild } from "@angular/core";
import { UntypedFormControl } from "@angular/forms";
2018-04-10 22:20:49 +02:00
import { Router } from "@angular/router";
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 { KeyConnectorService } from "@bitwarden/common/abstractions/keyConnector.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";
import { VaultTimeoutService } from "@bitwarden/common/abstractions/vaultTimeout/vaultTimeout.service";
import { VaultTimeoutSettingsService } from "@bitwarden/common/abstractions/vaultTimeout/vaultTimeoutSettings.service";
2022-06-14 17:10:53 +02:00
import { DeviceType } from "@bitwarden/common/enums/deviceType";
2022-02-24 18:14:04 +01:00
import { BrowserApi } from "../../browser/browserApi";
import { BiometricErrors, BiometricErrorTypes } from "../../models/biometricErrors";
import { SetPinComponent } from "../components/set-pin.component";
2022-02-24 18:14:04 +01:00
import { PopupUtilsService } from "../services/popup-utils.service";
SM-90: Add Server Version to Browser About Page (#3223) * Add structure to display server version on browser * Add getConfig to State Service interface * Clean up settings component code * Switch to ServerConfig, use Observables in the ConfigService, and more * Fix runtime error * Sm 90 addison (#3275) * Use await instead of then * Rename stateServerConfig -> storedServerConfig * Move config validation logic to the model * Use implied check for undefined * Rename getStateServicerServerConfig -> buildServerConfig * Rename getApiServiceServerConfig -> pollServerConfig * Build server config in async * small fixes and add last seen text * Move config server to /config folder * Update with concatMap and other changes * Config project updates * Rename fileds to convention and remove unneeded migration * Update libs/common/src/services/state.service.ts Update based on Oscar's recommendation Co-authored-by: Oscar Hinton <Hinton@users.noreply.github.com> * Update options for Oscar's rec * Rename abstractions to abstracitons * Fix null issues and add options * Combine classes into one file, per Oscar's rec * Add null checking * Fix dependency issue * Add null checks, await, and fix date issue * Remove unneeded null check * In progress commit, unsuitable for for more than dev env, just backing up changes made with Oscar * Fix temp code to force last seen state * Add localization and escapes in the browser about section * Call complete on destroy subject rather than unsubscribe * use mediumDate and formatDate for the last seen date messaging * Add ThirdPartyServerName in example * Add deprecated note per Oscar's comment * [SM-90] Change to using a modal for browser about (#3417) * Fix inconsistent constructor null checking * ServerConfig can be null, fixes this * Switch to call super first, as required * remove unneeded null checks * Remove null checks from server-config.data.ts class * Update via PR comments and add back needed null check in server conf obj * Remove type annotation from serverConfig$ * Update self-hosted to be <small> per design decision * Re-fetch config every hour * Make third party server version <small> and change wording per Oscar's PR comment * Add expiresSoon function and re-fetch if the serverConfig will expire soon (older than 18 hours) * Fix misaligned small third party server message text Co-authored-by: Addison Beck <addisonbeck1@gmail.com> Co-authored-by: Oscar Hinton <Hinton@users.noreply.github.com>
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]:
"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",
})
// eslint-disable-next-line rxjs-angular/prefer-takeuntil
2018-04-10 22:20:49 +02:00
export class SettingsComponent implements OnInit {
@ViewChild("vaultTimeoutActionSelect", { read: ElementRef, static: true })
vaultTimeoutActionSelectRef: ElementRef;
vaultTimeouts: any[];
vaultTimeoutActions: any[];
vaultTimeoutAction: string;
2019-02-13 05:53:04 +01:00
pin: boolean = null;
2021-01-25 21:23:18 +01:00
supportsBiometric: boolean;
2022-02-24 18:14:04 +01:00
biometric = false;
enableAutoBiometricsPrompt = true;
previousVaultTimeout: number = null;
showChangeMasterPass = true;
2021-12-21 15:43:35 +01:00
vaultTimeout: UntypedFormControl = new UntypedFormControl(null);
2021-12-21 15:43:35 +01:00
2018-04-10 22:20:49 +02:00
constructor(
private platformUtilsService: PlatformUtilsService,
private i18nService: I18nService,
private vaultTimeoutService: VaultTimeoutService,
private vaultTimeoutSettingsService: VaultTimeoutSettingsService,
public messagingService: MessagingService,
private router: Router,
private environmentService: EnvironmentService,
private cryptoService: CryptoService,
[Account Switching] Base changes for account switching (#2250) * Pull in jslib * Create new state models * Create browser specific stateService * Remove registration deprecated services, register stateService * Replace usage of deprecated services (user, constants) * Add missing properties to BrowserGroupingsComponentState * Remove StorageService from initFactory * Clear the correct state * Add null check when restoring send-grouping state * add remember email * Initialize stateservice in services.module * Fix 'lock now' not working * Comment to remove setting defaults on install * Pull jslib * Remove setting defaults on install * Bump jslib * Pass the current userId to services when logging out * Bump jslib * Override vaultTimeout default on account addition * Pull latest jslib * Retrieve vaultTimeout from stateService * Record activity per Account * Add userId to logout and add fallback if not present * Register AccountFactory * Pass userId in messages * Base changes for account switching di fixes (#2280) * [bug] Null checks on Account init * [bug] Use same stateService instance for all operations We override the stateService in browser, but currently don't pull the background service into popup and allow jslib to create its own instance of the base StateService for jslib services. This causes a split in in memory state between the three isntances that results in many errors, namely locking not working. * [chore] Update jslib * Pull in jslib * Pull in jslib * Pull in latest jslib to multiple stateservice inits * Check vault states before executing processReload * Adjust iterator * Update native messaging to include the userId (#2290) * Re-Add UserVerificationService * Fix email not being remembered by base component * Improve readability of reloadProcess * Removed unneeded null check * Fix constructor dependency (stateService) * Added missing await * Simplify dependency registration * Fixed typos * Reverted back to simple loop * Use vaultTimeoutService to retrieve Timeout Co-authored-by: Addison Beck <abeck@bitwarden.com> Co-authored-by: Oscar Hinton <oscar@oscarhinton.com>
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,
private keyConnectorService: KeyConnectorService
2021-12-21 15:43:35 +01:00
) {}
2018-04-10 22:20:49 +02:00
async ngOnInit() {
2020-09-15 16:50:45 +02:00
const showOnLocked =
!this.platformUtilsService.isFirefox() && !this.platformUtilsService.isSafari();
2021-12-21 15:43:35 +01:00
this.vaultTimeouts = [
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
];
if (showOnLocked) {
this.vaultTimeouts.push({ name: this.i18nService.t("onLocked"), value: -2 });
2018-04-10 22:20:49 +02:00
}
this.vaultTimeouts.push({ name: this.i18nService.t("onRestart"), value: -1 });
this.vaultTimeouts.push({ name: this.i18nService.t("never"), value: null });
2021-09-14 13:36:34 +02:00
this.vaultTimeoutActions = [
{ name: this.i18nService.t("lock"), value: "lock" },
{ name: this.i18nService.t("logOut"), value: "logOut" },
];
2019-02-13 05:53:04 +01:00
let timeout = await this.vaultTimeoutSettingsService.getVaultTimeout();
if (timeout != null) {
if (timeout === -2 && !showOnLocked) {
timeout = -1;
2021-12-21 15:43:35 +01:00
}
this.vaultTimeout.setValue(timeout);
2018-04-10 22:20:49 +02:00
}
2021-09-14 13:36:34 +02:00
this.previousVaultTimeout = this.vaultTimeout.value;
// eslint-disable-next-line rxjs-angular/prefer-takeuntil, rxjs/no-async-subscribe
this.vaultTimeout.valueChanges.subscribe(async (value) => {
await this.saveVaultTimeout(value);
2021-12-21 15:43:35 +01:00
});
[Account Switching] Base changes for account switching (#2250) * Pull in jslib * Create new state models * Create browser specific stateService * Remove registration deprecated services, register stateService * Replace usage of deprecated services (user, constants) * Add missing properties to BrowserGroupingsComponentState * Remove StorageService from initFactory * Clear the correct state * Add null check when restoring send-grouping state * add remember email * Initialize stateservice in services.module * Fix 'lock now' not working * Comment to remove setting defaults on install * Pull jslib * Remove setting defaults on install * Bump jslib * Pass the current userId to services when logging out * Bump jslib * Override vaultTimeout default on account addition * Pull latest jslib * Retrieve vaultTimeout from stateService * Record activity per Account * Add userId to logout and add fallback if not present * Register AccountFactory * Pass userId in messages * Base changes for account switching di fixes (#2280) * [bug] Null checks on Account init * [bug] Use same stateService instance for all operations We override the stateService in browser, but currently don't pull the background service into popup and allow jslib to create its own instance of the base StateService for jslib services. This causes a split in in memory state between the three isntances that results in many errors, namely locking not working. * [chore] Update jslib * Pull in jslib * Pull in jslib * Pull in latest jslib to multiple stateservice inits * Check vault states before executing processReload * Adjust iterator * Update native messaging to include the userId (#2290) * Re-Add UserVerificationService * Fix email not being remembered by base component * Improve readability of reloadProcess * Removed unneeded null check * Fix constructor dependency (stateService) * Added missing await * Simplify dependency registration * Fixed typos * Reverted back to simple loop * Use vaultTimeoutService to retrieve Timeout Co-authored-by: Addison Beck <abeck@bitwarden.com> Co-authored-by: Oscar Hinton <oscar@oscarhinton.com>
2022-01-27 22:22:51 +01:00
const action = await this.stateService.getVaultTimeoutAction();
2021-09-14 13:36:34 +02:00
this.vaultTimeoutAction = action == null ? "lock" : action;
2021-12-21 15:43:35 +01:00
const pinSet = await this.vaultTimeoutSettingsService.isPinLockSet();
this.pin = pinSet[0] || pinSet[1];
2021-12-21 15:43:35 +01:00
2021-09-14 13:36:34 +02:00
this.supportsBiometric = await this.platformUtilsService.supportsBiometric();
this.biometric = await this.vaultTimeoutSettingsService.isBiometricLockSet();
this.enableAutoBiometricsPrompt = !(await this.stateService.getDisableAutoBiometricsPrompt());
2021-12-07 20:42:18 +01:00
this.showChangeMasterPass = !(await this.keyConnectorService.getUsesKeyConnector());
2021-09-14 13:36:34 +02:00
}
2021-12-21 15:43:35 +01:00
async saveVaultTimeout(newValue: number) {
2019-02-13 05:53:04 +01:00
if (newValue == null) {
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,
this.i18nService.t("yes"),
2019-08-29 15:41:04 +02:00
this.i18nService.t("cancel"),
"warning"
);
if (!confirmed) {
this.vaultTimeout.setValue(this.previousVaultTimeout);
2021-12-21 15:43:35 +01:00
return;
2019-02-13 05:53:04 +01:00
}
}
// The minTimeoutError does not apply to browser because it supports Immediately
// So only check for the policyError
if (this.vaultTimeout.hasError("policyError")) {
this.platformUtilsService.showToast(
"error",
null,
this.i18nService.t("vaultTimeoutTooLarge")
);
return;
}
this.previousVaultTimeout = this.vaultTimeout.value;
await this.vaultTimeoutSettingsService.setVaultTimeoutOptions(
this.vaultTimeout.value,
this.vaultTimeoutAction
);
if (this.previousVaultTimeout == null) {
this.messagingService.send("bgReseedStorage");
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 saveVaultTimeoutAction(newValue: string) {
if (newValue === "logOut") {
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) {
this.vaultTimeoutActions.forEach((option: any, i) => {
if (option.value === this.vaultTimeoutAction) {
2018-04-10 22:20:49 +02:00
this.vaultTimeoutActionSelectRef.nativeElement.value =
i + ": " + this.vaultTimeoutAction;
2021-12-21 15:43:35 +01:00
}
2018-04-10 22:20:49 +02:00
});
2021-12-21 15:43:35 +01:00
return;
2018-04-10 22:20:49 +02:00
}
}
if (this.vaultTimeout.hasError("policyError")) {
this.platformUtilsService.showToast(
"error",
null,
this.i18nService.t("vaultTimeoutTooLarge")
);
2018-04-10 22:20:49 +02:00
return;
}
this.vaultTimeoutAction = newValue;
await this.vaultTimeoutSettingsService.setVaultTimeoutOptions(
2021-09-14 13:36:34 +02:00
this.vaultTimeout.value,
this.vaultTimeoutAction
2021-12-21 15:43:35 +01:00
);
}
2018-04-10 22:20:49 +02:00
async updatePin() {
if (this.pin) {
const ref = this.modalService.open(SetPinComponent, { allowMultipleModals: true });
2021-12-21 15:43:35 +01:00
if (ref == null) {
2018-04-10 22:20:49 +02:00
this.pin = false;
2021-12-21 15:43:35 +01:00
return;
}
2018-04-10 22:20:49 +02:00
this.pin = await ref.onClosedPromise();
} else {
await this.cryptoService.clearPinProtectedKey();
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() {
2021-01-25 21:23:18 +01:00
if (this.biometric && this.supportsBiometric) {
let granted;
2021-12-21 15:43:35 +01:00
try {
granted = await BrowserApi.requestPermission({ permissions: ["nativeMessaging"] });
} catch (e) {
2022-02-24 18:14:04 +01:00
// eslint-disable-next-line
console.error(e);
2021-12-21 15:43:35 +01:00
if (this.platformUtilsService.isFirefox() && this.popupUtilsService.inSidebar(window)) {
await this.platformUtilsService.showDialog(
this.i18nService.t("nativeMessaginPermissionSidebarDesc"),
this.i18nService.t("nativeMessaginPermissionSidebarTitle"),
this.i18nService.t("ok"),
2021-12-21 15:43:35 +01:00
null
);
this.biometric = false;
return;
}
2021-12-21 15:43:35 +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
);
this.biometric = false;
2021-12-21 15:43:35 +01:00
return;
}
const submitted = Swal.fire({
heightAuto: false,
buttonsStyling: false,
titleText: this.i18nService.t("awaitDesktop"),
text: this.i18nService.t("awaitDesktopDesc"),
icon: "info",
iconHtml: '<i class="swal-custom-icon bwi bwi-info-circle text-info"></i>',
showCancelButton: true,
cancelButtonText: this.i18nService.t("cancel"),
showConfirmButton: false,
allowOutsideClick: false,
2021-12-21 15:43:35 +01:00
});
[Account Switching] Base changes for account switching (#2250) * Pull in jslib * Create new state models * Create browser specific stateService * Remove registration deprecated services, register stateService * Replace usage of deprecated services (user, constants) * Add missing properties to BrowserGroupingsComponentState * Remove StorageService from initFactory * Clear the correct state * Add null check when restoring send-grouping state * add remember email * Initialize stateservice in services.module * Fix 'lock now' not working * Comment to remove setting defaults on install * Pull jslib * Remove setting defaults on install * Bump jslib * Pass the current userId to services when logging out * Bump jslib * Override vaultTimeout default on account addition * Pull latest jslib * Retrieve vaultTimeout from stateService * Record activity per Account * Add userId to logout and add fallback if not present * Register AccountFactory * Pass userId in messages * Base changes for account switching di fixes (#2280) * [bug] Null checks on Account init * [bug] Use same stateService instance for all operations We override the stateService in browser, but currently don't pull the background service into popup and allow jslib to create its own instance of the base StateService for jslib services. This causes a split in in memory state between the three isntances that results in many errors, namely locking not working. * [chore] Update jslib * Pull in jslib * Pull in jslib * Pull in latest jslib to multiple stateservice inits * Check vault states before executing processReload * Adjust iterator * Update native messaging to include the userId (#2290) * Re-Add UserVerificationService * Fix email not being remembered by base component * Improve readability of reloadProcess * Removed unneeded null check * Fix constructor dependency (stateService) * Added missing await * Simplify dependency registration * Fixed typos * Reverted back to simple loop * Use vaultTimeoutService to retrieve Timeout Co-authored-by: Addison Beck <abeck@bitwarden.com> Co-authored-by: Oscar Hinton <oscar@oscarhinton.com>
2022-01-27 22:22:51 +01:00
await this.stateService.setBiometricAwaitingAcceptance(true);
await this.cryptoService.toggleKey();
2021-12-21 15:43:35 +01:00
await Promise.race([
[Account Switching] Base changes for account switching (#2250) * Pull in jslib * Create new state models * Create browser specific stateService * Remove registration deprecated services, register stateService * Replace usage of deprecated services (user, constants) * Add missing properties to BrowserGroupingsComponentState * Remove StorageService from initFactory * Clear the correct state * Add null check when restoring send-grouping state * add remember email * Initialize stateservice in services.module * Fix 'lock now' not working * Comment to remove setting defaults on install * Pull jslib * Remove setting defaults on install * Bump jslib * Pass the current userId to services when logging out * Bump jslib * Override vaultTimeout default on account addition * Pull latest jslib * Retrieve vaultTimeout from stateService * Record activity per Account * Add userId to logout and add fallback if not present * Register AccountFactory * Pass userId in messages * Base changes for account switching di fixes (#2280) * [bug] Null checks on Account init * [bug] Use same stateService instance for all operations We override the stateService in browser, but currently don't pull the background service into popup and allow jslib to create its own instance of the base StateService for jslib services. This causes a split in in memory state between the three isntances that results in many errors, namely locking not working. * [chore] Update jslib * Pull in jslib * Pull in jslib * Pull in latest jslib to multiple stateservice inits * Check vault states before executing processReload * Adjust iterator * Update native messaging to include the userId (#2290) * Re-Add UserVerificationService * Fix email not being remembered by base component * Improve readability of reloadProcess * Removed unneeded null check * Fix constructor dependency (stateService) * Added missing await * Simplify dependency registration * Fixed typos * Reverted back to simple loop * Use vaultTimeoutService to retrieve Timeout Co-authored-by: Addison Beck <abeck@bitwarden.com> Co-authored-by: Oscar Hinton <oscar@oscarhinton.com>
2022-01-27 22:22:51 +01:00
submitted.then(async (result) => {
if (result.dismiss === Swal.DismissReason.cancel) {
this.biometric = false;
[Account Switching] Base changes for account switching (#2250) * Pull in jslib * Create new state models * Create browser specific stateService * Remove registration deprecated services, register stateService * Replace usage of deprecated services (user, constants) * Add missing properties to BrowserGroupingsComponentState * Remove StorageService from initFactory * Clear the correct state * Add null check when restoring send-grouping state * add remember email * Initialize stateservice in services.module * Fix 'lock now' not working * Comment to remove setting defaults on install * Pull jslib * Remove setting defaults on install * Bump jslib * Pass the current userId to services when logging out * Bump jslib * Override vaultTimeout default on account addition * Pull latest jslib * Retrieve vaultTimeout from stateService * Record activity per Account * Add userId to logout and add fallback if not present * Register AccountFactory * Pass userId in messages * Base changes for account switching di fixes (#2280) * [bug] Null checks on Account init * [bug] Use same stateService instance for all operations We override the stateService in browser, but currently don't pull the background service into popup and allow jslib to create its own instance of the base StateService for jslib services. This causes a split in in memory state between the three isntances that results in many errors, namely locking not working. * [chore] Update jslib * Pull in jslib * Pull in jslib * Pull in latest jslib to multiple stateservice inits * Check vault states before executing processReload * Adjust iterator * Update native messaging to include the userId (#2290) * Re-Add UserVerificationService * Fix email not being remembered by base component * Improve readability of reloadProcess * Removed unneeded null check * Fix constructor dependency (stateService) * Added missing await * Simplify dependency registration * Fixed typos * Reverted back to simple loop * Use vaultTimeoutService to retrieve Timeout Co-authored-by: Addison Beck <abeck@bitwarden.com> Co-authored-by: Oscar Hinton <oscar@oscarhinton.com>
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) => {
this.biometric = result;
2021-12-21 15:43:35 +01:00
Swal.close();
if (this.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) => {
// Handle connection errors
this.biometric = false;
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 {
[Account Switching] Base changes for account switching (#2250) * Pull in jslib * Create new state models * Create browser specific stateService * Remove registration deprecated services, register stateService * Replace usage of deprecated services (user, constants) * Add missing properties to BrowserGroupingsComponentState * Remove StorageService from initFactory * Clear the correct state * Add null check when restoring send-grouping state * add remember email * Initialize stateservice in services.module * Fix 'lock now' not working * Comment to remove setting defaults on install * Pull jslib * Remove setting defaults on install * Bump jslib * Pass the current userId to services when logging out * Bump jslib * Override vaultTimeout default on account addition * Pull latest jslib * Retrieve vaultTimeout from stateService * Record activity per Account * Add userId to logout and add fallback if not present * Register AccountFactory * Pass userId in messages * Base changes for account switching di fixes (#2280) * [bug] Null checks on Account init * [bug] Use same stateService instance for all operations We override the stateService in browser, but currently don't pull the background service into popup and allow jslib to create its own instance of the base StateService for jslib services. This causes a split in in memory state between the three isntances that results in many errors, namely locking not working. * [chore] Update jslib * Pull in jslib * Pull in jslib * Pull in latest jslib to multiple stateservice inits * Check vault states before executing processReload * Adjust iterator * Update native messaging to include the userId (#2290) * Re-Add UserVerificationService * Fix email not being remembered by base component * Improve readability of reloadProcess * Removed unneeded null check * Fix constructor dependency (stateService) * Added missing await * Simplify dependency registration * Fixed typos * Reverted back to simple loop * Use vaultTimeoutService to retrieve Timeout Co-authored-by: Addison Beck <abeck@bitwarden.com> Co-authored-by: Oscar Hinton <oscar@oscarhinton.com>
2022-01-27 22:22:51 +01:00
await this.stateService.setBiometricUnlock(null);
await this.stateService.setBiometricFingerprintValidated(false);
}
2021-12-21 15:43:35 +01:00
}
async updateAutoBiometricsPrompt() {
await this.stateService.setDisableAutoBiometricsPrompt(!this.enableAutoBiometricsPrompt);
2021-12-21 15:43:35 +01:00
}
2018-04-10 22:20:49 +02:00
async lock() {
await this.vaultTimeoutService.lock();
2021-12-21 15:43:35 +01:00
}
async logOut() {
const confirmed = await this.platformUtilsService.showDialog(
this.i18nService.t("logOutConfirmation"),
this.i18nService.t("logOut"),
2018-04-10 22:20:49 +02:00
this.i18nService.t("yes"),
this.i18nService.t("cancel")
);
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() {
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"),
this.i18nService.t("cancel")
2021-12-21 15:43:35 +01:00
);
2018-04-10 22:20:49 +02:00
if (confirmed) {
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"),
this.i18nService.t("cancel")
2021-12-21 15:43:35 +01:00
);
if (confirmed) {
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() {
const confirmed = await this.platformUtilsService.showDialog(
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
);
if (confirmed) {
BrowserApi.createNewTab("https://bitwarden.com/help/about-organizations/");
2018-04-12 23:28:33 +02:00
}
2021-12-21 15:43:35 +01:00
}
async webVault() {
const url = this.environmentService.getWebVaultUrl();
BrowserApi.createNewTab(url);
2021-12-21 15:43:35 +01:00
}
import() {
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
}
help() {
BrowserApi.createNewTab("https://bitwarden.com/help/");
2021-12-21 15:43:35 +01:00
}
2018-04-12 23:28:33 +02:00
about() {
SM-90: Add Server Version to Browser About Page (#3223) * Add structure to display server version on browser * Add getConfig to State Service interface * Clean up settings component code * Switch to ServerConfig, use Observables in the ConfigService, and more * Fix runtime error * Sm 90 addison (#3275) * Use await instead of then * Rename stateServerConfig -> storedServerConfig * Move config validation logic to the model * Use implied check for undefined * Rename getStateServicerServerConfig -> buildServerConfig * Rename getApiServiceServerConfig -> pollServerConfig * Build server config in async * small fixes and add last seen text * Move config server to /config folder * Update with concatMap and other changes * Config project updates * Rename fileds to convention and remove unneeded migration * Update libs/common/src/services/state.service.ts Update based on Oscar's recommendation Co-authored-by: Oscar Hinton <Hinton@users.noreply.github.com> * Update options for Oscar's rec * Rename abstractions to abstracitons * Fix null issues and add options * Combine classes into one file, per Oscar's rec * Add null checking * Fix dependency issue * Add null checks, await, and fix date issue * Remove unneeded null check * In progress commit, unsuitable for for more than dev env, just backing up changes made with Oscar * Fix temp code to force last seen state * Add localization and escapes in the browser about section * Call complete on destroy subject rather than unsubscribe * use mediumDate and formatDate for the last seen date messaging * Add ThirdPartyServerName in example * Add deprecated note per Oscar's comment * [SM-90] Change to using a modal for browser about (#3417) * Fix inconsistent constructor null checking * ServerConfig can be null, fixes this * Switch to call super first, as required * remove unneeded null checks * Remove null checks from server-config.data.ts class * Update via PR comments and add back needed null check in server conf obj * Remove type annotation from serverConfig$ * Update self-hosted to be <small> per design decision * Re-fetch config every hour * Make third party server version <small> and change wording per Oscar's PR comment * Add expiresSoon function and re-fetch if the serverConfig will expire soon (older than 18 hours) * Fix misaligned small third party server message text Co-authored-by: Addison Beck <addisonbeck1@gmail.com> Co-authored-by: Oscar Hinton <Hinton@users.noreply.github.com>
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() {
[Account Switching] Base changes for account switching (#2250) * Pull in jslib * Create new state models * Create browser specific stateService * Remove registration deprecated services, register stateService * Replace usage of deprecated services (user, constants) * Add missing properties to BrowserGroupingsComponentState * Remove StorageService from initFactory * Clear the correct state * Add null check when restoring send-grouping state * add remember email * Initialize stateservice in services.module * Fix 'lock now' not working * Comment to remove setting defaults on install * Pull jslib * Remove setting defaults on install * Bump jslib * Pass the current userId to services when logging out * Bump jslib * Override vaultTimeout default on account addition * Pull latest jslib * Retrieve vaultTimeout from stateService * Record activity per Account * Add userId to logout and add fallback if not present * Register AccountFactory * Pass userId in messages * Base changes for account switching di fixes (#2280) * [bug] Null checks on Account init * [bug] Use same stateService instance for all operations We override the stateService in browser, but currently don't pull the background service into popup and allow jslib to create its own instance of the base StateService for jslib services. This causes a split in in memory state between the three isntances that results in many errors, namely locking not working. * [chore] Update jslib * Pull in jslib * Pull in jslib * Pull in latest jslib to multiple stateservice inits * Check vault states before executing processReload * Adjust iterator * Update native messaging to include the userId (#2290) * Re-Add UserVerificationService * Fix email not being remembered by base component * Improve readability of reloadProcess * Removed unneeded null check * Fix constructor dependency (stateService) * Added missing await * Simplify dependency registration * Fixed typos * Reverted back to simple loop * Use vaultTimeoutService to retrieve Timeout Co-authored-by: Addison Beck <abeck@bitwarden.com> Co-authored-by: Oscar Hinton <oscar@oscarhinton.com>
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
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
if (result.value) {
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();
BrowserApi.createNewTab((RateUrls as any)[deviceType]);
2018-04-10 22:20:49 +02:00
}
}