|
|
|
|
@ -33,6 +33,7 @@ import { TwoFactorService as TwoFactorServiceAbstraction } from "jslib-common/ab
@@ -33,6 +33,7 @@ import { TwoFactorService as TwoFactorServiceAbstraction } from "jslib-common/ab
|
|
|
|
|
import { UserVerificationService as UserVerificationServiceAbstraction } from "jslib-common/abstractions/userVerification.service"; |
|
|
|
|
import { UsernameGenerationService as UsernameGenerationServiceAbstraction } from "jslib-common/abstractions/usernameGeneration.service"; |
|
|
|
|
import { VaultTimeoutService as VaultTimeoutServiceAbstraction } from "jslib-common/abstractions/vaultTimeout.service"; |
|
|
|
|
import { AuthenticationStatus } from "jslib-common/enums/authenticationStatus"; |
|
|
|
|
import { CipherRepromptType } from "jslib-common/enums/cipherRepromptType"; |
|
|
|
|
import { CipherType } from "jslib-common/enums/cipherType"; |
|
|
|
|
import { StateFactory } from "jslib-common/factories/stateFactory"; |
|
|
|
|
@ -267,6 +268,32 @@ export default class MainBackground {
@@ -267,6 +268,32 @@ export default class MainBackground {
|
|
|
|
|
this.cryptoFunctionService |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
this.twoFactorService = new TwoFactorService(this.i18nService, this.platformUtilsService); |
|
|
|
|
|
|
|
|
|
// eslint-disable-next-line
|
|
|
|
|
const that = this; |
|
|
|
|
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.platformUtilsService, |
|
|
|
|
backgroundMessagingService, |
|
|
|
|
this.logService, |
|
|
|
|
this.keyConnectorService, |
|
|
|
|
this.environmentService, |
|
|
|
|
this.stateService, |
|
|
|
|
this.twoFactorService, |
|
|
|
|
this.i18nService |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
const lockedCallback = async (userId?: string) => { |
|
|
|
|
if (this.notificationsService != null) { |
|
|
|
|
this.notificationsService.updateConnection(false); |
|
|
|
|
@ -294,6 +321,7 @@ export default class MainBackground {
@@ -294,6 +321,7 @@ export default class MainBackground {
|
|
|
|
|
this.policyService, |
|
|
|
|
this.keyConnectorService, |
|
|
|
|
this.stateService, |
|
|
|
|
this.authService, |
|
|
|
|
lockedCallback, |
|
|
|
|
logoutCallback |
|
|
|
|
); |
|
|
|
|
@ -352,11 +380,11 @@ export default class MainBackground {
@@ -352,11 +380,11 @@ export default class MainBackground {
|
|
|
|
|
this.syncService, |
|
|
|
|
this.appIdService, |
|
|
|
|
this.apiService, |
|
|
|
|
this.vaultTimeoutService, |
|
|
|
|
this.environmentService, |
|
|
|
|
logoutCallback, |
|
|
|
|
this.logService, |
|
|
|
|
this.stateService |
|
|
|
|
this.stateService, |
|
|
|
|
this.authService |
|
|
|
|
); |
|
|
|
|
this.popupUtilsService = new PopupUtilsService(isPrivateMode); |
|
|
|
|
|
|
|
|
|
@ -412,18 +440,19 @@ export default class MainBackground {
@@ -412,18 +440,19 @@ export default class MainBackground {
|
|
|
|
|
this.platformUtilsService, |
|
|
|
|
this.stateService, |
|
|
|
|
this.logService, |
|
|
|
|
this.vaultTimeoutService |
|
|
|
|
this.authService |
|
|
|
|
); |
|
|
|
|
this.commandsBackground = new CommandsBackground( |
|
|
|
|
this, |
|
|
|
|
this.passwordGenerationService, |
|
|
|
|
this.platformUtilsService, |
|
|
|
|
this.vaultTimeoutService |
|
|
|
|
this.vaultTimeoutService, |
|
|
|
|
this.authService |
|
|
|
|
); |
|
|
|
|
this.notificationBackground = new NotificationBackground( |
|
|
|
|
this.autofillService, |
|
|
|
|
this.cipherService, |
|
|
|
|
this.vaultTimeoutService, |
|
|
|
|
this.authService, |
|
|
|
|
this.policyService, |
|
|
|
|
this.folderService, |
|
|
|
|
this.stateService |
|
|
|
|
@ -435,7 +464,7 @@ export default class MainBackground {
@@ -435,7 +464,7 @@ export default class MainBackground {
|
|
|
|
|
this.cipherService, |
|
|
|
|
this.passwordGenerationService, |
|
|
|
|
this.platformUtilsService, |
|
|
|
|
this.vaultTimeoutService, |
|
|
|
|
this.authService, |
|
|
|
|
this.eventService, |
|
|
|
|
this.totpService |
|
|
|
|
); |
|
|
|
|
@ -447,37 +476,13 @@ export default class MainBackground {
@@ -447,37 +476,13 @@ export default class MainBackground {
|
|
|
|
|
this.webRequestBackground = new WebRequestBackground( |
|
|
|
|
this.platformUtilsService, |
|
|
|
|
this.cipherService, |
|
|
|
|
this.vaultTimeoutService |
|
|
|
|
this.authService |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
this.twoFactorService = new TwoFactorService(this.i18nService, this.platformUtilsService); |
|
|
|
|
|
|
|
|
|
// eslint-disable-next-line
|
|
|
|
|
const that = this; |
|
|
|
|
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.platformUtilsService, |
|
|
|
|
backgroundMessagingService, |
|
|
|
|
this.logService, |
|
|
|
|
this.keyConnectorService, |
|
|
|
|
this.environmentService, |
|
|
|
|
this.stateService, |
|
|
|
|
this.twoFactorService, |
|
|
|
|
this.i18nService |
|
|
|
|
); |
|
|
|
|
this.usernameGenerationService = new UsernameGenerationService( |
|
|
|
|
this.cryptoService, |
|
|
|
|
this.stateService |
|
|
|
|
this.stateService, |
|
|
|
|
this.apiService |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -532,13 +537,12 @@ export default class MainBackground {
@@ -532,13 +537,12 @@ export default class MainBackground {
|
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const isAuthenticated = await this.stateService.getIsAuthenticated(); |
|
|
|
|
const locked = await this.vaultTimeoutService.isLocked(); |
|
|
|
|
const authStatus = await this.authService.getAuthStatus(); |
|
|
|
|
|
|
|
|
|
let suffix = ""; |
|
|
|
|
if (!isAuthenticated) { |
|
|
|
|
if (authStatus === AuthenticationStatus.LoggedOut) { |
|
|
|
|
suffix = "_gray"; |
|
|
|
|
} else if (locked) { |
|
|
|
|
} else if (authStatus === AuthenticationStatus.Locked) { |
|
|
|
|
suffix = "_locked"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -756,8 +760,8 @@ export default class MainBackground {
@@ -756,8 +760,8 @@ export default class MainBackground {
|
|
|
|
|
this.actionSetBadgeBackgroundColor(this.sidebarAction); |
|
|
|
|
|
|
|
|
|
this.menuOptionsLoaded = []; |
|
|
|
|
const locked = await this.vaultTimeoutService.isLocked(); |
|
|
|
|
if (!locked) { |
|
|
|
|
const authStatus = await this.authService.getAuthStatus(); |
|
|
|
|
if (authStatus === AuthenticationStatus.Unlocked) { |
|
|
|
|
try { |
|
|
|
|
const ciphers = await this.cipherService.getAllDecryptedForUrl(url); |
|
|
|
|
ciphers.sort((a, b) => this.cipherService.sortCiphersByLastUsedThenName(a, b)); |
|
|
|
|
@ -1011,7 +1015,7 @@ export default class MainBackground {
@@ -1011,7 +1015,7 @@ export default class MainBackground {
|
|
|
|
|
const accounts = this.stateService.accounts.getValue(); |
|
|
|
|
if (accounts != null) { |
|
|
|
|
for (const userId of Object.keys(accounts)) { |
|
|
|
|
if (!(await this.vaultTimeoutService.isLocked(userId))) { |
|
|
|
|
if ((await this.authService.getAuthStatus(userId)) === AuthenticationStatus.Unlocked) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|