[refactor] Replace references to deprecated services

Several refactors were done on the data storage layer of jslib to support Account Switching for desktop.
These changes have been implemented here for parity across clients, improved readability, and to make it easier
to add Account Switching to other clients later if desired.

* The UserService was removed, and so all references have been replaced with the new access points for that data (activeAccount and organizationService most often)
* The StorageService is now considered a "global" scope, where as we have a new "account" scope to consider. Any "account" scope storage items I have moved to saving with
an ActiveAccountService instance instead of a StorageService instance.
* ConstantsServices have been removed and replaced with a StorageKey enum that holds keys that were in ConstantServices and in other feature scoped services.
This commit is contained in:
addison 2021-10-08 16:30:18 -04:00
parent ddfb02e938
commit 85e3436de6
28 changed files with 309 additions and 269 deletions

View File

@ -1,8 +1,8 @@
import { ActiveAccountService } from 'jslib-common/abstractions/activeAccount.service';
import { NotificationsService } from 'jslib-common/abstractions/notifications.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 { StorageKey } from 'jslib-common/enums/storageKey';
const IdleInterval = 60 * 5; // 5 minutes
@ -11,7 +11,7 @@ export default class IdleBackground {
private idleTimer: number = null;
private idleState = 'active';
constructor(private vaultTimeoutService: VaultTimeoutService, private storageService: StorageService,
constructor(private vaultTimeoutService: VaultTimeoutService, private activeAccount: ActiveAccountService,
private notificationsService: NotificationsService) {
this.idle = chrome.idle || (browser != null ? browser.idle : null);
}
@ -38,9 +38,9 @@ export default class IdleBackground {
if (this.idle.onStateChanged) {
this.idle.onStateChanged.addListener(async (newState: string) => {
if (newState === 'locked') { // If the screen is locked or the screensaver activates
const timeout = await this.storageService.get<number>(ConstantsService.vaultTimeoutKey);
const timeout = await this.activeAccount.getInformation<number>(StorageKey.VaultTimeout);
if (timeout === -2) { // On System Lock vault timeout option
const action = await this.storageService.get<string>(ConstantsService.vaultTimeoutActionKey);
const action = await this.activeAccount.getInformation<string>(StorageKey.VaultTimeoutAction);
if (action === 'logOut') {
await this.vaultTimeoutService.logOut();
} else {

View File

@ -1,6 +1,9 @@
import { CipherRepromptType } from 'jslib-common/enums/cipherRepromptType';
import { CipherType } from 'jslib-common/enums/cipherType';
import { StorageKey } from 'jslib-common/enums/storageKey';
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';
@ -8,7 +11,6 @@ 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 { ConsoleLogService } from 'jslib-common/services/consoleLog.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';
@ -16,19 +18,23 @@ 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 { WebCryptoFunctionService } from 'jslib-common/services/webCryptoFunction.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 { AppIdService as AppIdServiceAbstraction } from 'jslib-common/abstractions/appId.service';
import { AuditService as AuditServiceAbstraction } from 'jslib-common/abstractions/audit.service';
@ -46,9 +52,11 @@ 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 { 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';
@ -58,7 +66,6 @@ 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 { AutofillService as AutofillServiceAbstraction } from '../services/abstractions/autofill.service';
@ -91,7 +98,6 @@ export default class MainBackground {
secureStorageService: StorageServiceAbstraction;
i18nService: I18nServiceAbstraction;
platformUtilsService: PlatformUtilsServiceAbstraction;
constantsService: ConstantsService;
logService: LogServiceAbstraction;
cryptoService: CryptoServiceAbstraction;
cryptoFunctionService: CryptoFunctionServiceAbstraction;
@ -99,7 +105,6 @@ export default class MainBackground {
appIdService: AppIdServiceAbstraction;
apiService: ApiServiceAbstraction;
environmentService: EnvironmentServiceAbstraction;
userService: UserServiceAbstraction;
settingsService: SettingsServiceAbstraction;
cipherService: CipherServiceAbstraction;
folderService: FolderServiceAbstraction;
@ -122,6 +127,10 @@ export default class MainBackground {
popupUtilsService: PopupUtilsService;
sendService: SendServiceAbstraction;
fileUploadService: FileUploadServiceAbstraction;
activeAccount: ActiveAccountServiceAbstraction;
accountsManagementService: AccountsManagementServiceAbstraction;
organizationService: OrganizationServiceAbstraction;
providerService: ProviderServiceAbstraction;
onUpdatedRan: boolean;
onReplacedRan: boolean;
@ -147,7 +156,11 @@ export default class MainBackground {
// Services
this.messagingService = new BrowserMessagingService();
this.storageService = new BrowserStorageService();
this.platformUtilsService = new BrowserPlatformUtilsService(this.messagingService, this.storageService,
this.secureStorageService = new BrowserStorageService();
const storeService = new StoreService(this.storageService, this.secureStorageService);
this.accountsManagementService = new AccountsManagementService(this.storageService, this.secureStorageService);
this.activeAccount = new ActiveAccountService(this.accountsManagementService, storeService);
this.platformUtilsService = new BrowserPlatformUtilsService(this.messagingService, this.activeAccount,
(clipboardValue, clearMs) => {
if (this.systemService != null) {
this.systemService.clearClipboard(clipboardValue, clearMs);
@ -166,35 +179,37 @@ export default class MainBackground {
return promise.then(result => result.response === 'unlocked');
}
});
this.secureStorageService = new BrowserStorageService();
this.i18nService = new I18nService(BrowserApi.getUILanguage(window));
this.cryptoFunctionService = new WebCryptoFunctionService(window, this.platformUtilsService);
this.logService = new ConsoleLogService(false);
this.cryptoService = new BrowserCryptoService(this.storageService, this.secureStorageService,
this.cryptoFunctionService, this.platformUtilsService, this.logService);
this.tokenService = new TokenService(this.storageService);
this.cryptoService = new BrowserCryptoService(this.cryptoFunctionService, this.platformUtilsService,
this.logService, this.activeAccount);
this.tokenService = new TokenService(this.activeAccount);
this.appIdService = new AppIdService(this.storageService);
this.environmentService = new EnvironmentService(this.storageService);
this.environmentService = new EnvironmentService(this.activeAccount);
this.apiService = new ApiService(this.tokenService, this.platformUtilsService, this.environmentService,
(expired: boolean) => this.logout(expired));
this.userService = new UserService(this.tokenService, this.storageService);
this.settingsService = new SettingsService(this.userService, this.storageService);
this.settingsService = new SettingsService(this.activeAccount);
this.fileUploadService = new FileUploadService(this.logService, this.apiService);
this.cipherService = new CipherService(this.cryptoService, this.userService, this.settingsService,
this.apiService, this.fileUploadService, this.storageService, this.i18nService, () => this.searchService);
this.folderService = new FolderService(this.cryptoService, this.userService, this.apiService,
this.storageService, this.i18nService, this.cipherService);
this.collectionService = new CollectionService(this.cryptoService, this.userService, this.storageService,
this.i18nService);
this.cipherService = new CipherService(this.cryptoService, this.settingsService,
this.apiService, this.fileUploadService,
this.i18nService, () => this.searchService,
this.activeAccount);
this.folderService = new FolderService(this.cryptoService, this.apiService,
this.i18nService, this.cipherService,
this.activeAccount);
this.collectionService = new CollectionService(this.cryptoService, this.i18nService,
this.activeAccount);
this.searchService = new SearchService(this.cipherService, this.logService, this.i18nService);
this.sendService = new SendService(this.cryptoService, this.userService, this.apiService, this.fileUploadService,
this.storageService, this.i18nService, this.cryptoFunctionService);
this.sendService = new SendService(this.cryptoService, this.apiService,
this.fileUploadService, this.i18nService,
this.cryptoFunctionService, this.activeAccount);
this.stateService = new StateService();
this.policyService = new PolicyService(this.userService, this.storageService);
this.vaultTimeoutService = new VaultTimeoutService(this.cipherService, this.folderService,
this.collectionService, this.cryptoService, this.platformUtilsService, this.storageService,
this.messagingService, this.searchService, this.userService, this.tokenService, this.policyService,
async () => {
this.organizationService = new OrganizationService(this.activeAccount);
this.policyService = new PolicyService(this.activeAccount, this.organizationService);
const vaultTimeoutServiceCallbacks = {
locked: async () => {
if (this.notificationsService != null) {
this.notificationsService.updateConnection(false);
}
@ -204,32 +219,49 @@ export default class MainBackground {
this.systemService.startProcessReload();
await this.systemService.clearPendingClipboard();
}
}, async () => await this.logout(false));
this.syncService = new SyncService(this.userService, this.apiService, this.settingsService,
this.folderService, this.cipherService, this.cryptoService, this.collectionService,
this.storageService, this.messagingService, this.policyService, this.sendService,
async (expired: boolean) => await this.logout(expired));
this.eventService = new EventService(this.storageService, this.apiService, this.userService,
this.cipherService);
this.passwordGenerationService = new PasswordGenerationService(this.cryptoService, this.storageService,
this.policyService);
this.totpService = new TotpService(this.storageService, this.cryptoFunctionService);
this.autofillService = new AutofillService(this.cipherService, this.userService, this.totpService,
this.eventService);
},
logout: async () => await this.logout(false),
};
this.vaultTimeoutService = new VaultTimeoutService(this.cipherService, this.folderService,
this.collectionService, this.cryptoService,
this.platformUtilsService, this.messagingService,
this.searchService, this.tokenService,
this.policyService, this.activeAccount,
vaultTimeoutServiceCallbacks.locked, vaultTimeoutServiceCallbacks.logout);
this.providerService = new ProviderService(this.activeAccount);
this.syncService = new SyncService(this.apiService, this.settingsService,
this.folderService, this.cipherService,
this.cryptoService, this.collectionService,
this.messagingService, this.policyService,
this.sendService, async (expired: boolean) => await this.logout(expired),
this.activeAccount, this.organizationService,
this.providerService);
this.eventService = new EventService(this.apiService, this.cipherService,
this.activeAccount, this.organizationService);
this.passwordGenerationService = new PasswordGenerationService(this.cryptoService, this.policyService,
this.activeAccount);
this.totpService = new TotpService(this.cryptoFunctionService, this.activeAccount);
this.autofillService = new AutofillService(this.cipherService, this.activeAccount,
this.totpService, this.eventService);
this.containerService = new ContainerService(this.cryptoService);
this.auditService = new AuditService(this.cryptoFunctionService, this.apiService);
this.exportService = new ExportService(this.folderService, this.cipherService, this.apiService,
this.cryptoService);
this.notificationsService = new NotificationsService(this.userService, this.syncService, this.appIdService,
this.apiService, this.vaultTimeoutService, this.environmentService, () => this.logout(true), this.logService);
this.notificationsService = new NotificationsService(this.syncService, this.appIdService,
this.apiService, this.vaultTimeoutService,
this.environmentService, () => this.logout(true),
this.logService, this.activeAccount);
this.popupUtilsService = new PopupUtilsService(this.platformUtilsService);
this.systemService = new SystemService(this.storageService, this.vaultTimeoutService,
this.messagingService, this.platformUtilsService, () => {
const forceWindowReload = this.platformUtilsService.isSafari() ||
this.platformUtilsService.isFirefox() || this.platformUtilsService.isOpera();
BrowserApi.reloadExtension(forceWindowReload ? window : null);
return Promise.resolve();
});
const systemUtilsServiceReloadCallback = () => {
const forceWindowReload = this.platformUtilsService.isSafari() ||
this.platformUtilsService.isFirefox() || this.platformUtilsService.isOpera();
BrowserApi.reloadExtension(forceWindowReload ? window : null);
return Promise.resolve();
};
this.systemService = new SystemService(this.vaultTimeoutService,
this.messagingService, this.platformUtilsService, systemUtilsServiceReloadCallback, this.activeAccount);
// Other fields
this.isSafari = this.platformUtilsService.isSafari();
@ -238,34 +270,42 @@ export default class MainBackground {
// Background
this.runtimeBackground = new RuntimeBackground(this, this.autofillService, this.cipherService,
this.platformUtilsService as BrowserPlatformUtilsService, this.storageService, this.i18nService,
this.notificationsService, this.systemService, this.vaultTimeoutService,
this.environmentService, this.policyService, this.userService, this.messagingService, this.folderService);
this.nativeMessagingBackground = new NativeMessagingBackground(this.storageService, this.cryptoService, this.cryptoFunctionService,
this.vaultTimeoutService, this.runtimeBackground, this.i18nService, this.userService, this.messagingService, this.appIdService,
this.platformUtilsService);
this.platformUtilsService as BrowserPlatformUtilsService, this.storageService,
this.i18nService, this.notificationsService,
this.systemService, this.vaultTimeoutService,
this.environmentService, this.policyService,
this.messagingService, this.folderService);
this.nativeMessagingBackground = new NativeMessagingBackground(this.storageService, this.cryptoService,
this.cryptoFunctionService, this.vaultTimeoutService,
this.runtimeBackground, this.i18nService,
this.messagingService, this.appIdService,
this.platformUtilsService, this.activeAccount);
this.commandsBackground = new CommandsBackground(this, this.passwordGenerationService,
this.platformUtilsService, this.vaultTimeoutService);
this.tabsBackground = new TabsBackground(this);
this.contextMenusBackground = new ContextMenusBackground(this, this.cipherService, this.passwordGenerationService,
this.platformUtilsService, this.vaultTimeoutService, this.eventService, this.totpService);
this.idleBackground = new IdleBackground(this.vaultTimeoutService, this.storageService,
this.idleBackground = new IdleBackground(this.vaultTimeoutService, this.activeAccount,
this.notificationsService);
this.webRequestBackground = new WebRequestBackground(this.platformUtilsService, this.cipherService,
this.vaultTimeoutService);
this.windowsBackground = new WindowsBackground(this);
const that = this;
this.authService = new AuthService(this.cryptoService, this.apiService, this.userService,
this.tokenService, this.appIdService, this.i18nService, this.platformUtilsService,
new class extends MessagingServiceAbstraction {
// AuthService should send the messages to the background not popup.
send = (subscriber: string, arg: any = {}) => {
const message = Object.assign({}, { command: subscriber }, arg);
that.runtimeBackground.processMessage(message, that, null);
}
}(), this.vaultTimeoutService, this.logService);
const backgroundMessagingService = new class extends MessagingServiceAbstraction {
// AuthService should send the messages to the background not popup.
send = (subscriber: string, arg: any = {}) => {
const message = Object.assign({}, { command: subscriber }, arg);
that.runtimeBackground.processMessage(message, that, null);
}
}();
this.authService = new AuthService(this.cryptoService, this.apiService,
this.tokenService, this.appIdService,
this.i18nService, this.platformUtilsService,
backgroundMessagingService, this.vaultTimeoutService,
this.logService, this.activeAccount, this.accountsManagementService);
}
async bootstrap() {
@ -301,7 +341,7 @@ export default class MainBackground {
return;
}
const isAuthenticated = await this.userService.isAuthenticated();
const isAuthenticated = this.activeAccount.isAuthenticated;
const locked = await this.vaultTimeoutService.isLocked();
let suffix = '';
@ -320,7 +360,7 @@ export default class MainBackground {
return;
}
const menuDisabled = await this.storageService.get<boolean>(ConstantsService.disableContextMenuItemKey);
const menuDisabled = await this.storageService.get<boolean>(StorageKey.DisableContextMenuItem);
if (!menuDisabled) {
await this.buildContextMenu();
} else {
@ -341,14 +381,13 @@ export default class MainBackground {
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),
@ -422,7 +461,7 @@ export default class MainBackground {
return;
}
const currentVaultTimeout = await this.storageService.get<number>(ConstantsService.vaultTimeoutKey);
const currentVaultTimeout = await this.storageService.get<number>(StorageKey.VaultTimeout);
if (currentVaultTimeout == null) {
return;
}
@ -485,7 +524,7 @@ export default class MainBackground {
title: this.i18nService.t('copyPassword'),
});
if (await this.userService.canAccessPremium()) {
if (this.activeAccount.canAccessPremium) {
await this.contextMenusCreate({
type: 'normal',
id: 'copy-totp',
@ -545,7 +584,7 @@ export default class MainBackground {
});
}
const disableBadgeCounter = await this.storageService.get<boolean>(ConstantsService.disableBadgeCounterKey);
const disableBadgeCounter = await this.storageService.get<boolean>(StorageKey.DisableBadgeCounter);
let theText = '';
if (!disableBadgeCounter) {
@ -572,7 +611,7 @@ export default class MainBackground {
private async loadMenuAndUpdateBadgeForNoAccessState(contextMenuEnabled: boolean) {
if (contextMenuEnabled) {
const authed = await this.userService.isAuthenticated();
const authed = this.activeAccount.isAuthenticated;
await this.loadNoLoginsContextMenuOptions(this.i18nService.t(authed ? 'vaultLocked' : 'vaultLoggedOut'));
}
@ -641,7 +680,7 @@ export default class MainBackground {
});
}
const canAccessPremium = await this.userService.canAccessPremium();
const canAccessPremium = this.activeAccount.canAccessPremium;
if (canAccessPremium && (cipher == null || (cipher.login.totp && cipher.login.totp !== ''))) {
await this.contextMenusCreate({
type: 'normal',

View File

@ -1,3 +1,4 @@
import { ActiveAccountService } from 'jslib-common/abstractions/activeAccount.service';
import { AppIdService } from 'jslib-common/abstractions/appId.service';
import { CryptoService } from 'jslib-common/abstractions/crypto.service';
import { CryptoFunctionService } from 'jslib-common/abstractions/cryptoFunction.service';
@ -5,9 +6,9 @@ import { I18nService } from 'jslib-common/abstractions/i18n.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 { ConstantsService } from 'jslib-common/services/constants.service';
import { StorageKey } from 'jslib-common/enums/storageKey';
import { Utils } from 'jslib-common/misc/utils';
import { SymmetricCryptoKey } from 'jslib-common/models/domain/symmetricCryptoKey';
@ -33,10 +34,10 @@ export class NativeMessagingBackground {
constructor(private storageService: StorageService, private cryptoService: CryptoService,
private cryptoFunctionService: CryptoFunctionService, private vaultTimeoutService: VaultTimeoutService,
private runtimeBackground: RuntimeBackground, private i18nService: I18nService, private userService: UserService,
private runtimeBackground: RuntimeBackground, private i18nService: I18nService,
private messagingService: MessagingService, private appIdService: AppIdService,
private platformUtilsService: PlatformUtilsService) {
this.storageService.save(ConstantsService.biometricFingerprintValidated, false);
private platformUtilsService: PlatformUtilsService, private activeAccount: ActiveAccountService) {
this.storageService.save(StorageKey.BiometricFingerprintValidated, false);
if (chrome?.permissions?.onAdded) {
// Reload extension to activate nativeMessaging
@ -48,7 +49,7 @@ export class NativeMessagingBackground {
async connect() {
this.appId = await this.appIdService.getAppId();
this.storageService.save(ConstantsService.biometricFingerprintValidated, false);
this.storageService.save(StorageKey.BiometricFingerprintValidated, false);
return new Promise<void>((resolve, reject) => {
this.port = BrowserApi.connectNative('com.8bit.bitwarden');
@ -96,7 +97,7 @@ export class NativeMessagingBackground {
if (this.validatingFingerprint) {
this.validatingFingerprint = false;
this.storageService.save(ConstantsService.biometricFingerprintValidated, true);
this.storageService.save(StorageKey.BiometricFingerprintValidated, true);
}
this.sharedSecret = new SymmetricCryptoKey(decrypted);
this.secureSetupResolve();
@ -233,7 +234,7 @@ export class NativeMessagingBackground {
switch (message.command) {
case 'biometricUnlock':
await this.storageService.remove(ConstantsService.biometricAwaitingAcceptance);
await this.storageService.remove(StorageKey.BiometricAwaitingAcceptance);
if (message.response === 'not enabled') {
this.messagingService.send('showDialog', {
@ -253,10 +254,10 @@ export class NativeMessagingBackground {
break;
}
const enabled = await this.storageService.get(ConstantsService.biometricUnlockKey);
const enabled = await this.storageService.get(StorageKey.BiometricUnlock);
if (enabled === null || enabled === false) {
if (message.response === 'unlocked') {
await this.storageService.save(ConstantsService.biometricUnlockKey, true);
await this.storageService.save(StorageKey.BiometricUnlock, true);
}
break;
}
@ -271,7 +272,7 @@ export class NativeMessagingBackground {
// Verify key is correct by attempting to decrypt a secret
try {
await this.cryptoService.getFingerprint(await this.userService.getUserId());
await this.cryptoService.getFingerprint(this.activeAccount.userId);
} catch (e) {
// tslint:disable-next-line
console.error('Unable to verify key:', e);
@ -304,7 +305,7 @@ export class NativeMessagingBackground {
this.sendUnencrypted({
command: 'setupEncryption',
publicKey: Utils.fromBufferToB64(publicKey),
userId: await this.userService.getUserId(),
userId: this.activeAccount.userId,
});
return new Promise((resolve, reject) => this.secureSetupResolve = resolve);
@ -321,7 +322,7 @@ export class NativeMessagingBackground {
}
private async showFingerprintDialog() {
const fingerprint = (await this.cryptoService.getFingerprint(await this.userService.getUserId(), this.publicKey)).join(' ');
const fingerprint = (await this.cryptoService.getFingerprint(this.activeAccount.userId, this.publicKey)).join(' ');
this.messagingService.send('showDialog', {
html: `${this.i18nService.t('desktopIntegrationVerificationText')}<br><br><strong>${fingerprint}</strong>`,

View File

@ -13,9 +13,7 @@ import { NotificationsService } from 'jslib-common/abstractions/notifications.se
import { PolicyService } from 'jslib-common/abstractions/policy.service';
import { StorageService } from 'jslib-common/abstractions/storage.service';
import { SystemService } from 'jslib-common/abstractions/system.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 { AutofillService } from '../services/abstractions/autofill.service';
import BrowserPlatformUtilsService from '../services/browserPlatformUtils.service';
@ -26,6 +24,7 @@ import MainBackground from './main.background';
import { Utils } from 'jslib-common/misc/utils';
import { PolicyType } from 'jslib-common/enums/policyType';
import { StorageKey } from 'jslib-common/enums/storageKey';
export default class RuntimeBackground {
private runtime: any;
@ -36,10 +35,9 @@ export default class RuntimeBackground {
constructor(private main: MainBackground, private autofillService: AutofillService,
private cipherService: CipherService, private platformUtilsService: BrowserPlatformUtilsService,
private storageService: StorageService, private i18nService: I18nService,
private notificationsService: NotificationsService,
private systemService: SystemService, private vaultTimeoutService: VaultTimeoutService,
private environmentService: EnvironmentService, private policyService: PolicyService,
private userService: UserService, private messagingService: MessagingService,
private notificationsService: NotificationsService, private systemService: SystemService,
private vaultTimeoutService: VaultTimeoutService, private environmentService: EnvironmentService,
private policyService: PolicyService, private messagingService: MessagingService,
private folderService: FolderService) {
// onInstalled listener must be wired up before anything else, so we do it in the ctor
@ -331,7 +329,7 @@ export default class RuntimeBackground {
c.login.username != null && c.login.username.toLowerCase() === normalizedUsername);
if (usernameMatches.length === 0) {
const disabledAddLogin = await this.storageService.get<boolean>(
ConstantsService.disableAddLoginNotificationKey);
StorageKey.DisableAddLoginNotification);
if (disabledAddLogin) {
return;
}
@ -354,7 +352,7 @@ export default class RuntimeBackground {
await this.main.checkNotificationQueue(tab);
} else if (usernameMatches.length === 1 && usernameMatches[0].login.password !== loginInfo.password) {
const disabledChangePassword = await this.storageService.get<boolean>(
ConstantsService.disableChangedPasswordNotificationKey);
StorageKey.DisableChangedPasswordNotification);
if (disabledChangePassword) {
return;
}
@ -424,30 +422,30 @@ export default class RuntimeBackground {
private async setDefaultSettings() {
// Default timeout option to "on restart".
const currentVaultTimeout = await this.storageService.get<number>(ConstantsService.vaultTimeoutKey);
const currentVaultTimeout = await this.storageService.get<number>(StorageKey.VaultTimeout);
if (currentVaultTimeout == null) {
await this.storageService.save(ConstantsService.vaultTimeoutKey, -1);
await this.storageService.save(StorageKey.VaultTimeout, -1);
}
// Default action to "lock".
const currentVaultTimeoutAction = await this.storageService.get<string>(ConstantsService.vaultTimeoutActionKey);
const currentVaultTimeoutAction = await this.storageService.get<string>(StorageKey.VaultTimeoutAction);
if (currentVaultTimeoutAction == null) {
await this.storageService.save(ConstantsService.vaultTimeoutActionKey, 'lock');
await this.storageService.save(StorageKey.VaultTimeoutAction, 'lock');
}
}
private async getDataForTab(tab: any, responseCommand: string) {
const responseData: any = {};
if (responseCommand === 'notificationBarDataResponse') {
responseData.neverDomains = await this.storageService.get<any>(ConstantsService.neverDomainsKey);
responseData.neverDomains = await this.storageService.get<any>(StorageKey.NeverDomains);
const disableAddLoginFromOptions = await this.storageService.get<boolean>(
ConstantsService.disableAddLoginNotificationKey);
StorageKey.DisableAddLoginNotification);
responseData.disabledAddLoginNotification = disableAddLoginFromOptions || !(await this.allowPersonalOwnership());
responseData.disabledChangedPasswordNotification = await this.storageService.get<boolean>(
ConstantsService.disableChangedPasswordNotificationKey);
StorageKey.DisableChangedPasswordNotification);
} else if (responseCommand === 'autofillerAutofillOnPageLoadEnabledResponse') {
responseData.autofillEnabled = await this.storageService.get<boolean>(
ConstantsService.enableAutoFillOnPageLoadKey);
StorageKey.EnableAutoFillOnPageLoad);
} else if (responseCommand === 'notificationBarFrameDataResponse') {
responseData.i18n = {
appName: this.i18nService.t('appName'),

View File

@ -1,22 +1,22 @@
import { Component } from '@angular/core';
import { ConstantsService } from 'jslib-common/services/constants.service';
import { ActiveAccountService } from 'jslib-common/abstractions/activeAccount.service';
import { CryptoFunctionService } from 'jslib-common/abstractions/cryptoFunction.service';
import { EnvironmentService } from 'jslib-common/abstractions/environment.service';
import { PasswordGenerationService } from 'jslib-common/abstractions/passwordGeneration.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { StorageService } from 'jslib-common/abstractions/storage.service';
import { Utils } from 'jslib-common/misc/utils';
import { StorageKey } from 'jslib-common/enums/storageKey';
@Component({
selector: 'app-home',
templateUrl: 'home.component.html',
})
export class HomeComponent {
constructor(protected platformUtilsService: PlatformUtilsService,
private passwordGenerationService: PasswordGenerationService, private storageService: StorageService,
private passwordGenerationService: PasswordGenerationService, private activeAccount: ActiveAccountService,
private cryptoFunctionService: CryptoFunctionService, private environmentService: EnvironmentService) { }
async launchSsoBrowser() {
@ -35,8 +35,8 @@ export class HomeComponent {
const codeVerifierHash = await this.cryptoFunctionService.hash(codeVerifier, 'sha256');
const codeChallenge = Utils.fromBufferToUrlB64(codeVerifierHash);
await this.storageService.save(ConstantsService.ssoCodeVerifierKey, codeVerifier);
await this.storageService.save(ConstantsService.ssoStateKey, state);
await this.activeAccount.saveInformation(StorageKey.SsoCodeVerifier, codeVerifier);
await this.activeAccount.saveInformation(StorageKey.SsoState, state);
let url = this.environmentService.getWebVaultUrl();
if (url == null) {

View File

@ -1,8 +1,7 @@
import { Component } from '@angular/core';
import { Router } from '@angular/router';
import { ConstantsService } from 'jslib-common/services/constants.service';
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';
@ -10,13 +9,13 @@ import { I18nService } from 'jslib-common/abstractions/i18n.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 { LockComponent as BaseLockComponent } from 'jslib-angular/components/lock.component';
import Swal from 'sweetalert2';
import { StorageKey } from 'jslib-common/enums/storageKey';
@Component({
selector: 'app-lock',
templateUrl: 'lock.component.html',
@ -26,20 +25,20 @@ export class LockComponent extends BaseLockComponent {
constructor(router: Router, i18nService: I18nService,
platformUtilsService: PlatformUtilsService, messagingService: MessagingService,
userService: UserService, cryptoService: CryptoService,
storageService: StorageService, vaultTimeoutService: VaultTimeoutService,
environmentService: EnvironmentService, stateService: StateService,
apiService: ApiService) {
super(router, i18nService, platformUtilsService, messagingService, userService, cryptoService,
storageService, vaultTimeoutService, environmentService, stateService, apiService);
activeAccount: ActiveAccountService, cryptoService: CryptoService,
vaultTimeoutService: VaultTimeoutService, environmentService: EnvironmentService,
stateService: StateService, apiService: ApiService) {
super(router, i18nService, platformUtilsService,
messagingService, cryptoService, vaultTimeoutService,
environmentService, stateService, apiService, activeAccount);
this.successRoute = '/tabs/current';
this.isInitialLockScreen = (window as any).previousPopupUrl == null;
}
async ngOnInit() {
await super.ngOnInit();
const disableAutoBiometricsPrompt = await this.storageService.get<boolean>(
ConstantsService.disableAutoBiometricsPromptKey) ?? true;
const disableAutoBiometricsPrompt = await this.activeAccount.getInformation<boolean>(
StorageKey.DisableAutoBiometricsPrompt) ?? true;
window.setTimeout(async () => {
document.getElementById(this.pinLock ? 'pin' : 'masterPassword').focus();

View File

@ -1,6 +1,7 @@
import { Component } from '@angular/core';
import { Router } from '@angular/router';
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';
@ -23,8 +24,10 @@ export class LoginComponent extends BaseLoginComponent {
protected stateService: StateService, protected environmentService: EnvironmentService,
protected passwordGenerationService: PasswordGenerationService,
protected cryptoFunctionService: CryptoFunctionService, storageService: StorageService,
syncService: SyncService) {
super(authService, router, platformUtilsService, i18nService, stateService, environmentService, passwordGenerationService, cryptoFunctionService, storageService);
syncService: SyncService, protected activeAccount: ActiveAccountService) {
super(authService, router, platformUtilsService, i18nService,
stateService, environmentService, passwordGenerationService, cryptoFunctionService,
storageService, activeAccount);
super.onSuccessfulLogin = async () => {
await syncService.fullSync(true);
};

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 { CryptoService } from 'jslib-common/abstractions/crypto.service';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
@ -13,7 +14,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 {
SetPasswordComponent as BaseSetPasswordComponent,
@ -26,11 +26,11 @@ import {
export class SetPasswordComponent extends BaseSetPasswordComponent {
constructor(apiService: ApiService, i18nService: I18nService,
cryptoService: CryptoService, messagingService: MessagingService,
userService: UserService, passwordGenerationService: PasswordGenerationService,
activeAccount: ActiveAccountService, passwordGenerationService: PasswordGenerationService,
platformUtilsService: PlatformUtilsService, policyService: PolicyService, router: Router,
syncService: SyncService, route: ActivatedRoute) {
super(i18nService, cryptoService, messagingService, userService, passwordGenerationService,
platformUtilsService, policyService, router, apiService, syncService, route);
super(i18nService, cryptoService, messagingService, passwordGenerationService,
platformUtilsService, policyService, router, apiService, syncService, route, activeAccount);
}
get masterPasswordScoreWidth() {

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';
@ -8,7 +9,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';
@ -55,10 +55,11 @@ export class UpdateTempPasswordComponent extends BaseUpdateTempPasswordComponent
constructor(i18nService: I18nService, platformUtilsService: PlatformUtilsService,
passwordGenerationService: PasswordGenerationService, policyService: PolicyService,
cryptoService: CryptoService, userService: UserService,
cryptoService: CryptoService, activeAccount: ActiveAccountService,
messagingService: MessagingService, apiService: ApiService,
syncService: SyncService) {
super(i18nService, platformUtilsService, passwordGenerationService, policyService, cryptoService,
userService, messagingService, apiService, syncService);
super(i18nService, platformUtilsService, passwordGenerationService, policyService,
cryptoService, messagingService, apiService, activeAccount,
syncService);
}
}

View File

@ -31,9 +31,8 @@ import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.se
import { StateService } from 'jslib-common/abstractions/state.service';
import { StorageService } from 'jslib-common/abstractions/storage.service';
import { ConstantsService } from 'jslib-common/services/constants.service';
import { StorageKey } from 'jslib-common/enums/storageKey';
import BrowserPlatformUtilsService from 'src/services/browserPlatformUtils.service';
import { routerTransition } from './app-routing.animations';
@Component({
@ -174,7 +173,7 @@ export class AppComponent implements OnInit {
}
this.lastActivity = now;
this.storageService.save(ConstantsService.lastActiveKey, now);
this.storageService.save(StorageKey.LastActive, now);
}
private showToast(msg: any) {

View File

@ -13,12 +13,12 @@ import { EventType } from 'jslib-common/enums/eventType';
import { CipherView } from 'jslib-common/models/view/cipherView';
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 { PasswordRepromptService } from 'jslib-common/abstractions/passwordReprompt.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { TotpService } from 'jslib-common/abstractions/totp.service';
import { UserService } from 'jslib-common/abstractions/user.service';
@Component({
selector: 'app-action-buttons',
@ -35,11 +35,11 @@ export class ActionButtonsComponent {
constructor(private toasterService: ToasterService, private i18nService: I18nService,
private platformUtilsService: PlatformUtilsService, private eventService: EventService,
private totpService: TotpService, private userService: UserService,
private totpService: TotpService, private activeAccount: ActiveAccountService,
private passwordRepromptService: PasswordRepromptService) { }
async ngOnInit() {
this.userHasPremiumAccess = await this.userService.canAccessPremium();
this.userHasPremiumAccess = this.activeAccount.canAccessPremium;
}
launchCipher() {

View File

@ -10,6 +10,7 @@ import {
Router,
} from '@angular/router';
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 { MessagingService } from 'jslib-common/abstractions/messaging.service';
@ -17,7 +18,6 @@ import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.se
import { PolicyService } from 'jslib-common/abstractions/policy.service';
import { SendService } from 'jslib-common/abstractions/send.service';
import { TokenService } from 'jslib-common/abstractions/token.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { PopupUtilsService } from '../services/popup-utils.service';
@ -38,12 +38,12 @@ export class SendAddEditComponent extends BaseAddEditComponent {
isUnsupportedMac = false;
constructor(i18nService: I18nService, platformUtilsService: PlatformUtilsService,
userService: UserService, messagingService: MessagingService, policyService: PolicyService,
activeAccount: ActiveAccountService, messagingService: MessagingService, policyService: PolicyService,
environmentService: EnvironmentService, datePipe: DatePipe, sendService: SendService,
private route: ActivatedRoute, private router: Router, private location: Location,
private popupUtilsService: PopupUtilsService) {
super(i18nService, platformUtilsService, environmentService, datePipe, sendService, userService,
messagingService, policyService);
super(i18nService, platformUtilsService, environmentService, datePipe,
sendService, messagingService, policyService, activeAccount);
}
get showFileSelector(): boolean {

View File

@ -20,7 +20,6 @@ import { SearchService } from 'jslib-common/abstractions/search.service';
import { SendService } from 'jslib-common/abstractions/send.service';
import { StateService } from 'jslib-common/abstractions/state.service';
import { SyncService } from 'jslib-common/abstractions/sync.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { BroadcasterService } from 'jslib-angular/services/broadcaster.service';
@ -47,12 +46,12 @@ export class SendGroupingsComponent extends BaseSendComponent {
constructor(sendService: SendService, i18nService: I18nService,
platformUtilsService: PlatformUtilsService, environmentService: EnvironmentService, ngZone: NgZone,
policyService: PolicyService, userService: UserService, searchService: SearchService,
policyService: PolicyService, searchService: SearchService,
private popupUtils: PopupUtilsService, private stateService: StateService,
private router: Router, private syncService: SyncService,
private changeDetectorRef: ChangeDetectorRef, private broadcasterService: BroadcasterService) {
super(sendService, i18nService, platformUtilsService, environmentService, ngZone, searchService,
policyService, userService);
policyService);
super.onSuccessfulLoad = async () => {
this.calculateTypeCounts();
this.selectAll();

View File

@ -22,7 +22,6 @@ 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 { StateService } from 'jslib-common/abstractions/state.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { BroadcasterService } from 'jslib-angular/services/broadcaster.service';
@ -45,12 +44,12 @@ export class SendTypeComponent extends BaseSendComponent {
constructor(sendService: SendService, i18nService: I18nService,
platformUtilsService: PlatformUtilsService, environmentService: EnvironmentService, ngZone: NgZone,
policyService: PolicyService, userService: UserService, searchService: SearchService,
policyService: PolicyService, searchService: SearchService,
private popupUtils: PopupUtilsService, private stateService: StateService,
private route: ActivatedRoute, private location: Location, private changeDetectorRef: ChangeDetectorRef,
private broadcasterService: BroadcasterService, private router: Router) {
super(sendService, i18nService, platformUtilsService, environmentService, ngZone, searchService,
policyService, userService);
policyService);
super.onSuccessfulLoad = async () => {
this.selectType(this.type);
};

View File

@ -19,6 +19,8 @@ import { ValidationService } from 'jslib-angular/services/validation.service';
import { BrowserApi } from '../../browser/browserApi';
import { AccountsManagementService } from 'jslib-common/abstractions/accountsManagement.service';
import { ActiveAccountService } from 'jslib-common/abstractions/activeAccount.service';
import { ApiService } from 'jslib-common/abstractions/api.service';
import { AppIdService } from 'jslib-common/abstractions/appId.service';
import { AuditService } from 'jslib-common/abstractions/audit.service';
@ -36,10 +38,12 @@ import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { LogService as LogServiceAbstraction } from 'jslib-common/abstractions/log.service';
import { MessagingService } from 'jslib-common/abstractions/messaging.service';
import { NotificationsService } from 'jslib-common/abstractions/notifications.service';
import { OrganizationService } from 'jslib-common/abstractions/organization.service';
import { PasswordGenerationService } from 'jslib-common/abstractions/passwordGeneration.service';
import { PasswordRepromptService as PasswordRepromptServiceAbstraction } from 'jslib-common/abstractions/passwordReprompt.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { PolicyService } from 'jslib-common/abstractions/policy.service';
import { ProviderService } from 'jslib-common/abstractions/provider.service';
import { SearchService as SearchServiceAbstraction } from 'jslib-common/abstractions/search.service';
import { SendService } from 'jslib-common/abstractions/send.service';
import { SettingsService } from 'jslib-common/abstractions/settings.service';
@ -48,7 +52,6 @@ import { StorageService } from 'jslib-common/abstractions/storage.service';
import { SyncService } from 'jslib-common/abstractions/sync.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 { VaultTimeoutService } from 'jslib-common/abstractions/vaultTimeout.service';
import { AutofillService } from '../../services/abstractions/autofill.service';
@ -56,13 +59,13 @@ import BrowserMessagingService from '../../services/browserMessaging.service';
import { AuthService } from 'jslib-common/services/auth.service';
import { ConsoleLogService } from 'jslib-common/services/consoleLog.service';
import { ConstantsService } from 'jslib-common/services/constants.service';
import { SearchService } from 'jslib-common/services/search.service';
import { StateService } from 'jslib-common/services/state.service';
import { PopupSearchService } from './popup-search.service';
import { PopupUtilsService } from './popup-utils.service';
import { StorageKey } from 'jslib-common/enums/storageKey';
import { ThemeType } from 'jslib-common/enums/themeType';
function getBgService<T>(service: string) {
@ -92,17 +95,17 @@ export function initFactory(platformUtilsService: PlatformUtilsService, i18nServ
}
if (!isPrivateMode) {
await stateService.save(ConstantsService.disableFaviconKey,
await storageService.get<boolean>(ConstantsService.disableFaviconKey));
await stateService.save(StorageKey.DisableFavicon,
await storageService.get<boolean>(StorageKey.DisableFavicon));
await stateService.save(ConstantsService.disableBadgeCounterKey,
await storageService.get<boolean>(ConstantsService.disableBadgeCounterKey));
await stateService.save(StorageKey.DisableBadgeCounter,
await storageService.get<boolean>(StorageKey.DisableBadgeCounter));
const htmlEl = window.document.documentElement;
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 storageService.get<ThemeType>(StorageKey.Theme);
if (bwTheme == null || bwTheme === ThemeType.System) {
htmlEl.classList.remove('theme_' + ThemeType.Light, 'theme_' + ThemeType.Dark);
htmlEl.classList.add('theme_' + sysTheme);
@ -162,7 +165,6 @@ export function initFactory(platformUtilsService: PlatformUtilsService, i18nServ
},
{ provide: ApiService, useFactory: getBgService<ApiService>('apiService'), deps: [] },
{ provide: SyncService, useFactory: getBgService<SyncService>('syncService'), deps: [] },
{ provide: UserService, useFactory: getBgService<UserService>('userService'), deps: [] },
{ provide: SettingsService, useFactory: getBgService<SettingsService>('settingsService'), deps: [] },
{ provide: StorageService, useFactory: getBgService<StorageService>('storageService'), deps: [] },
{ provide: AppIdService, useFactory: getBgService<AppIdService>('appIdService'), deps: [] },
@ -191,6 +193,11 @@ export function initFactory(platformUtilsService: PlatformUtilsService, i18nServ
deps: [],
},
{ provide: PasswordRepromptServiceAbstraction, useClass: PasswordRepromptService },
{ provide: PasswordRepromptServiceAbstraction, useClass: PasswordRepromptService },
{ provide: ActiveAccountService, useFactory: getBgService<ActiveAccountService>('activeAccount'), deps: [] },
{ provide: AccountsManagementService, useFactory: getBgService<AccountsManagementService>('accountsManagementService'), deps: [] },
{ provide: OrganizationService, useFactory: getBgService<OrganizationService>('organizationService'), deps: [] },
{ provide: ProviderService, useFactory: getBgService<ProviderService>('providerService'), deps: [] },
],
})
export class ServicesModule {

View File

@ -7,11 +7,11 @@ import {
import { Router } from '@angular/router';
import { ConstantsService } from 'jslib-common/services/constants.service';
import { StorageKey } from 'jslib-common/enums/storageKey';
import { ActiveAccountService } from 'jslib-common/abstractions/activeAccount.service';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { StorageService } from 'jslib-common/abstractions/storage.service';
import { BroadcasterService } from 'jslib-angular/services/broadcaster.service';
@ -35,14 +35,14 @@ export class ExcludedDomainsComponent implements OnInit, OnDestroy {
currentUris: string[];
loadCurrentUrisTimeout: number;
constructor(private storageService: StorageService,
constructor(private activeAccount: ActiveAccountService,
private i18nService: I18nService, private router: Router,
private broadcasterService: BroadcasterService, private ngZone: NgZone,
private platformUtilsService: PlatformUtilsService) {
}
async ngOnInit() {
const savedDomains = await this.storageService.get<any>(ConstantsService.neverDomainsKey);
const savedDomains = await this.activeAccount.getInformation<any>(StorageKey.NeverDomains);
if (savedDomains) {
for (const uri of Object.keys(savedDomains)) {
this.excludedDomains.push({ uri: uri, showCurrentUris: false });
@ -93,7 +93,7 @@ export class ExcludedDomainsComponent implements OnInit, OnDestroy {
savedDomains[validDomain] = null;
}
}
await this.storageService.save(ConstantsService.neverDomainsKey, savedDomains);
await this.activeAccount.saveInformation(StorageKey.NeverDomains, savedDomains);
this.router.navigate(['/tabs/settings']);
}
@ -114,3 +114,4 @@ export class ExcludedDomainsComponent implements OnInit, OnDestroy {
}
}
}

View File

@ -3,17 +3,15 @@ import {
OnInit,
} from '@angular/core';
import { StorageKey } from 'jslib-common/enums/storageKey';
import { ThemeType } from 'jslib-common/enums/themeType';
import { UriMatchType } from 'jslib-common/enums/uriMatchType';
import { ActiveAccountService } from 'jslib-common/abstractions/activeAccount.service';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { MessagingService } from 'jslib-common/abstractions/messaging.service';
import { StateService } from 'jslib-common/abstractions/state.service';
import { StorageService } from 'jslib-common/abstractions/storage.service';
import { TotpService } from 'jslib-common/abstractions/totp.service';
import { ConstantsService } from 'jslib-common/services/constants.service';
@Component({
selector: 'app-options',
templateUrl: 'options.component.html',
@ -41,8 +39,8 @@ export class OptionsComponent implements OnInit {
showAutofill: boolean = true;
showDisplay: boolean = true;
constructor(private messagingService: MessagingService, private storageService: StorageService,
private stateService: StateService, private totpService: TotpService, i18nService: I18nService) {
constructor(private messagingService: MessagingService, private activeAccount: ActiveAccountService,
private totpService: TotpService, i18nService: I18nService) {
this.themeOptions = [
{ name: i18nService.t('default'), value: null },
{ name: i18nService.t('light'), value: ThemeType.Light },
@ -74,97 +72,93 @@ export class OptionsComponent implements OnInit {
}
async ngOnInit() {
this.enableAutoFillOnPageLoad = await this.storageService.get<boolean>(
ConstantsService.enableAutoFillOnPageLoadKey);
this.enableAutoFillOnPageLoad = await this.activeAccount.getInformation<boolean>(
StorageKey.EnableAutoFillOnPageLoad);
this.autoFillOnPageLoadDefault = await this.storageService.get<boolean>(
ConstantsService.autoFillOnPageLoadDefaultKey) ?? true;
this.autoFillOnPageLoadDefault = await this.activeAccount.getInformation<boolean>(
StorageKey.AutoFillOnPageLoadDefault) ?? true;
this.disableAddLoginNotification = await this.storageService.get<boolean>(
ConstantsService.disableAddLoginNotificationKey);
this.disableAddLoginNotification = await this.activeAccount.getInformation<boolean>(
StorageKey.DisableAddLoginNotification);
this.disableChangedPasswordNotification = await this.storageService.get<boolean>(
ConstantsService.disableChangedPasswordNotificationKey);
this.disableChangedPasswordNotification = await this.activeAccount.getInformation<boolean>(
StorageKey.DisableChangedPasswordNotification);
this.disableContextMenuItem = await this.storageService.get<boolean>(
ConstantsService.disableContextMenuItemKey);
this.disableContextMenuItem = await this.activeAccount.getInformation<boolean>(
StorageKey.DisableContextMenuItem);
this.dontShowCards = await this.storageService.get<boolean>(ConstantsService.dontShowCardsCurrentTab);
this.dontShowIdentities = await this.storageService.get<boolean>(ConstantsService.dontShowIdentitiesCurrentTab);
this.dontShowCards = await this.activeAccount.getInformation<boolean>(StorageKey.DontShowCardsCurrentTab);
this.dontShowIdentities = await this.activeAccount.getInformation<boolean>(StorageKey.DontShowIdentitiesCurrentTab);
this.disableAutoTotpCopy = !(await this.totpService.isAutoCopyEnabled());
this.disableFavicon = await this.storageService.get<boolean>(ConstantsService.disableFaviconKey);
this.disableFavicon = await this.activeAccount.getInformation<boolean>(StorageKey.DisableFavicon);
this.disableBadgeCounter = await this.storageService.get<boolean>(ConstantsService.disableBadgeCounterKey);
this.disableBadgeCounter = await this.activeAccount.getInformation<boolean>(StorageKey.DisableBadgeCounter);
this.theme = await this.storageService.get<string>(ConstantsService.themeKey);
this.theme = await this.activeAccount.getInformation<string>(StorageKey.Theme);
const defaultUriMatch = await this.storageService.get<UriMatchType>(ConstantsService.defaultUriMatch);
const defaultUriMatch = await this.activeAccount.getInformation<UriMatchType>(StorageKey.DefaultUriMatch);
this.defaultUriMatch = defaultUriMatch == null ? UriMatchType.Domain : defaultUriMatch;
this.clearClipboard = await this.storageService.get<number>(ConstantsService.clearClipboardKey);
this.clearClipboard = await this.activeAccount.getInformation<number>(StorageKey.ClearClipboard);
}
async updateAddLoginNotification() {
await this.storageService.save(ConstantsService.disableAddLoginNotificationKey,
await this.activeAccount.saveInformation(StorageKey.DisableAddLoginNotification,
this.disableAddLoginNotification);
}
async updateChangedPasswordNotification() {
await this.storageService.save(ConstantsService.disableChangedPasswordNotificationKey,
await this.activeAccount.saveInformation(StorageKey.DisableChangedPasswordNotification,
this.disableChangedPasswordNotification);
}
async updateDisableContextMenuItem() {
await this.storageService.save(ConstantsService.disableContextMenuItemKey,
await this.activeAccount.saveInformation(StorageKey.DisableContextMenuItem,
this.disableContextMenuItem);
this.messagingService.send('bgUpdateContextMenu');
}
async updateAutoTotpCopy() {
await this.storageService.save(ConstantsService.disableAutoTotpCopyKey, this.disableAutoTotpCopy);
await this.activeAccount.saveInformation(StorageKey.DisableAutoTotpCopy, this.disableAutoTotpCopy);
}
async updateAutoFillOnPageLoad() {
await this.storageService.save(ConstantsService.enableAutoFillOnPageLoadKey, this.enableAutoFillOnPageLoad);
await this.activeAccount.saveInformation(StorageKey.EnableAutoFillOnPageLoad, this.enableAutoFillOnPageLoad);
}
async updateAutoFillOnPageLoadDefault() {
await this.storageService.save(ConstantsService.autoFillOnPageLoadDefaultKey, this.autoFillOnPageLoadDefault);
await this.activeAccount.saveInformation(StorageKey.AutoFillOnPageLoadDefault, this.autoFillOnPageLoadDefault);
}
async updateDisableFavicon() {
await this.storageService.save(ConstantsService.disableFaviconKey, this.disableFavicon);
await this.stateService.save(ConstantsService.disableFaviconKey, this.disableFavicon);
await this.activeAccount.saveInformation(StorageKey.DisableFavicon, this.disableFavicon);
}
async updateDisableBadgeCounter() {
await this.storageService.save(ConstantsService.disableBadgeCounterKey, this.disableBadgeCounter);
await this.stateService.save(ConstantsService.disableBadgeCounterKey, this.disableBadgeCounter);
await this.activeAccount.saveInformation(StorageKey.DisableBadgeCounter, this.disableBadgeCounter);
this.messagingService.send('bgUpdateContextMenu');
}
async updateShowCards() {
await this.storageService.save(ConstantsService.dontShowCardsCurrentTab, this.dontShowCards);
await this.stateService.save(ConstantsService.dontShowCardsCurrentTab, this.dontShowCards);
await this.activeAccount.saveInformation(StorageKey.DontShowCardsCurrentTab, this.dontShowCards);
}
async updateShowIdentities() {
await this.storageService.save(ConstantsService.dontShowIdentitiesCurrentTab, this.dontShowIdentities);
await this.stateService.save(ConstantsService.dontShowIdentitiesCurrentTab, this.dontShowIdentities);
await this.activeAccount.saveInformation(StorageKey.DontShowIdentitiesCurrentTab, this.dontShowIdentities);
}
async saveTheme() {
await this.storageService.save(ConstantsService.themeKey, this.theme);
await this.activeAccount.saveInformation(StorageKey.Theme, this.theme);
window.setTimeout(() => window.location.reload(), 200);
}
async saveDefaultUriMatch() {
await this.storageService.save(ConstantsService.defaultUriMatch, this.defaultUriMatch);
await this.activeAccount.saveInformation(StorageKey.DefaultUriMatch, this.defaultUriMatch);
}
async saveClearClipboard() {
await this.storageService.save(ConstantsService.clearClipboardKey, this.clearClipboard);
await this.activeAccount.saveInformation(StorageKey.ClearClipboard, this.clearClipboard);
}
}

View File

@ -1,10 +1,10 @@
import { CurrencyPipe } from '@angular/common';
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 { 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';
@ -16,9 +16,9 @@ export class PremiumComponent extends BasePremiumComponent {
priceString: string;
constructor(i18nService: I18nService, platformUtilsService: PlatformUtilsService,
apiService: ApiService, userService: UserService,
apiService: ApiService, activeAccount: ActiveAccountService,
private currencyPipe: CurrencyPipe) {
super(i18nService, platformUtilsService, apiService, userService);
super(i18nService, platformUtilsService, apiService, activeAccount);
// Support old price string. Can be removed in future once all translations are properly updated.
const thePrice = this.currencyPipe.transform(this.price, '$');

View File

@ -12,16 +12,14 @@ import Swal from 'sweetalert2/src/sweetalert2.js';
import { BrowserApi } from '../../browser/browserApi';
import { DeviceType } from 'jslib-common/enums/deviceType';
import { StorageKey } from 'jslib-common/enums/storageKey';
import { ConstantsService } from 'jslib-common/services/constants.service';
import { ActiveAccountService } from 'jslib-common/abstractions/activeAccount.service';
import { CryptoService } from 'jslib-common/abstractions/crypto.service';
import { EnvironmentService } from 'jslib-common/abstractions/environment.service';
import { I18nService } from 'jslib-common/abstractions/i18n.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 { PopupUtilsService } from '../services/popup-utils.service';
@ -62,11 +60,11 @@ export class SettingsComponent implements OnInit {
vaultTimeout: FormControl = new FormControl(null);
constructor(private platformUtilsService: PlatformUtilsService, private i18nService: I18nService,
private vaultTimeoutService: VaultTimeoutService, private storageService: StorageService,
public messagingService: MessagingService, private router: Router,
private environmentService: EnvironmentService, private cryptoService: CryptoService,
private userService: UserService, private popupUtilsService: PopupUtilsService,
private modalService: ModalService, private toasterService: ToasterService) {
private vaultTimeoutService: VaultTimeoutService, public messagingService: MessagingService,
private router: Router, private environmentService: EnvironmentService,
private cryptoService: CryptoService, private activeAccount: ActiveAccountService,
private popupUtilsService: PopupUtilsService, private modalService: ModalService,
private toasterService: ToasterService) {
}
async ngOnInit() {
@ -108,7 +106,7 @@ export class SettingsComponent implements OnInit {
this.saveVaultTimeout(value);
});
const action = await this.storageService.get<string>(ConstantsService.vaultTimeoutActionKey);
const action = await this.activeAccount.getInformation<string>(StorageKey.VaultTimeoutAction);
this.vaultTimeoutAction = action == null ? 'lock' : action;
const pinSet = await this.vaultTimeoutService.isPinLockSet();
@ -116,8 +114,8 @@ export class SettingsComponent implements OnInit {
this.supportsBiometric = await this.platformUtilsService.supportsBiometric();
this.biometric = await this.vaultTimeoutService.isBiometricLockSet();
this.disableAutoBiometricsPrompt = await this.storageService.get<boolean>(
ConstantsService.disableAutoBiometricsPromptKey) ?? true;
this.disableAutoBiometricsPrompt = await this.activeAccount.getInformation<boolean>(
StorageKey.DisableAutoBiometricsPrompt) ?? true;
}
async saveVaultTimeout(newValue: number) {
@ -225,14 +223,14 @@ export class SettingsComponent implements OnInit {
allowOutsideClick: false,
});
await this.storageService.save(ConstantsService.biometricAwaitingAcceptance, true);
await this.activeAccount.saveInformation(StorageKey.BiometricAwaitingAcceptance, true);
await this.cryptoService.toggleKey();
await Promise.race([
submitted.then(result => {
if (result.dismiss === Swal.DismissReason.cancel) {
this.biometric = false;
this.storageService.remove(ConstantsService.biometricAwaitingAcceptance);
this.activeAccount.removeInformation(StorageKey.BiometricAwaitingAcceptance);
}
}),
this.platformUtilsService.authenticateBiometric().then(result => {
@ -248,13 +246,13 @@ export class SettingsComponent implements OnInit {
}),
]);
} else {
await this.storageService.remove(ConstantsService.biometricUnlockKey);
await this.activeAccount.removeInformation(StorageKey.BiometricUnlock);
this.vaultTimeoutService.biometricLocked = false;
}
}
async updateAutoBiometricsPrompt() {
await this.storageService.save(ConstantsService.disableAutoBiometricsPromptKey, this.disableAutoBiometricsPrompt);
await this.activeAccount.saveInformation(StorageKey.DisableAutoBiometricsPrompt, this.disableAutoBiometricsPrompt);
}
async lock() {
@ -334,7 +332,7 @@ export class SettingsComponent implements OnInit {
}
async fingerprint() {
const fingerprint = await this.cryptoService.getFingerprint(await this.userService.getUserId());
const fingerprint = await this.cryptoService.getFingerprint(this.activeAccount.userId);
const p = document.createElement('p');
p.innerText = this.i18nService.t('yourAccountsFingerprint') + ':';
const p2 = document.createElement('p');
@ -363,3 +361,4 @@ export class SettingsComponent implements OnInit {
BrowserApi.createNewTab((RateUrls as any)[deviceType]);
}
}

View File

@ -7,6 +7,7 @@ import {
import { BrowserApi } from '../../browser/browserApi';
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';
@ -14,13 +15,11 @@ import { EventService } from 'jslib-common/abstractions/event.service';
import { FolderService } from 'jslib-common/abstractions/folder.service';
import { I18nService } from 'jslib-common/abstractions/i18n.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 { StorageService } from 'jslib-common/abstractions/storage.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { ConstantsService } from 'jslib-common/services/constants.service';
import { PopupUtilsService } from '../services/popup-utils.service';
import { LoginUriView } from 'jslib-common/models/view/loginUriView';
@ -28,6 +27,7 @@ import { LoginUriView } from 'jslib-common/models/view/loginUriView';
import { AddEditComponent as BaseAddEditComponent } from 'jslib-angular/components/add-edit.component';
import { CipherType } from 'jslib-common/enums/cipherType';
import { StorageKey } from 'jslib-common/enums/storageKey';
@Component({
selector: 'app-vault-add-edit',
@ -42,13 +42,14 @@ export class AddEditComponent extends BaseAddEditComponent {
constructor(cipherService: CipherService, folderService: FolderService,
i18nService: I18nService, platformUtilsService: PlatformUtilsService,
auditService: AuditService, stateService: StateService,
userService: UserService, collectionService: CollectionService,
activeAccount: ActiveAccountService, collectionService: CollectionService,
messagingService: MessagingService, private route: ActivatedRoute,
private router: Router, private location: Location,
eventService: EventService, policyService: PolicyService,
private popupUtilsService: PopupUtilsService, private storageService: StorageService) {
super(cipherService, folderService, i18nService, platformUtilsService, auditService, stateService,
userService, collectionService, messagingService, eventService, policyService);
private popupUtilsService: PopupUtilsService, organizationService: OrganizationService) {
super(cipherService, folderService, i18nService, platformUtilsService,
auditService, stateService, collectionService, messagingService,
eventService, policyService, activeAccount, organizationService);
}
async ngOnInit() {
@ -116,7 +117,7 @@ export class AddEditComponent extends BaseAddEditComponent {
async load() {
await super.load();
this.showAutoFillOnPageLoadOptions = this.cipher.type === CipherType.Login &&
await this.storageService.get<boolean>(ConstantsService.enableAutoFillOnPageLoadKey);
await this.activeAccount.getInformation<boolean>(StorageKey.EnableAutoFillOnPageLoad);
}
async submit(): Promise<boolean> {

View File

@ -1,13 +1,13 @@
import { Location } from '@angular/common';
import { Component } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { ActivatedRoute } from '@angular/router';
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 { 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';
@ -19,10 +19,11 @@ export class AttachmentsComponent extends BaseAttachmentsComponent {
openedAttachmentsInPopup: boolean;
constructor(cipherService: CipherService, i18nService: I18nService,
cryptoService: CryptoService, userService: UserService,
platformUtilsService: PlatformUtilsService, apiService: ApiService, private location: Location,
private route: ActivatedRoute, private router: Router) {
super(cipherService, i18nService, cryptoService, userService, platformUtilsService, apiService, window);
cryptoService: CryptoService, platformUtilsService: PlatformUtilsService,
apiService: ApiService, private location: Location,
private route: ActivatedRoute, activeAccount: ActiveAccountService) {
super(cipherService, i18nService, cryptoService, platformUtilsService,
apiService, window, activeAccount);
}
async ngOnInit() {

View File

@ -16,19 +16,18 @@ import { BroadcasterService } from 'jslib-angular/services/broadcaster.service';
import { CipherRepromptType } from 'jslib-common/enums/cipherRepromptType';
import { CipherType } from 'jslib-common/enums/cipherType';
import { StorageKey } from 'jslib-common/enums/storageKey';
import { CipherView } from 'jslib-common/models/view/cipherView';
import { ActiveAccountService } from 'jslib-common/abstractions/activeAccount.service';
import { CipherService } from 'jslib-common/abstractions/cipher.service';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { PasswordRepromptService } from 'jslib-common/abstractions/passwordReprompt.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { SearchService } from 'jslib-common/abstractions/search.service';
import { StorageService } from 'jslib-common/abstractions/storage.service';
import { SyncService } from 'jslib-common/abstractions/sync.service';
import { ConstantsService } from 'jslib-common/services/constants.service';
import { AutofillService } from '../../services/abstractions/autofill.service';
import { PopupUtilsService } from '../services/popup-utils.service';
@ -63,7 +62,7 @@ export class CurrentTabComponent implements OnInit, OnDestroy {
private toasterService: ToasterService, private i18nService: I18nService, private router: Router,
private ngZone: NgZone, private broadcasterService: BroadcasterService,
private changeDetectorRef: ChangeDetectorRef, private syncService: SyncService,
private searchService: SearchService, private storageService: StorageService,
private searchService: SearchService, private activeAccount: ActiveAccountService,
private passwordRepromptService: PasswordRepromptService) {
}
@ -209,9 +208,9 @@ export class CurrentTabComponent implements OnInit, OnDestroy {
});
const otherTypes: CipherType[] = [];
const dontShowCards = await this.storageService.get<boolean>(ConstantsService.dontShowCardsCurrentTab);
const dontShowIdentities = await this.storageService.get<boolean>(
ConstantsService.dontShowIdentitiesCurrentTab);
const dontShowCards = await this.activeAccount.getInformation<boolean>(StorageKey.DontShowCardsCurrentTab);
const dontShowIdentities = await this.activeAccount.getInformation<boolean>(
StorageKey.DontShowIdentitiesCurrentTab);
if (!dontShowCards) {
otherTypes.push(CipherType.Card);
}

View File

@ -19,15 +19,14 @@ import { CipherView } from 'jslib-common/models/view/cipherView';
import { CollectionView } from 'jslib-common/models/view/collectionView';
import { FolderView } from 'jslib-common/models/view/folderView';
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 { FolderService } from 'jslib-common/abstractions/folder.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { SearchService } from 'jslib-common/abstractions/search.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 { UserService } from 'jslib-common/abstractions/user.service';
import { BroadcasterService } from 'jslib-angular/services/broadcaster.service';
@ -76,14 +75,14 @@ export class GroupingsComponent extends BaseGroupingsComponent implements OnInit
private allCiphers: CipherView[] = null;
constructor(collectionService: CollectionService, folderService: FolderService,
storageService: StorageService, userService: UserService,
private cipherService: CipherService, private router: Router,
private ngZone: NgZone, private broadcasterService: BroadcasterService,
private changeDetectorRef: ChangeDetectorRef, private route: ActivatedRoute,
private stateService: StateService, private popupUtils: PopupUtilsService,
private syncService: SyncService, private platformUtilsService: PlatformUtilsService,
private searchService: SearchService, private location: Location) {
super(collectionService, folderService, storageService, userService);
private searchService: SearchService, private location: Location,
activeAccount: ActiveAccountService) {
super(collectionService, folderService, activeAccount);
this.noFolderListSize = 100;
}

View File

@ -1,15 +1,15 @@
import { Location } from '@angular/common';
import { Component } from '@angular/core';
import {
ActivatedRoute,
Router,
} from '@angular/router';
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 { 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';
@ -19,10 +19,11 @@ import { ShareComponent as BaseShareComponent } from 'jslib-angular/components/s
})
export class ShareComponent extends BaseShareComponent {
constructor(collectionService: CollectionService, platformUtilsService: PlatformUtilsService,
i18nService: I18nService, userService: UserService,
i18nService: I18nService, activeAccount: ActiveAccountService,
cipherService: CipherService, private route: ActivatedRoute,
private location: Location, private router: Router) {
super(collectionService, platformUtilsService, i18nService, userService, cipherService);
private router: Router, organizationService: OrganizationService) {
super(collectionService, platformUtilsService, i18nService, cipherService,
activeAccount, organizationService);
}
async ngOnInit() {

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 { AuditService } from 'jslib-common/abstractions/audit.service';
import { CipherService } from 'jslib-common/abstractions/cipher.service';
@ -20,7 +21,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';
@ -54,13 +54,14 @@ export class ViewComponent extends BaseViewComponent {
auditService: AuditService, private route: ActivatedRoute,
private router: Router, private location: Location,
broadcasterService: BroadcasterService, ngZone: NgZone,
changeDetectorRef: ChangeDetectorRef, userService: UserService,
changeDetectorRef: ChangeDetectorRef, activeAccount: ActiveAccountService,
eventService: EventService, private autofillService: AutofillService,
private messagingService: MessagingService, private popupUtilsService: PopupUtilsService,
apiService: ApiService, passwordRepromptService: PasswordRepromptService) {
super(cipherService, totpService, tokenService, i18nService, cryptoService, platformUtilsService,
auditService, window, broadcasterService, ngZone, changeDetectorRef, userService, eventService,
apiService, passwordRepromptService);
super(cipherService, totpService, tokenService, i18nService,
cryptoService, platformUtilsService, auditService, window,
broadcasterService, ngZone, changeDetectorRef, eventService,
apiService, passwordRepromptService, activeAccount);
}
ngOnInit() {

View File

@ -1,7 +1,7 @@
import { ActiveAccountService } from 'jslib-common/abstractions/activeAccount.service';
import { CipherService } from 'jslib-common/abstractions/cipher.service';
import { EventService } from 'jslib-common/abstractions/event.service';
import { TotpService } from 'jslib-common/abstractions/totp.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { AutofillService as AutofillServiceInterface } from './abstractions/autofill.service';
@ -130,7 +130,7 @@ var IsoProvinces: { [id: string]: string; } = {
export default class AutofillService implements AutofillServiceInterface {
constructor(private cipherService: CipherService, private userService: UserService,
constructor(private cipherService: CipherService, private activeAccount: ActiveAccountService,
private totpService: TotpService, private eventService: EventService) { }
getFormsWithPasswordFields(pageDetails: AutofillPageDetails): any[] {
@ -172,7 +172,7 @@ export default class AutofillService implements AutofillServiceInterface {
throw new Error('Nothing to auto-fill.');
}
const canAccessPremium = await this.userService.canAccessPremium();
const canAccessPremium = this.activeAccount.canAccessPremium;
let didAutofill = false;
options.pageDetails.forEach((pd: any) => {
// make sure we're still on correct tab

View File

@ -1,4 +1,5 @@
import { KeySuffixOptions } from 'jslib-common/abstractions/storage.service';
import { KeySuffixOptions } from 'jslib-common/models/domain/settingStorageOptions';
import { CryptoService } from 'jslib-common/services/crypto.service';
export class BrowserCryptoService extends CryptoService {
@ -10,5 +11,4 @@ export class BrowserCryptoService extends CryptoService {
return await super.retrieveKeyFromStorage(keySuffix);
}
}

View File

@ -4,11 +4,10 @@ import { SafariApp } from '../browser/safariApp';
import { DeviceType } from 'jslib-common/enums/deviceType';
import { ThemeType } from 'jslib-common/enums/themeType';
import { ActiveAccountService } from 'jslib-common/abstractions/activeAccount.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 { ConstantsService } from 'jslib-common/services/constants.service';
import { StorageKey } from 'jslib-common/enums/storageKey';
const DialogPromiseExpiration = 600000; // 10 minutes
@ -20,7 +19,7 @@ export default class BrowserPlatformUtilsService implements PlatformUtilsService
private deviceCache: DeviceType = null;
private prefersColorSchemeDark = window.matchMedia('(prefers-color-scheme: dark)');
constructor(private messagingService: MessagingService, private storageService: StorageService,
constructor(private messagingService: MessagingService, private activeAccount: ActiveAccountService,
private clipboardWriteCallback: (clipboardValue: string, clearMs: number) => void,
private biometricCallback: () => Promise<boolean>) { }
@ -332,7 +331,7 @@ export default class BrowserPlatformUtilsService implements PlatformUtilsService
}
async getEffectiveTheme() {
const theme = await this.storageService.get<ThemeType>(ConstantsService.themeKey);
const theme = await this.activeAccount.getInformation<ThemeType>(StorageKey.Theme);
if (theme == null || theme === ThemeType.System) {
return this.getDefaultSystemTheme();
} else {