1
0
mirror of https://github.com/bitwarden/desktop synced 2026-02-14 15:33:30 +00:00

[refactor] Remove references to deprecated services

This commit is contained in:
addison
2021-09-16 10:09:35 -04:00
parent 6f69486c36
commit f2f3c97867
26 changed files with 279 additions and 242 deletions

2
jslib

Submodule jslib updated: f09fb69882...24fe836032

View File

@@ -9,6 +9,7 @@ import {
} from '@angular/router';
import { ipcRenderer } from 'electron';
import { ActiveAccountService } from 'jslib-common/abstractions/activeAccount.service';
import { ApiService } from 'jslib-common/abstractions/api.service';
import { CryptoService } from 'jslib-common/abstractions/crypto.service';
import { EnvironmentService } from 'jslib-common/abstractions/environment.service';
@@ -17,15 +18,13 @@ import { LogService } from 'jslib-common/abstractions/log.service';
import { MessagingService } from 'jslib-common/abstractions/messaging.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { StateService } from 'jslib-common/abstractions/state.service';
import { StorageService } from 'jslib-common/abstractions/storage.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { VaultTimeoutService } from 'jslib-common/abstractions/vaultTimeout.service';
import { BroadcasterService } from 'jslib-angular/services/broadcaster.service';
import { LockComponent as BaseLockComponent } from 'jslib-angular/components/lock.component';
import { ConstantsService } from 'jslib-common/services/constants.service';
import { StorageKey } from 'jslib-common/enums/storageKey';
const BroadcasterSubscriptionId = 'LockComponent';
@@ -38,19 +37,19 @@ export class LockComponent extends BaseLockComponent implements OnDestroy {
constructor(router: Router, i18nService: I18nService,
platformUtilsService: PlatformUtilsService, messagingService: MessagingService,
userService: UserService, cryptoService: CryptoService,
storageService: StorageService, vaultTimeoutService: VaultTimeoutService,
cryptoService: CryptoService, vaultTimeoutService: VaultTimeoutService,
environmentService: EnvironmentService, stateService: StateService,
apiService: ApiService, private route: ActivatedRoute,
private broadcasterService: BroadcasterService, private ngZone: NgZone,
logService: LogService) {
super(router, i18nService, platformUtilsService, messagingService, userService, cryptoService,
storageService, vaultTimeoutService, environmentService, stateService, apiService, logService);
logService: LogService, activeAccount: ActiveAccountService) {
super(router, i18nService, platformUtilsService, messagingService, cryptoService,
vaultTimeoutService, environmentService, stateService, apiService, logService,
activeAccount);
}
async ngOnInit() {
await super.ngOnInit();
const autoPromptBiometric = !await this.storageService.get<boolean>(ConstantsService.disableAutoBiometricsPromptKey);
const autoPromptBiometric = !await this.activeAccount.getInformation<boolean>(StorageKey.NoAutoPromptBiometrics);
this.route.queryParams.subscribe(params => {
if (this.supportsBiometric && params.promptBiometric && autoPromptBiometric) {

View File

@@ -10,6 +10,7 @@ import { Router } from '@angular/router';
import { EnvironmentComponent } from './environment.component';
import { ActiveAccountService } from 'jslib-common/abstractions/activeAccount.service';
import { AuthService } from 'jslib-common/abstractions/auth.service';
import { CryptoFunctionService } from 'jslib-common/abstractions/cryptoFunction.service';
import { EnvironmentService } from 'jslib-common/abstractions/environment.service';
@@ -27,6 +28,8 @@ import { ModalService } from 'jslib-angular/services/modal.service';
import { LoginComponent as BaseLoginComponent } from 'jslib-angular/components/login.component';
import { StorageKey } from 'jslib-common/enums/storageKey';
const BroadcasterSubscriptionId = 'LoginComponent';
@Component({
@@ -46,9 +49,10 @@ export class LoginComponent extends BaseLoginComponent implements OnDestroy {
environmentService: EnvironmentService, passwordGenerationService: PasswordGenerationService,
cryptoFunctionService: CryptoFunctionService, storageService: StorageService,
private broadcasterService: BroadcasterService, private ngZone: NgZone,
private messagingService: MessagingService, logService: LogService) {
private messagingService: MessagingService, logService: LogService,
activeAccount: ActiveAccountService) {
super(authService, router, platformUtilsService, i18nService, stateService, environmentService,
passwordGenerationService, cryptoFunctionService, storageService, logService);
passwordGenerationService, cryptoFunctionService, storageService, logService, activeAccount);
super.onSuccessfulLogin = () => {
return syncService.fullSync(true);
};

View File

@@ -1,10 +1,10 @@
import { Component } from '@angular/core';
import { ActiveAccountService } from 'jslib-common/abstractions/activeAccount.service';
import { ApiService } from 'jslib-common/abstractions/api.service';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { LogService } from 'jslib-common/abstractions/log.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { PremiumComponent as BasePremiumComponent } from 'jslib-angular/components/premium.component';
@@ -14,8 +14,8 @@ import { PremiumComponent as BasePremiumComponent } from 'jslib-angular/componen
})
export class PremiumComponent extends BasePremiumComponent {
constructor(i18nService: I18nService, platformUtilsService: PlatformUtilsService,
apiService: ApiService, userService: UserService,
logService: LogService) {
super(i18nService, platformUtilsService, apiService, userService, logService);
apiService: ApiService, logService: LogService,
activeAccount: ActiveAccountService) {
super(i18nService, platformUtilsService, apiService, logService, activeAccount);
}
}

View File

@@ -9,6 +9,7 @@ import {
Router,
} from '@angular/router';
import { ActiveAccountService } from 'jslib-common/abstractions/activeAccount.service';
import { ApiService } from 'jslib-common/abstractions/api.service';
import { CryptoService } from 'jslib-common/abstractions/crypto.service';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
@@ -17,7 +18,8 @@ import { PasswordGenerationService } from 'jslib-common/abstractions/passwordGen
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { PolicyService } from 'jslib-common/abstractions/policy.service';
import { SyncService } from 'jslib-common/abstractions/sync.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { StorageKey } from 'jslib-common/enums/storageKey';
import { BroadcasterService } from 'jslib-angular/services/broadcaster.service';
@@ -34,12 +36,14 @@ import {
export class SetPasswordComponent extends BaseSetPasswordComponent implements OnDestroy {
constructor(apiService: ApiService, i18nService: I18nService,
cryptoService: CryptoService, messagingService: MessagingService,
userService: UserService, passwordGenerationService: PasswordGenerationService,
platformUtilsService: PlatformUtilsService, policyService: PolicyService, router: Router,
passwordGenerationService: PasswordGenerationService, platformUtilsService: PlatformUtilsService,
policyService: PolicyService, router: Router,
syncService: SyncService, route: ActivatedRoute,
private broadcasterService: BroadcasterService, private ngZone: NgZone) {
super(i18nService, cryptoService, messagingService, userService, passwordGenerationService,
platformUtilsService, policyService, router, apiService, syncService, route);
private broadcasterService: BroadcasterService, private ngZone: NgZone,
activeAccount: ActiveAccountService) {
super(i18nService, cryptoService, messagingService, passwordGenerationService,
platformUtilsService, policyService, router, apiService, syncService, route,
activeAccount);
}
get masterPasswordScoreWidth() {

View File

@@ -8,6 +8,7 @@ import { debounceTime } from 'rxjs/operators';
import { DeviceType } from 'jslib-common/enums/deviceType';
import { ThemeType } from 'jslib-common/enums/themeType';
import { ActiveAccountService } from 'jslib-common/abstractions/activeAccount.service';
import { CryptoService } from 'jslib-common/abstractions/crypto.service';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { MessagingService } from 'jslib-common/abstractions/messaging.service';
@@ -16,16 +17,14 @@ import { StateService } from 'jslib-common/abstractions/state.service';
import { StorageService } from 'jslib-common/abstractions/storage.service';
import { VaultTimeoutService } from 'jslib-common/abstractions/vaultTimeout.service';
import { ConstantsService } from 'jslib-common/services/constants.service';
import { ModalService } from 'jslib-angular/services/modal.service';
import { ElectronConstants } from 'jslib-electron/electronConstants';
import { SetPinComponent } from '../components/set-pin.component';
import { Utils } from 'jslib-common/misc/utils';
import { isWindowsStore } from 'jslib-electron/utils';
import { SetPinComponent } from '../components/set-pin.component';
import { StorageKey } from 'jslib-common/enums/storageKey';
@Component({
selector: 'app-settings',
@@ -72,9 +71,10 @@ export class SettingsComponent implements OnInit {
vaultTimeout: FormControl = new FormControl(null);
constructor(private i18nService: I18nService, private platformUtilsService: PlatformUtilsService,
private storageService: StorageService, private vaultTimeoutService: VaultTimeoutService,
private stateService: StateService, private messagingService: MessagingService,
private cryptoService: CryptoService, private modalService: ModalService) {
private vaultTimeoutService: VaultTimeoutService, private stateService: StateService,
private messagingService: MessagingService, private cryptoService: CryptoService,
private modalService: ModalService, private activeAccount: ActiveAccountService,
private storageService: StorageService) {
const isMac = this.platformUtilsService.getDevice() === DeviceType.MacOsDesktop;
// Workaround to avoid ghosting trays https://github.com/electron/electron/issues/17622
@@ -153,31 +153,31 @@ export class SettingsComponent implements OnInit {
async ngOnInit() {
this.showMinToTray = this.platformUtilsService.getDevice() !== DeviceType.LinuxDesktop;
this.vaultTimeout.setValue(await this.vaultTimeoutService.getVaultTimeout());
this.vaultTimeoutAction = await this.storageService.get<string>(ConstantsService.vaultTimeoutActionKey);
this.vaultTimeout.setValue(await this.activeAccount.getInformation<number>(StorageKey.VaultTimeout) ?? 1);
this.vaultTimeoutAction = await this.activeAccount.getInformation<string>(StorageKey.VaultTimeoutAction) ?? 'lock';
const pinSet = await this.vaultTimeoutService.isPinLockSet();
this.pin = pinSet[0] || pinSet[1];
this.disableFavicons = await this.storageService.get<boolean>(ConstantsService.disableFaviconKey);
this.enableBrowserIntegration = await this.storageService.get<boolean>(
ElectronConstants.enableBrowserIntegration);
this.enableBrowserIntegrationFingerprint = await this.storageService.get<boolean>(ElectronConstants.enableBrowserIntegrationFingerprint);
this.enableMinToTray = await this.storageService.get<boolean>(ElectronConstants.enableMinimizeToTrayKey);
this.enableCloseToTray = await this.storageService.get<boolean>(ElectronConstants.enableCloseToTrayKey);
this.enableTray = await this.storageService.get<boolean>(ElectronConstants.enableTrayKey);
this.startToTray = await this.storageService.get<boolean>(ElectronConstants.enableStartToTrayKey);
this.locale = await this.storageService.get<string>(ConstantsService.localeKey);
this.theme = await this.storageService.get<string>(ConstantsService.themeKey);
this.clearClipboard = await this.storageService.get<number>(ConstantsService.clearClipboardKey);
this.minimizeOnCopyToClipboard = await this.storageService.get<boolean>(
ElectronConstants.minimizeOnCopyToClipboardKey);
this.disableFavicons = await this.storageService.get(StorageKey.DisableFavicon) ?? false;
this.enableBrowserIntegration = await this.activeAccount.getInformation<boolean>(
StorageKey.EnableBrowserIntegration);
this.enableBrowserIntegrationFingerprint = await this.activeAccount.getInformation<boolean>(StorageKey.EnableBrowserIntegrationFingerprint);
this.enableMinToTray = await this.activeAccount.getInformation<boolean>(StorageKey.EnableMinimizeToTrayKey);
this.enableCloseToTray = await this.activeAccount.getInformation<boolean>(StorageKey.EnableCloseToTrayKey);
this.enableTray = await this.activeAccount.getInformation<boolean>(StorageKey.EnableTrayKey);
this.startToTray = await this.activeAccount.getInformation<boolean>(StorageKey.EnableStartToTrayKey);
this.locale = await this.activeAccount.getInformation<string>(StorageKey.Locale);
this.theme = await this.activeAccount.getInformation<string>(StorageKey.Theme);
this.clearClipboard = await this.activeAccount.getInformation<number>(StorageKey.ClearClipboard);
this.minimizeOnCopyToClipboard = await this.activeAccount.getInformation<boolean>(
StorageKey.MinimizeOnCopyToClipboardKey);
this.supportsBiometric = await this.platformUtilsService.supportsBiometric();
this.biometric = await this.vaultTimeoutService.isBiometricLockSet();
this.biometricText = await this.storageService.get<string>(ConstantsService.biometricText);
this.noAutoPromptBiometrics = await this.storageService.get<boolean>(ConstantsService.disableAutoBiometricsPromptKey);
this.noAutoPromptBiometricsText = await this.storageService.get<string>(ElectronConstants.noAutoPromptBiometricsText);
this.alwaysShowDock = await this.storageService.get<boolean>(ElectronConstants.alwaysShowDock);
this.biometricText = await this.activeAccount.getInformation<string>(StorageKey.BiometricText);
this.noAutoPromptBiometrics = await this.activeAccount.getInformation<boolean>(StorageKey.NoAutoPromptBiometrics);
this.noAutoPromptBiometricsText = await this.activeAccount.getInformation<string>(StorageKey.NoAutoPromptBiometricsText);
this.alwaysShowDock = await this.activeAccount.getInformation<boolean>(StorageKey.AlwaysShowDock);
this.showAlwaysShowDock = this.platformUtilsService.getDevice() === DeviceType.MacOsDesktop;
this.openAtLogin = await this.storageService.get<boolean>(ElectronConstants.openAtLogin);
this.openAtLogin = await this.activeAccount.getInformation<boolean>(StorageKey.OpenAtLogin);
}
async saveVaultTimeoutOptions() {
@@ -233,10 +233,10 @@ export class SettingsComponent implements OnInit {
return;
}
if (this.biometric) {
await this.storageService.save(ConstantsService.biometricUnlockKey, true);
await this.activeAccount.saveInformation(StorageKey.BiometricUnlock, true);
} else {
await this.storageService.remove(ConstantsService.biometricUnlockKey);
await this.storageService.remove(ConstantsService.disableAutoBiometricsPromptKey);
await this.activeAccount.removeInformation(StorageKey.BiometricUnlock);
await this.activeAccount.removeInformation(StorageKey.NoAutoPromptBiometrics);
this.noAutoPromptBiometrics = false;
}
this.vaultTimeoutService.biometricLocked = false;
@@ -249,29 +249,29 @@ export class SettingsComponent implements OnInit {
}
if (this.noAutoPromptBiometrics) {
await this.storageService.save(ConstantsService.disableAutoBiometricsPromptKey, true);
await this.activeAccount.saveInformation(StorageKey.NoAutoPromptBiometrics, true);
} else {
await this.storageService.remove(ConstantsService.disableAutoBiometricsPromptKey);
await this.activeAccount.removeInformation(StorageKey.NoAutoPromptBiometrics);
}
}
async saveFavicons() {
await this.storageService.save(ConstantsService.disableFaviconKey, this.disableFavicons);
await this.stateService.save(ConstantsService.disableFaviconKey, this.disableFavicons);
await this.activeAccount.saveInformation(StorageKey.DisableFavicon, this.disableFavicons);
await this.stateService.save(StorageKey.DisableFavicon, this.disableFavicons);
this.messagingService.send('refreshCiphers');
}
async saveMinToTray() {
await this.storageService.save(ElectronConstants.enableMinimizeToTrayKey, this.enableMinToTray);
await this.activeAccount.saveInformation(StorageKey.EnableMinimizeToTrayKey, this.enableMinToTray);
}
async saveCloseToTray() {
if (this.requireEnableTray) {
this.enableTray = true;
await this.storageService.save(ElectronConstants.enableTrayKey, this.enableTray);
await this.activeAccount.saveInformation(StorageKey.EnableTrayKey, this.enableTray);
}
await this.storageService.save(ElectronConstants.enableCloseToTrayKey, this.enableCloseToTray);
await this.activeAccount.saveInformation(StorageKey.EnableCloseToTrayKey, this.enableCloseToTray);
}
async saveTray() {
@@ -282,9 +282,9 @@ export class SettingsComponent implements OnInit {
if (confirm) {
this.startToTray = false;
await this.storageService.save(ElectronConstants.enableStartToTrayKey, this.startToTray);
await this.activeAccount.saveInformation(StorageKey.EnableStartToTrayKey, this.startToTray);
this.enableCloseToTray = false;
await this.storageService.save(ElectronConstants.enableCloseToTrayKey, this.enableCloseToTray);
await this.activeAccount.saveInformation(StorageKey.EnableCloseToTrayKey, this.enableCloseToTray);
} else {
this.enableTray = true;
}
@@ -292,42 +292,43 @@ export class SettingsComponent implements OnInit {
return;
}
await this.storageService.save(ElectronConstants.enableTrayKey, this.enableTray);
await this.activeAccount.saveInformation(StorageKey.EnableTrayKey, this.enableTray);
this.messagingService.send(this.enableTray ? 'showTray' : 'removeTray');
}
async saveStartToTray() {
if (this.requireEnableTray) {
this.enableTray = true;
await this.storageService.save(ElectronConstants.enableTrayKey, this.enableTray);
await this.activeAccount.saveInformation(StorageKey.EnableTrayKey, this.enableTray);
}
await this.storageService.save(ElectronConstants.enableStartToTrayKey, this.startToTray);
await this.activeAccount.saveInformation(StorageKey.EnableStartToTrayKey, this.startToTray);
}
async saveLocale() {
await this.storageService.save(ConstantsService.localeKey, this.locale);
await this.activeAccount.saveInformation(StorageKey.Locale, this.locale);
}
async saveTheme() {
await this.storageService.save(ConstantsService.themeKey, this.theme);
await this.activeAccount.saveInformation(StorageKey.Theme, this.theme);
await this.storageService.save(`global.${StorageKey.Theme}`, this.theme);
window.setTimeout(() => window.location.reload(), 200);
}
async saveMinOnCopyToClipboard() {
await this.storageService.save(ElectronConstants.minimizeOnCopyToClipboardKey, this.minimizeOnCopyToClipboard);
await this.activeAccount.saveInformation(StorageKey.MinimizeOnCopyToClipboardKey, this.minimizeOnCopyToClipboard);
}
async saveClearClipboard() {
await this.storageService.save(ConstantsService.clearClipboardKey, this.clearClipboard);
await this.activeAccount.saveInformation(StorageKey.ClearClipboard, this.clearClipboard);
}
async saveAlwaysShowDock() {
await this.storageService.save(ElectronConstants.alwaysShowDock, this.alwaysShowDock);
await this.activeAccount.saveInformation(StorageKey.AlwaysShowDock, this.alwaysShowDock);
}
async saveOpenAtLogin() {
this.storageService.save(ElectronConstants.openAtLogin, this.openAtLogin);
this.activeAccount.saveInformation(StorageKey.OpenAtLogin, this.openAtLogin);
this.messagingService.send(this.openAtLogin ? 'addOpenAtLogin' : 'removeOpenAtLogin');
}
@@ -350,7 +351,7 @@ export class SettingsComponent implements OnInit {
return;
}
await this.storageService.save(ElectronConstants.enableBrowserIntegration, this.enableBrowserIntegration);
await this.activeAccount.saveInformation(StorageKey.EnableBrowserIntegration, this.enableBrowserIntegration);
this.messagingService.send(this.enableBrowserIntegration ? 'enableBrowserIntegration' : 'disableBrowserIntegration');
if (!this.enableBrowserIntegration) {
@@ -360,6 +361,6 @@ export class SettingsComponent implements OnInit {
}
async saveBrowserIntegrationFingerprint() {
await this.storageService.save(ElectronConstants.enableBrowserIntegrationFingerprint, this.enableBrowserIntegrationFingerprint);
await this.activeAccount.saveInformation(StorageKey.EnableBrowserIntegrationFingerprint, this.enableBrowserIntegrationFingerprint);
}
}

View File

@@ -5,6 +5,7 @@ import {
Router,
} from '@angular/router';
import { ActiveAccountService } from 'jslib-common/abstractions/activeAccount.service';
import { ApiService } from 'jslib-common/abstractions/api.service';
import { AuthService } from 'jslib-common/abstractions/auth.service';
import { CryptoFunctionService } from 'jslib-common/abstractions/cryptoFunction.service';
@@ -29,9 +30,11 @@ export class SsoComponent extends BaseSsoComponent {
storageService: StorageService, stateService: StateService,
platformUtilsService: PlatformUtilsService, apiService: ApiService,
cryptoFunctionService: CryptoFunctionService, environmentService: EnvironmentService,
passwordGenerationService: PasswordGenerationService, logService: LogService) {
passwordGenerationService: PasswordGenerationService, logService: LogService,
activeAccount: ActiveAccountService) {
super(authService, router, i18nService, route, storageService, stateService, platformUtilsService,
apiService, cryptoFunctionService, environmentService, passwordGenerationService, logService);
apiService, cryptoFunctionService, environmentService, passwordGenerationService, logService,
activeAccount);
super.onSuccessfulLogin = () => {
return syncService.fullSync(true);
};

View File

@@ -13,6 +13,7 @@ import { TwoFactorOptionsComponent } from './two-factor-options.component';
import { TwoFactorProviderType } from 'jslib-common/enums/twoFactorProviderType';
import { ActiveAccountService } from 'jslib-common/abstractions/activeAccount.service';
import { ApiService } from 'jslib-common/abstractions/api.service';
import { AuthService } from 'jslib-common/abstractions/auth.service';
import { EnvironmentService } from 'jslib-common/abstractions/environment.service';
@@ -27,6 +28,8 @@ import { ModalService } from 'jslib-angular/services/modal.service';
import { TwoFactorComponent as BaseTwoFactorComponent } from 'jslib-angular/components/two-factor.component';
import { StorageKey } from 'jslib-common/enums/storageKey';
@Component({
selector: 'app-two-factor',
templateUrl: 'two-factor.component.html',

View File

@@ -1,5 +1,6 @@
import { Component } from '@angular/core';
import { ActiveAccountService } from 'jslib-common/abstractions/activeAccount.service';
import { ApiService } from 'jslib-common/abstractions/api.service';
import { CryptoService } from 'jslib-common/abstractions/crypto.service';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
@@ -9,7 +10,6 @@ import { PasswordGenerationService } from 'jslib-common/abstractions/passwordGen
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { PolicyService } from 'jslib-common/abstractions/policy.service';
import { SyncService } from 'jslib-common/abstractions/sync.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { UpdateTempPasswordComponent as BaseUpdateTempPasswordComponent } from 'jslib-angular/components/update-temp-password.component';
@@ -56,10 +56,10 @@ export class UpdateTempPasswordComponent extends BaseUpdateTempPasswordComponent
}
constructor(i18nService: I18nService, platformUtilsService: PlatformUtilsService,
passwordGenerationService: PasswordGenerationService, policyService: PolicyService,
cryptoService: CryptoService, userService: UserService,
messagingService: MessagingService, apiService: ApiService,
syncService: SyncService, logService: LogService) {
cryptoService: CryptoService, messagingService: MessagingService,
apiService: ApiService, syncService: SyncService,
logService: LogService, activeAccount: ActiveAccountService) {
super(i18nService, platformUtilsService, passwordGenerationService, policyService, cryptoService,
userService, messagingService, apiService, syncService, logService);
messagingService, apiService, activeAccount, syncService, logService);
}
}

View File

@@ -23,6 +23,8 @@ import { PasswordGeneratorHistoryComponent } from './vault/password-generator-hi
import { BroadcasterService } from 'jslib-angular/services/broadcaster.service';
import { AccountsManagementService } from 'jslib-common/abstractions/accountsManagement.service';
import { ActiveAccountService } from 'jslib-common/abstractions/activeAccount.service';
import { AuthService } from 'jslib-common/abstractions/auth.service';
import { CipherService } from 'jslib-common/abstractions/cipher.service';
import { CollectionService } from 'jslib-common/abstractions/collection.service';
@@ -39,16 +41,13 @@ import { PolicyService } from 'jslib-common/abstractions/policy.service';
import { SearchService } from 'jslib-common/abstractions/search.service';
import { SettingsService } from 'jslib-common/abstractions/settings.service';
import { StateService } from 'jslib-common/abstractions/state.service';
import { StorageService } from 'jslib-common/abstractions/storage.service';
import { SyncService } from 'jslib-common/abstractions/sync.service';
import { SystemService } from 'jslib-common/abstractions/system.service';
import { TokenService } from 'jslib-common/abstractions/token.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { VaultTimeoutService } from 'jslib-common/abstractions/vaultTimeout.service';
import { ConstantsService } from 'jslib-common/services/constants.service';
import { CipherType } from 'jslib-common/enums/cipherType';
import { StorageKey } from 'jslib-common/enums/storageKey';
import { ModalRef } from 'jslib-angular/components/modal/modal.ref';
import { ModalService } from 'jslib-angular/services/modal.service';
@@ -95,20 +94,20 @@ export class AppComponent implements OnInit {
private idleTimer: number = null;
private isIdle = false;
constructor(private broadcasterService: BroadcasterService, private userService: UserService,
constructor(private broadcasterService: BroadcasterService, private activeAccount: ActiveAccountService,
private tokenService: TokenService, private folderService: FolderService,
private settingsService: SettingsService, private syncService: SyncService,
private passwordGenerationService: PasswordGenerationService, private cipherService: CipherService,
private authService: AuthService, private router: Router,
private toasterService: ToasterService, private i18nService: I18nService,
private sanitizer: DomSanitizer, private ngZone: NgZone,
private vaultTimeoutService: VaultTimeoutService, private storageService: StorageService,
private cryptoService: CryptoService, private logService: LogService,
private messagingService: MessagingService, private collectionService: CollectionService,
private searchService: SearchService, private notificationsService: NotificationsService,
private platformUtilsService: PlatformUtilsService, private systemService: SystemService,
private stateService: StateService, private eventService: EventService,
private policyService: PolicyService, private modalService: ModalService) { }
private vaultTimeoutService: VaultTimeoutService, private cryptoService: CryptoService,
private logService: LogService, private messagingService: MessagingService,
private collectionService: CollectionService, private searchService: SearchService,
private notificationsService: NotificationsService, private platformUtilsService: PlatformUtilsService,
private systemService: SystemService, private stateService: StateService,
private eventService: EventService, private policyService: PolicyService,
private modalService: ModalService, private accountsManagementService: AccountsManagementService) { }
ngOnInit() {
this.ngZone.runOutsideAngular(() => {
@@ -177,7 +176,7 @@ export class AppComponent implements OnInit {
break;
case 'showFingerprintPhrase':
const fingerprint = await this.cryptoService.getFingerprint(
await this.userService.getUserId());
this.activeAccount.userId);
const result = await this.platformUtilsService.showDialog(
this.i18nService.t('yourAccountsFingerprint') + ':\n' + fingerprint.join('-'),
this.i18nService.t('fingerprintPhrase'), this.i18nService.t('learnMore'),
@@ -329,21 +328,20 @@ export class AppComponent implements OnInit {
private async updateAppMenu() {
this.messagingService.send('updateAppMenu', {
isAuthenticated: await this.userService.isAuthenticated(),
isAuthenticated: this.activeAccount.isAuthenticated,
isLocked: await this.vaultTimeoutService.isLocked(),
});
}
private async logOut(expired: boolean) {
await this.eventService.uploadEvents();
const userId = await this.userService.getUserId();
const userId = this.activeAccount.userId;
await Promise.all([
this.eventService.clearEvents(),
this.syncService.setLastSync(new Date(0)),
this.tokenService.clearToken(),
this.cryptoService.clearKeys(),
this.userService.clear(),
this.settingsService.clear(userId),
this.cipherService.clear(userId),
this.folderService.clear(userId),
@@ -352,6 +350,7 @@ export class AppComponent implements OnInit {
this.vaultTimeoutService.clear(),
this.stateService.purge(),
this.policyService.clear(userId),
this.accountsManagementService.remove(userId),
]);
this.vaultTimeoutService.biometricLocked = true;
@@ -372,7 +371,7 @@ export class AppComponent implements OnInit {
}
this.lastActivity = now;
this.storageService.save(ConstantsService.lastActiveKey, now);
this.activeAccount.saveInformation(StorageKey.LastActive, now);
// Idle states
if (this.isIdle) {

View File

@@ -2,6 +2,7 @@ import { DatePipe } from '@angular/common';
import { Component } from '@angular/core';
import { ActiveAccountService } from 'jslib-common/abstractions/activeAccount.service';
import { EnvironmentService } from 'jslib-common/abstractions/environment.service';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { LogService } from 'jslib-common/abstractions/log.service';
@@ -9,7 +10,6 @@ import { MessagingService } from 'jslib-common/abstractions/messaging.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { PolicyService } from 'jslib-common/abstractions/policy.service';
import { SendService } from 'jslib-common/abstractions/send.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { AddEditComponent as BaseAddEditComponent } from 'jslib-angular/components/send/add-edit.component';
@@ -20,12 +20,12 @@ import { AddEditComponent as BaseAddEditComponent } from 'jslib-angular/componen
export class AddEditComponent extends BaseAddEditComponent {
constructor(i18nService: I18nService, platformUtilsService: PlatformUtilsService,
environmentService: EnvironmentService, datePipe: DatePipe,
sendService: SendService, userService: UserService,
sendService: SendService, activeAccount: ActiveAccountService,
messagingService: MessagingService, policyService: PolicyService,
logService: LogService) {
super(i18nService, platformUtilsService, environmentService,
datePipe, sendService, userService, messagingService, policyService,
logService);
datePipe, sendService, messagingService, policyService,
logService, activeAccount);
}
async refresh() {

View File

@@ -3,7 +3,6 @@ import { DatePipe } from '@angular/common';
import {
Component,
OnChanges,
SimpleChanges,
} from '@angular/core';
import { ControlContainer, NgForm } from '@angular/forms';

View File

@@ -13,7 +13,6 @@ import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.se
import { PolicyService } from 'jslib-common/abstractions/policy.service';
import { SearchService } from 'jslib-common/abstractions/search.service';
import { SendService } from 'jslib-common/abstractions/send.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { SendComponent as BaseSendComponent } from 'jslib-angular/components/send/send.component';
@@ -46,10 +45,10 @@ export class SendComponent extends BaseSendComponent implements OnInit, OnDestro
platformUtilsService: PlatformUtilsService, environmentService: EnvironmentService,
private broadcasterService: BroadcasterService, ngZone: NgZone,
searchService: SearchService, policyService: PolicyService,
userService: UserService, logService: LogService) {
logService: LogService) {
super(sendService, i18nService, platformUtilsService,
environmentService, ngZone, searchService,
policyService, userService, logService);
policyService, logService);
}
async ngOnInit() {

View File

@@ -23,13 +23,14 @@ import { ModalService } from 'jslib-angular/services/modal.service';
import { UnauthGuardService } from 'jslib-angular/services/unauth-guard.service';
import { ValidationService } from 'jslib-angular/services/validation.service';
import { AccountsManagementService } from 'jslib-common/services/accountsManagement.service';
import { ActiveAccountService } from 'jslib-common/services/activeAccount.service';
import { ApiService } from 'jslib-common/services/api.service';
import { AppIdService } from 'jslib-common/services/appId.service';
import { AuditService } from 'jslib-common/services/audit.service';
import { AuthService } from 'jslib-common/services/auth.service';
import { CipherService } from 'jslib-common/services/cipher.service';
import { CollectionService } from 'jslib-common/services/collection.service';
import { ConstantsService } from 'jslib-common/services/constants.service';
import { ContainerService } from 'jslib-common/services/container.service';
import { EnvironmentService } from 'jslib-common/services/environment.service';
import { EventService } from 'jslib-common/services/event.service';
@@ -37,22 +38,26 @@ import { ExportService } from 'jslib-common/services/export.service';
import { FileUploadService } from 'jslib-common/services/fileUpload.service';
import { FolderService } from 'jslib-common/services/folder.service';
import { NotificationsService } from 'jslib-common/services/notifications.service';
import { OrganizationService } from 'jslib-common/services/organization.service';
import { PasswordGenerationService } from 'jslib-common/services/passwordGeneration.service';
import { PolicyService } from 'jslib-common/services/policy.service';
import { ProviderService } from 'jslib-common/services/provider.service';
import { SearchService } from 'jslib-common/services/search.service';
import { SendService } from 'jslib-common/services/send.service';
import { SettingsService } from 'jslib-common/services/settings.service';
import { StateService } from 'jslib-common/services/state.service';
import { StoreService } from 'jslib-common/services/store.service';
import { SyncService } from 'jslib-common/services/sync.service';
import { SystemService } from 'jslib-common/services/system.service';
import { TokenService } from 'jslib-common/services/token.service';
import { TotpService } from 'jslib-common/services/totp.service';
import { UserService } from 'jslib-common/services/user.service';
import { VaultTimeoutService } from 'jslib-common/services/vaultTimeout.service';
import { WebCryptoFunctionService } from 'jslib-common/services/webCryptoFunction.service';
import { ElectronCryptoService } from 'jslib-electron/services/electronCrypto.service';
import { AccountsManagementService as AccountsManagementServiceAbstraction } from 'jslib-common/abstractions/accountsManagement.service';
import { ActiveAccountService as ActiveAccountServiceAbstraction } from 'jslib-common/abstractions/activeAccount.service';
import { ApiService as ApiServiceAbstraction } from 'jslib-common/abstractions/api.service';
import { AuditService as AuditServiceAbstraction } from 'jslib-common/abstractions/audit.service';
import { AuthService as AuthServiceAbstraction } from 'jslib-common/abstractions/auth.service';
@@ -69,12 +74,14 @@ import { I18nService as I18nServiceAbstraction } from 'jslib-common/abstractions
import { LogService as LogServiceAbstraction } from 'jslib-common/abstractions/log.service';
import { MessagingService as MessagingServiceAbstraction } from 'jslib-common/abstractions/messaging.service';
import { NotificationsService as NotificationsServiceAbstraction } from 'jslib-common/abstractions/notifications.service';
import { OrganizationService as OrganizationServiceAbstraction } from 'jslib-common/abstractions/organization.service';
import {
PasswordGenerationService as PasswordGenerationServiceAbstraction,
} from 'jslib-common/abstractions/passwordGeneration.service';
import { PasswordRepromptService as PasswordRepromptServiceAbstraction } from 'jslib-common/abstractions/passwordReprompt.service';
import { PlatformUtilsService as PlatformUtilsServiceAbstraction } from 'jslib-common/abstractions/platformUtils.service';
import { PolicyService as PolicyServiceAbstraction } from 'jslib-common/abstractions/policy.service';
import { ProviderService as ProviderServiceAbstraction } from 'jslib-common/abstractions/provider.service';
import { SearchService as SearchServiceAbstraction } from 'jslib-common/abstractions/search.service';
import { SendService as SendServiceAbstraction } from 'jslib-common/abstractions/send.service';
import { SettingsService as SettingsServiceAbstraction } from 'jslib-common/abstractions/settings.service';
@@ -84,8 +91,8 @@ import { SyncService as SyncServiceAbstraction } from 'jslib-common/abstractions
import { SystemService as SystemServiceAbstraction } from 'jslib-common/abstractions/system.service';
import { TokenService as TokenServiceAbstraction } from 'jslib-common/abstractions/token.service';
import { TotpService as TotpServiceAbstraction } from 'jslib-common/abstractions/totp.service';
import { UserService as UserServiceAbstraction } from 'jslib-common/abstractions/user.service';
import { VaultTimeoutService as VaultTimeoutServiceAbstraction } from 'jslib-common/abstractions/vaultTimeout.service';
import { StorageKey } from 'jslib-common/enums/storageKey';
import { ThemeType } from 'jslib-common/enums/themeType';
@@ -95,51 +102,54 @@ const stateService = new StateService();
const broadcasterService = new BroadcasterService();
const messagingService = new ElectronRendererMessagingService(broadcasterService);
const storageService: StorageServiceAbstraction = new ElectronRendererStorageService();
const platformUtilsService = new ElectronPlatformUtilsService(i18nService, messagingService, true, storageService);
const secureStorageService: StorageServiceAbstraction = new ElectronRendererSecureStorageService();
const storeService = new StoreService(storageService, secureStorageService);
const accountsManagementService: AccountsManagementServiceAbstraction = new AccountsManagementService(storageService, secureStorageService);
const activeAccount: ActiveAccountServiceAbstraction = new ActiveAccountService(accountsManagementService, storeService);
const platformUtilsService = new ElectronPlatformUtilsService(i18nService, messagingService, true, storageService, activeAccount);
const cryptoFunctionService: CryptoFunctionServiceAbstraction = new WebCryptoFunctionService(window,
platformUtilsService);
const cryptoService = new ElectronCryptoService(storageService, secureStorageService, cryptoFunctionService,
platformUtilsService, logService);
const tokenService = new TokenService(storageService);
const cryptoService = new ElectronCryptoService(cryptoFunctionService, platformUtilsService,
logService, activeAccount);
const tokenService = new TokenService(activeAccount);
const appIdService = new AppIdService(storageService);
const environmentService = new EnvironmentService(storageService);
const environmentService = new EnvironmentService(activeAccount);
const apiService = new ApiService(tokenService, platformUtilsService, environmentService,
async (expired: boolean) => messagingService.send('logout', { expired: expired }));
const userService = new UserService(tokenService, storageService);
const settingsService = new SettingsService(userService, storageService);
const settingsService = new SettingsService(activeAccount);
export let searchService: SearchService = null;
const fileUploadService = new FileUploadService(logService, apiService);
const cipherService = new CipherService(cryptoService, userService, settingsService,
apiService, fileUploadService, storageService, i18nService, () => searchService,
logService);
const folderService = new FolderService(cryptoService, userService, apiService, storageService,
i18nService, cipherService);
const collectionService = new CollectionService(cryptoService, userService, storageService, i18nService);
const cipherService = new CipherService(cryptoService, settingsService, apiService,
fileUploadService, i18nService, () => searchService, logService, activeAccount);
const folderService = new FolderService(cryptoService, apiService, i18nService,
cipherService, activeAccount);
const collectionService = new CollectionService(cryptoService, i18nService, activeAccount);
searchService = new SearchService(cipherService, logService, i18nService);
const sendService = new SendService(cryptoService, userService, apiService, fileUploadService, storageService,
i18nService, cryptoFunctionService);
const policyService = new PolicyService(userService, storageService, apiService);
const sendService = new SendService(cryptoService, apiService, fileUploadService, i18nService,
cryptoFunctionService, activeAccount);
const organizationService = new OrganizationService(activeAccount);
const providerService: ProviderServiceAbstraction = new ProviderService(activeAccount);
const policyService = new PolicyService(activeAccount, organizationService, apiService);
const vaultTimeoutService = new VaultTimeoutService(cipherService, folderService, collectionService,
cryptoService, platformUtilsService, storageService, messagingService, searchService, userService, tokenService,
policyService, null, async () => messagingService.send('logout', { expired: false }));
const syncService = new SyncService(userService, apiService, settingsService,
folderService, cipherService, cryptoService, collectionService, storageService, messagingService, policyService,
sendService, logService, async (expired: boolean) => messagingService.send('logout', { expired: expired }));
const passwordGenerationService = new PasswordGenerationService(cryptoService, storageService, policyService);
const totpService = new TotpService(storageService, cryptoFunctionService, logService);
cryptoService, platformUtilsService, messagingService, searchService, tokenService, policyService, activeAccount, null,
async () => messagingService.send('logout', { expired: false }));
const syncService = new SyncService(apiService, settingsService,
folderService, cipherService, cryptoService, collectionService, messagingService, policyService, sendService, logService,
async (expired: boolean) => messagingService.send('logout', { expired: expired }), activeAccount, organizationService, providerService);
const passwordGenerationService = new PasswordGenerationService(cryptoService, policyService, activeAccount);
const totpService = new TotpService(cryptoFunctionService, logService, activeAccount);
const containerService = new ContainerService(cryptoService);
const authService = new AuthService(cryptoService, apiService, userService, tokenService, appIdService,
i18nService, platformUtilsService, messagingService, vaultTimeoutService, logService);
const authService = new AuthService(cryptoService, apiService, tokenService, appIdService, i18nService,
platformUtilsService, messagingService, vaultTimeoutService, logService, activeAccount, accountsManagementService);
const exportService = new ExportService(folderService, cipherService, apiService, cryptoService);
const auditService = new AuditService(cryptoFunctionService, apiService);
const notificationsService = new NotificationsService(userService, syncService, appIdService,
apiService, vaultTimeoutService, environmentService, async () => messagingService.send('logout', { expired: true }), logService);
const eventService = new EventService(storageService, apiService, userService, cipherService, logService);
const systemService = new SystemService(storageService, vaultTimeoutService, messagingService, platformUtilsService,
null);
const notificationsService = new NotificationsService(syncService, appIdService,
apiService, vaultTimeoutService, environmentService, async () => messagingService.send('logout', { expired: true }), logService, activeAccount);
const eventService = new EventService(apiService, cipherService, activeAccount, logService, organizationService);
const systemService = new SystemService(vaultTimeoutService, messagingService, platformUtilsService, null,
activeAccount);
const nativeMessagingService = new NativeMessagingService(cryptoFunctionService, cryptoService, platformUtilsService,
logService, i18nService, userService, messagingService, vaultTimeoutService, storageService);
logService, i18nService, messagingService, vaultTimeoutService, activeAccount);
containerService.attachToGlobal(window);
@@ -148,7 +158,7 @@ export function initFactory(): Function {
await environmentService.setUrlsFromStorage();
syncService.fullSync(true);
vaultTimeoutService.init(true);
const locale = await storageService.get<string>(ConstantsService.localeKey);
const locale = await activeAccount.getInformation<string>(StorageKey.Locale);
await i18nService.init(locale);
eventService.init(true);
authService.init();
@@ -156,22 +166,21 @@ export function initFactory(): Function {
const htmlEl = window.document.documentElement;
htmlEl.classList.add('os_' + platformUtilsService.getDeviceString());
htmlEl.classList.add('locale_' + i18nService.translationLocale);
const theme = await platformUtilsService.getEffectiveTheme();
htmlEl.classList.add('theme_' + theme);
platformUtilsService.onDefaultSystemThemeChange(async sysTheme => {
const bwTheme = await storageService.get<ThemeType>(ConstantsService.themeKey);
const bwTheme = await activeAccount.getInformation<ThemeType>(StorageKey.Theme);
if (bwTheme == null || bwTheme === ThemeType.System) {
htmlEl.classList.remove('theme_' + ThemeType.Light, 'theme_' + ThemeType.Dark);
htmlEl.classList.add('theme_' + sysTheme);
}
});
stateService.save(ConstantsService.disableFaviconKey,
await storageService.get<boolean>(ConstantsService.disableFaviconKey));
stateService.save(StorageKey.DisableFavicon,
await storageService.get<boolean>(StorageKey.DisableFavicon));
let installAction = null;
const installedVersion = await storageService.get<string>(ConstantsService.installedVersionKey);
const installedVersion = await activeAccount.getInformation<string>(StorageKey.InstalledVersion);
const currentVersion = await platformUtilsService.getApplicationVersion();
if (installedVersion == null) {
installAction = 'install';
@@ -180,7 +189,7 @@ export function initFactory(): Function {
}
if (installAction != null) {
await storageService.save(ConstantsService.installedVersionKey, currentVersion);
await activeAccount.saveInformation(StorageKey.InstalledVersion, currentVersion);
}
};
}
@@ -196,40 +205,42 @@ export function initFactory(): Function {
UnauthGuardService,
LockGuardService,
ModalService,
{ provide: AccountsManagementServiceAbstraction, useValue: accountsManagementService },
{ provide: ActiveAccountServiceAbstraction, useValue: activeAccount },
{ provide: ApiServiceAbstraction, useValue: apiService },
{ provide: AuditServiceAbstraction, useValue: auditService },
{ provide: AuthServiceAbstraction, useValue: authService },
{ provide: CipherServiceAbstraction, useValue: cipherService },
{ provide: FolderServiceAbstraction, useValue: folderService },
{ provide: CollectionServiceAbstraction, useValue: collectionService },
{ provide: EnvironmentServiceAbstraction, useValue: environmentService },
{ provide: TotpServiceAbstraction, useValue: totpService },
{ provide: TokenServiceAbstraction, useValue: tokenService },
{ provide: I18nServiceAbstraction, useValue: i18nService },
{ provide: CryptoServiceAbstraction, useValue: cryptoService },
{ provide: CryptoFunctionServiceAbstraction, useValue: cryptoFunctionService },
{ provide: PlatformUtilsServiceAbstraction, useValue: platformUtilsService },
{ provide: PasswordGenerationServiceAbstraction, useValue: passwordGenerationService },
{ provide: ApiServiceAbstraction, useValue: apiService },
{ provide: SyncServiceAbstraction, useValue: syncService },
{ provide: UserServiceAbstraction, useValue: userService },
{ provide: MessagingServiceAbstraction, useValue: messagingService },
{ provide: BroadcasterService, useValue: broadcasterService },
{ provide: SettingsServiceAbstraction, useValue: settingsService },
{ provide: VaultTimeoutServiceAbstraction, useValue: vaultTimeoutService },
{ provide: StorageServiceAbstraction, useValue: storageService },
{ provide: StateServiceAbstraction, useValue: stateService },
{ provide: LogServiceAbstraction, useValue: logService },
{ provide: ExportServiceAbstraction, useValue: exportService },
{ provide: SearchServiceAbstraction, useValue: searchService },
{ provide: NotificationsServiceAbstraction, useValue: notificationsService },
{ provide: SystemServiceAbstraction, useValue: systemService },
{ provide: EventServiceAbstraction, useValue: eventService },
{ provide: PolicyServiceAbstraction, useValue: policyService },
{ provide: SendServiceAbstraction, useValue: sendService },
{ provide: CipherServiceAbstraction, useValue: cipherService },
{ provide: CollectionServiceAbstraction, useValue: collectionService },
{ provide: CryptoFunctionServiceAbstraction, useValue: cryptoFunctionService },
{ provide: NativeMessagingService, useValue: nativeMessagingService },
{ provide: CryptoFunctionServiceAbstraction, useValue: cryptoFunctionService },
{ provide: CryptoServiceAbstraction, useValue: cryptoService },
{ provide: EnvironmentServiceAbstraction, useValue: environmentService },
{ provide: EventServiceAbstraction, useValue: eventService },
{ provide: ExportServiceAbstraction, useValue: exportService },
{ provide: FileUploadServiceAbstraction, useValue: fileUploadService },
{ provide: FolderServiceAbstraction, useValue: folderService },
{ provide: I18nServiceAbstraction, useValue: i18nService },
{ provide: LogServiceAbstraction, useValue: logService },
{ provide: MessagingServiceAbstraction, useValue: messagingService },
{ provide: NativeMessagingService, useValue: nativeMessagingService },
{ provide: NotificationsServiceAbstraction, useValue: notificationsService },
{ provide: OrganizationServiceAbstraction, useValue: organizationService },
{ provide: PasswordGenerationServiceAbstraction, useValue: passwordGenerationService },
{ provide: PasswordRepromptServiceAbstraction, useClass: PasswordRepromptService },
{ provide: PlatformUtilsServiceAbstraction, useValue: platformUtilsService },
{ provide: PolicyServiceAbstraction, useValue: policyService },
{ provide: SearchServiceAbstraction, useValue: searchService },
{ provide: SendServiceAbstraction, useValue: sendService },
{ provide: SettingsServiceAbstraction, useValue: settingsService },
{ provide: StateServiceAbstraction, useValue: stateService },
{ provide: StorageServiceAbstraction, useValue: storageService },
{ provide: SyncServiceAbstraction, useValue: syncService },
{ provide: SystemServiceAbstraction, useValue: systemService },
{ provide: TokenServiceAbstraction, useValue: tokenService },
{ provide: TotpServiceAbstraction, useValue: totpService },
{ provide: VaultTimeoutServiceAbstraction, useValue: vaultTimeoutService },
{
provide: APP_INITIALIZER,
useFactory: initFactory,

View File

@@ -7,6 +7,7 @@ import {
} from '@angular/core';
import { NgForm } from '@angular/forms';
import { ActiveAccountService } from 'jslib-common/abstractions/activeAccount.service';
import { AuditService } from 'jslib-common/abstractions/audit.service';
import { CipherService } from 'jslib-common/abstractions/cipher.service';
import { CollectionService } from 'jslib-common/abstractions/collection.service';
@@ -15,16 +16,15 @@ import { FolderService } from 'jslib-common/abstractions/folder.service';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { LogService } from 'jslib-common/abstractions/log.service';
import { MessagingService } from 'jslib-common/abstractions/messaging.service';
import { OrganizationService } from 'jslib-common/abstractions/organization.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { PolicyService } from 'jslib-common/abstractions/policy.service';
import { StateService } from 'jslib-common/abstractions/state.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { BroadcasterService } from 'jslib-angular/services/broadcaster.service';
import { AddEditComponent as BaseAddEditComponent } from 'jslib-angular/components/add-edit.component';
const BroadcasterSubscriptionId = 'AddEditComponent';
@Component({
@@ -37,12 +37,14 @@ export class AddEditComponent extends BaseAddEditComponent implements OnChanges,
constructor(cipherService: CipherService, folderService: FolderService,
i18nService: I18nService, platformUtilsService: PlatformUtilsService,
auditService: AuditService, stateService: StateService,
userService: UserService, collectionService: CollectionService,
messagingService: MessagingService, eventService: EventService,
policyService: PolicyService, private broadcasterService: BroadcasterService,
private ngZone: NgZone, logService: LogService) {
collectionService: CollectionService, messagingService: MessagingService,
eventService: EventService, policyService: PolicyService,
private broadcasterService: BroadcasterService, private ngZone: NgZone,
logService: LogService, activeAccountService: ActiveAccountService,
organizationService: OrganizationService) {
super(cipherService, folderService, i18nService, platformUtilsService, auditService, stateService,
userService, collectionService, messagingService, eventService, policyService, logService);
collectionService, messagingService, eventService, policyService, logService, activeAccountService,
organizationService);
}
async ngOnInit() {

View File

@@ -1,12 +1,12 @@
import { Component } from '@angular/core';
import { ActiveAccountService } from 'jslib-common/abstractions/activeAccount.service';
import { ApiService } from 'jslib-common/abstractions/api.service';
import { CipherService } from 'jslib-common/abstractions/cipher.service';
import { CryptoService } from 'jslib-common/abstractions/crypto.service';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { LogService } from 'jslib-common/abstractions/log.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { AttachmentsComponent as BaseAttachmentsComponent } from 'jslib-angular/components/attachments.component';
@@ -16,10 +16,10 @@ import { AttachmentsComponent as BaseAttachmentsComponent } from 'jslib-angular/
})
export class AttachmentsComponent extends BaseAttachmentsComponent {
constructor(cipherService: CipherService, i18nService: I18nService,
cryptoService: CryptoService, userService: UserService,
platformUtilsService: PlatformUtilsService, apiService: ApiService,
logService: LogService) {
super(cipherService, i18nService, cryptoService, userService, platformUtilsService,
apiService, window, logService);
cryptoService: CryptoService, platformUtilsService: PlatformUtilsService,
apiService: ApiService, logService: LogService,
activeAccountService: ActiveAccountService) {
super(cipherService, i18nService, cryptoService, platformUtilsService,
apiService, window, logService, activeAccountService);
}
}

View File

@@ -27,11 +27,10 @@ const BroadcasterSubscriptionId = 'ExportComponent';
export class ExportComponent extends BaseExportComponent implements OnInit {
constructor(cryptoService: CryptoService, i18nService: I18nService,
platformUtilsService: PlatformUtilsService, exportService: ExportService,
eventService: EventService, policyService: PolicyService,
private broadcasterService: BroadcasterService, private ngZone: NgZone,
eventService: EventService, private broadcasterService: BroadcasterService,
private ngZone: NgZone, policyService: PolicyService,
logService: LogService) {
super(cryptoService, i18nService, platformUtilsService, exportService, eventService,
policyService, window, logService);
super(cryptoService, i18nService, platformUtilsService, exportService, eventService, policyService, window, logService);
}
async ngOnInit() {

View File

@@ -1,9 +1,8 @@
import { Component } from '@angular/core';
import { ActiveAccountService } from 'jslib-common/abstractions/activeAccount.service';
import { CollectionService } from 'jslib-common/abstractions/collection.service';
import { FolderService } from 'jslib-common/abstractions/folder.service';
import { StorageService } from 'jslib-common/abstractions/storage.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { GroupingsComponent as BaseGroupingsComponent } from 'jslib-angular/components/groupings.component';
@@ -13,7 +12,7 @@ import { GroupingsComponent as BaseGroupingsComponent } from 'jslib-angular/comp
})
export class GroupingsComponent extends BaseGroupingsComponent {
constructor(collectionService: CollectionService, folderService: FolderService,
storageService: StorageService, userService: UserService) {
super(collectionService, folderService, storageService, userService);
activeAccountService: ActiveAccountService) {
super(collectionService, folderService, activeAccountService);
}
}

View File

@@ -1,11 +1,12 @@
import { Component } from '@angular/core';
import { ActiveAccountService } from 'jslib-common/abstractions/activeAccount.service';
import { CipherService } from 'jslib-common/abstractions/cipher.service';
import { CollectionService } from 'jslib-common/abstractions/collection.service';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { LogService } from 'jslib-common/abstractions/log.service';
import { OrganizationService } from 'jslib-common/abstractions/organization.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { ShareComponent as BaseShareComponent } from 'jslib-angular/components/share.component';
@@ -15,9 +16,10 @@ import { ShareComponent as BaseShareComponent } from 'jslib-angular/components/s
})
export class ShareComponent extends BaseShareComponent {
constructor(cipherService: CipherService, i18nService: I18nService,
collectionService: CollectionService, userService: UserService,
platformUtilsService: PlatformUtilsService, logService: LogService) {
super(collectionService, platformUtilsService, i18nService, userService, cipherService,
logService);
collectionService: CollectionService, platformUtilsService: PlatformUtilsService,
logService: LogService, activeAccountService: ActiveAccountService,
organizationService: OrganizationService) {
super(collectionService, platformUtilsService, i18nService, cipherService,
logService, activeAccountService, organizationService);
}
}

View File

@@ -38,7 +38,7 @@ import { FolderView } from 'jslib-common/models/view/folderView';
import { ModalRef } from 'jslib-angular/components/modal/modal.ref';
import { ModalService } from 'jslib-angular/services/modal.service';
import { ActiveAccountService } from 'jslib-common/abstractions/activeAccount.service';
import { EventService } from 'jslib-common/abstractions/event.service';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { MessagingService } from 'jslib-common/abstractions/messaging.service';
@@ -46,7 +46,9 @@ import { PasswordRepromptService } from 'jslib-common/abstractions/passwordRepro
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { SyncService } from 'jslib-common/abstractions/sync.service';
import { TotpService } from 'jslib-common/abstractions/totp.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { ModalService } from 'jslib-angular/services/modal.service';
import { invokeMenu, RendererMenuItem } from 'jslib-electron/utils';
const BroadcasterSubscriptionId = 'VaultComponent';
@@ -88,11 +90,11 @@ export class VaultComponent implements OnInit, OnDestroy {
private ngZone: NgZone, private syncService: SyncService,
private toasterService: ToasterService, private messagingService: MessagingService,
private platformUtilsService: PlatformUtilsService, private eventService: EventService,
private totpService: TotpService, private userService: UserService,
private passwordRepromptService: PasswordRepromptService) { }
private totpService: TotpService, private passwordRepromptService: PasswordRepromptService,
private activeAccount: ActiveAccountService) { }
async ngOnInit() {
this.userHasPremiumAccess = await this.userService.canAccessPremium();
this.userHasPremiumAccess = this.activeAccount.canAccessPremium;
this.broadcasterService.subscribe(BroadcasterSubscriptionId, (message: any) => {
this.ngZone.run(async () => {
let detectChanges = true;

View File

@@ -7,6 +7,7 @@ import {
Output,
} from '@angular/core';
import { ActiveAccountService } from 'jslib-common/abstractions/activeAccount.service';
import { ApiService } from 'jslib-common/abstractions/api.service';
import { AuditService } from 'jslib-common/abstractions/audit.service';
import { CipherService } from 'jslib-common/abstractions/cipher.service';
@@ -19,7 +20,6 @@ import { PasswordRepromptService } from 'jslib-common/abstractions/passwordRepro
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { TokenService } from 'jslib-common/abstractions/token.service';
import { TotpService } from 'jslib-common/abstractions/totp.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { BroadcasterService } from 'jslib-angular/services/broadcaster.service';
@@ -41,12 +41,12 @@ export class ViewComponent extends BaseViewComponent implements OnChanges {
cryptoService: CryptoService, platformUtilsService: PlatformUtilsService,
auditService: AuditService, broadcasterService: BroadcasterService,
ngZone: NgZone, changeDetectorRef: ChangeDetectorRef,
userService: UserService, eventService: EventService, apiService: ApiService,
eventService: EventService, apiService: ApiService,
private messagingService: MessagingService, passwordRepromptService: PasswordRepromptService,
logService: LogService) {
logService: LogService, activeAccountService: ActiveAccountService) {
super(cipherService, totpService, tokenService, i18nService, cryptoService, platformUtilsService,
auditService, window, broadcasterService, ngZone, changeDetectorRef, userService, eventService,
apiService, passwordRepromptService, logService);
auditService, window, broadcasterService, ngZone, changeDetectorRef, eventService,
apiService, passwordRepromptService, logService, activeAccountService);
}
ngOnInit() {
super.ngOnInit();

View File

@@ -7,24 +7,33 @@ import { MenuMain } from './main/menu.main';
import { MessagingMain } from './main/messaging.main';
import { PowerMonitorMain } from './main/powerMonitor.main';
import { ConstantsService } from 'jslib-common/services/constants.service';
import { BiometricMain } from 'jslib-common/abstractions/biometric.main';
import { ElectronConstants } from 'jslib-electron/electronConstants';
import { KeytarStorageListener } from 'jslib-electron/keytarStorageListener';
import { ElectronLogService } from 'jslib-electron/services/electronLog.service';
import { ElectronMainMessagingService } from 'jslib-electron/services/electronMainMessaging.service';
import { ElectronStorageService } from 'jslib-electron/services/electronStorage.service';
import { TrayMain } from 'jslib-electron/tray.main';
import { UpdaterMain } from 'jslib-electron/updater.main';
import { WindowMain } from 'jslib-electron/window.main';
import { NativeMessagingMain } from './main/nativeMessaging.main';
import { StorageKey } from 'jslib-common/enums/storageKey';
import { AccountsManagementService } from 'jslib-common/services/accountsManagement.service';
import { ActiveAccountService } from 'jslib-common/services/activeAccount.service';
import { StoreService } from 'jslib-common/services/store.service';
export class Main {
logService: ElectronLogService;
i18nService: I18nService;
storageService: ElectronStorageService;
messagingService: ElectronMainMessagingService;
accountsManagementService: AccountsManagementService;
activeAccount: ActiveAccountService;
storeService: StoreService;
keytarStorageListener: KeytarStorageListener;
windowMain: WindowMain;
@@ -69,9 +78,12 @@ export class Main {
const storageDefaults: any = {};
// Default vault timeout to "on restart", and action to "lock"
storageDefaults[ConstantsService.vaultTimeoutKey] = -1;
storageDefaults[ConstantsService.vaultTimeoutActionKey] = 'lock';
storageDefaults[StorageKey.VaultTimeout] = -1;
storageDefaults[StorageKey.VaultTimeoutAction] = 'lock';
this.storageService = new ElectronStorageService(app.getPath('userData'), storageDefaults);
this.accountsManagementService = new AccountsManagementService(this.storageService, null);
this.storeService = new StoreService(this.storageService, null);
this.activeAccount = new ActiveAccountService(this.accountsManagementService, this.storeService);
this.windowMain = new WindowMain(this.storageService, this.logService, true, undefined, undefined,
arg => this.processDeepLink(arg), win => this.trayMain.setupWindowListeners(win));
@@ -94,10 +106,10 @@ export class Main {
if (process.platform === 'win32') {
const BiometricWindowsMain = require('jslib-electron/biometric.windows.main').default;
this.biometricMain = new BiometricWindowsMain(this.storageService, this.i18nService, this.windowMain);
this.biometricMain = new BiometricWindowsMain(this.i18nService, this.windowMain, this.storageService);
} else if (process.platform === 'darwin') {
const BiometricDarwinMain = require('jslib-electron/biometric.darwin.main').default;
this.biometricMain = new BiometricDarwinMain(this.storageService, this.i18nService);
this.biometricMain = new BiometricDarwinMain(this.i18nService, this.storageService);
}
this.keytarStorageListener = new KeytarStorageListener('Bitwarden', this.biometricMain);
@@ -108,7 +120,7 @@ export class Main {
bootstrap() {
this.keytarStorageListener.init();
this.windowMain.init().then(async () => {
const locale = await this.storageService.get<string>(ConstantsService.localeKey);
const locale = await this.activeAccount.getInformation<string>(StorageKey.Locale);
await this.i18nService.init(locale != null ? locale : app.getLocale());
this.messagingMain.init();
this.menuMain.init();
@@ -118,7 +130,7 @@ export class Main {
id: 'lockNow',
click: () => this.messagingService.send('lockVault'),
}]);
if (await this.storageService.get<boolean>(ElectronConstants.enableStartToTrayKey)) {
if (await this.activeAccount.getInformation<boolean>(StorageKey.EnableStartToTrayKey)) {
this.trayMain.hideToTray();
}
this.powerMonitorMain.init();
@@ -127,7 +139,7 @@ export class Main {
await this.biometricMain.init();
}
if (await this.storageService.get<boolean>(ElectronConstants.enableBrowserIntegration)) {
if (await this.activeAccount.getInformation<boolean>(StorageKey.EnableBrowserIntegration)) {
this.nativeMessagingMain.listen();
}

View File

@@ -1,9 +1,7 @@
import {
app,
BrowserWindow,
clipboard,
dialog,
ipcMain,
Menu,
MenuItem,
MenuItemConstructorOptions,
@@ -12,12 +10,12 @@ import {
import { Main } from '../main';
import { StorageKey } from 'jslib-common/enums/storageKey';
import { BaseMenu } from 'jslib-electron/baseMenu';
import { isMacAppStore, isSnapStore, isWindowsStore } from 'jslib-electron/utils';
import { ConstantsService } from 'jslib-common/services/constants.service';
export class MenuMain extends BaseMenu {
menu: Menu;
updateMenuItem: MenuItem;
@@ -506,7 +504,7 @@ export class MenuMain extends BaseMenu {
private async openWebVault() {
let webUrl = 'https://vault.bitwarden.com';
const urlsObj: any = await this.main.storageService.get(ConstantsService.environmentUrlsKey);
const urlsObj: any = await this.main.activeAccount.getInformation(StorageKey.EnvironmentUrls);
if (urlsObj != null) {
if (urlsObj.base != null) {
webUrl = urlsObj.base;

View File

@@ -4,10 +4,10 @@ import * as path from 'path';
import { Main } from '../main';
import { ElectronConstants } from 'jslib-electron/electronConstants';
import { StorageService } from 'jslib-common/abstractions/storage.service';
import { StorageKey } from 'jslib-common/enums/storageKey';
const SyncInterval = 5 * 60 * 1000; // 5 minutes
export class MessagingMain {
@@ -18,10 +18,10 @@ export class MessagingMain {
init() {
this.scheduleNextSync();
if (process.platform === 'linux') {
this.storageService.save(ElectronConstants.openAtLogin, fs.existsSync(this.linuxStartupFile()));
this.storageService.save(StorageKey.OpenAtLogin, fs.existsSync(this.linuxStartupFile()));
} else {
const loginSettings = app.getLoginItemSettings();
this.storageService.save(ElectronConstants.openAtLogin, loginSettings.openAtLogin);
this.storageService.save(StorageKey.OpenAtLogin, loginSettings.openAtLogin);
}
ipcMain.on('messagingService', async (event: any, message: any) => this.onMessage(message));
}
@@ -36,7 +36,7 @@ export class MessagingMain {
this.updateTrayMenu(message.isAuthenticated, message.isLocked);
break;
case 'minimizeOnCopy':
this.storageService.get<boolean>(ElectronConstants.minimizeOnCopyToClipboardKey).then(
this.storageService.get<boolean>(StorageKey.MinimizeOnCopyToClipboardKey).then(
shouldMinimize => {
if (shouldMinimize && this.main.windowMain.win !== null) {
this.main.windowMain.win.minimize();

View File

@@ -1,6 +1,6 @@
import { powerMonitor } from 'electron';
import { ConstantsService } from 'jslib-common/services/constants.service';
import { StorageKey } from 'jslib-common/enums/storageKey';
import { isSnapStore } from 'jslib-electron/utils';
@@ -60,8 +60,8 @@ export class PowerMonitorMain {
}
private async getVaultTimeoutOptions(): Promise<[number, string]> {
const timeout = await this.main.storageService.get<number>(ConstantsService.vaultTimeoutKey);
const action = await this.main.storageService.get<string>(ConstantsService.vaultTimeoutActionKey);
const timeout = await this.main.activeAccount.getInformation<number>(StorageKey.VaultTimeout);
const action = await this.main.activeAccount.getInformation<string>(StorageKey.VaultTimeoutAction);
return [timeout, action];
}
}

View File

@@ -1,19 +1,20 @@
import { ipcRenderer } from 'electron';
import Swal from 'sweetalert2';
import { ActiveAccountService } from 'jslib-common/abstractions/activeAccount.service';
import { CryptoService } from 'jslib-common/abstractions/crypto.service';
import { CryptoFunctionService } from 'jslib-common/abstractions/cryptoFunction.service';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { LogService } from 'jslib-common/abstractions/log.service';
import { MessagingService } from 'jslib-common/abstractions/messaging.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { StorageService } from 'jslib-common/abstractions/storage.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { VaultTimeoutService } from 'jslib-common/abstractions/vaultTimeout.service';
import { Utils } from 'jslib-common/misc/utils';
import { SymmetricCryptoKey } from 'jslib-common/models/domain/symmetricCryptoKey';
import { ElectronConstants } from 'jslib-electron/electronConstants';
import { StorageKey } from 'jslib-common/enums/storageKey';
const MessageValidTimeout = 10 * 1000;
const EncryptionAlgorithm = 'sha1';
@@ -23,9 +24,9 @@ export class NativeMessagingService {
constructor(private cryptoFunctionService: CryptoFunctionService, private cryptoService: CryptoService,
private platformUtilService: PlatformUtilsService, private logService: LogService,
private i18nService: I18nService, private userService: UserService, private messagingService: MessagingService,
private vaultTimeoutService: VaultTimeoutService, private storageService: StorageService) {
ipcRenderer.on('nativeMessaging', async (event: any, message: any) => {
private i18nService: I18nService, private messagingService: MessagingService,
private vaultTimeoutService: VaultTimeoutService, private activeAccount: ActiveAccountService) {
ipcRenderer.on('nativeMessaging', async (_event: any, message: any) => {
this.messageHandler(message);
});
}
@@ -39,15 +40,15 @@ export class NativeMessagingService {
const remotePublicKey = Utils.fromB64ToArray(rawMessage.publicKey).buffer;
// Valudate the UserId to ensure we are logged into the same account.
if (rawMessage.userId !== await this.userService.getUserId()) {
if (rawMessage.userId !== this.activeAccount.userId) {
ipcRenderer.send('nativeMessagingReply', {command: 'wrongUserId', appId: appId});
return;
}
if (await this.storageService.get<boolean>(ElectronConstants.enableBrowserIntegrationFingerprint)) {
if (await this.activeAccount.getInformation<boolean>(StorageKey.EnableBrowserIntegrationFingerprint)) {
ipcRenderer.send('nativeMessagingReply', {command: 'verifyFingerprint', appId: appId});
const fingerprint = (await this.cryptoService.getFingerprint(await this.userService.getUserId(), remotePublicKey)).join(' ');
const fingerprint = (await this.cryptoService.getFingerprint(this.activeAccount.userId, remotePublicKey)).join(' ');
this.messagingService.send('setFocus');
@@ -102,7 +103,7 @@ export class NativeMessagingService {
});
}
const keyB64 = await (await this.cryptoService.getKeyFromStorage('biometric')).keyB64;
const keyB64 = (await this.cryptoService.getKeyFromStorage('biometric')).keyB64;
if (keyB64 != null) {
this.send({ command: 'biometricUnlock', response: 'unlocked', keyB64: keyB64 }, appId);