diff --git a/jslib b/jslib index a20e935268..24fe836032 160000 --- a/jslib +++ b/jslib @@ -1 +1 @@ -Subproject commit a20e935268c986538ff68f72016bb8c772ea3a1b +Subproject commit 24fe836032354d4ec39435776e54dd0995e1b389 diff --git a/package-lock.json b/package-lock.json index 112839dbb5..bd883693f7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -94,6 +94,7 @@ } }, "jslib/common": { + "name": "@bitwarden/jslib-common", "version": "0.0.0", "license": "GPL-3.0", "dependencies": { diff --git a/src/background/main.background.ts b/src/background/main.background.ts index 486ef98b3c..e18837ba30 100644 --- a/src/background/main.background.ts +++ b/src/background/main.background.ts @@ -184,7 +184,8 @@ export default class MainBackground { this.settingsService = new SettingsService(this.userService, this.storageService); 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.apiService, this.fileUploadService, this.storageService, this.i18nService, () => this.searchService, + this.logService); 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, @@ -193,7 +194,7 @@ export default class MainBackground { this.sendService = new SendService(this.cryptoService, this.userService, this.apiService, this.fileUploadService, this.storageService, this.i18nService, this.cryptoFunctionService); this.stateService = new StateService(); - this.policyService = new PolicyService(this.userService, this.storageService); + this.policyService = new PolicyService(this.userService, this.storageService, this.apiService); 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, @@ -211,14 +212,14 @@ export default class MainBackground { 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.logService, async (expired: boolean) => await this.logout(expired)); this.eventService = new EventService(this.storageService, this.apiService, this.userService, - this.cipherService); + this.cipherService, this.logService); this.passwordGenerationService = new PasswordGenerationService(this.cryptoService, this.storageService, this.policyService); - this.totpService = new TotpService(this.storageService, this.cryptoFunctionService); + this.totpService = new TotpService(this.storageService, this.cryptoFunctionService, this.logService); this.autofillService = new AutofillService(this.cipherService, this.userService, this.totpService, - this.eventService); + this.eventService, this.logService); this.containerService = new ContainerService(this.cryptoService); this.auditService = new AuditService(this.cryptoFunctionService, this.apiService); this.exportService = new ExportService(this.folderService, this.cipherService, this.apiService, @@ -242,7 +243,8 @@ export default class MainBackground { // Background this.runtimeBackground = new RuntimeBackground(this, this.autofillService, this.platformUtilsService as BrowserPlatformUtilsService, this.storageService, this.i18nService, - this.notificationsService, this.systemService, this.environmentService, this.messagingService); + this.notificationsService, this.systemService, this.environmentService, this.messagingService, + this.logService); this.nativeMessagingBackground = new NativeMessagingBackground(this.storageService, this.cryptoService, this.cryptoFunctionService, this.vaultTimeoutService, this.runtimeBackground, this.i18nService, this.userService, this.messagingService, this.appIdService, this.platformUtilsService); @@ -548,7 +550,9 @@ export default class MainBackground { this.browserActionSetBadgeText(theText, tabId); return; - } catch { } + } catch (e) { + this.logService.error(e); + } } await this.loadMenuAndUpdateBadgeForNoAccessState(contextMenuEnabled); diff --git a/src/background/models/addChangePasswordQueueMessage.ts b/src/background/models/addChangePasswordQueueMessage.ts index 9adcc3d5e7..65309ce7cd 100644 --- a/src/background/models/addChangePasswordQueueMessage.ts +++ b/src/background/models/addChangePasswordQueueMessage.ts @@ -1,4 +1,4 @@ -import NotificationQueueMessage from "./notificationQueueMessage"; +import NotificationQueueMessage from './notificationQueueMessage'; export default class AddChangePasswordQueueMessage extends NotificationQueueMessage { cipherId: string; diff --git a/src/background/models/addLoginQueueMessage.ts b/src/background/models/addLoginQueueMessage.ts index 466c5c6c95..1de8b721d2 100644 --- a/src/background/models/addLoginQueueMessage.ts +++ b/src/background/models/addLoginQueueMessage.ts @@ -1,4 +1,4 @@ -import NotificationQueueMessage from "./notificationQueueMessage"; +import NotificationQueueMessage from './notificationQueueMessage'; export default class AddLoginQueueMessage extends NotificationQueueMessage { username: string; diff --git a/src/background/models/lockedVaultPendingNotificationsItem.ts b/src/background/models/lockedVaultPendingNotificationsItem.ts index dec2313966..248868e6ac 100644 --- a/src/background/models/lockedVaultPendingNotificationsItem.ts +++ b/src/background/models/lockedVaultPendingNotificationsItem.ts @@ -2,6 +2,6 @@ export default class LockedVaultPendingNotificationsItem { commandToRetry: { msg: any; sender: chrome.runtime.MessageSender; - } + }; target: string; } diff --git a/src/background/models/notificationQueueMessage.ts b/src/background/models/notificationQueueMessage.ts index 1e4b81c9c9..00a05d15a4 100644 --- a/src/background/models/notificationQueueMessage.ts +++ b/src/background/models/notificationQueueMessage.ts @@ -1,4 +1,4 @@ -import { NotificationQueueMessageType } from "./notificationQueueMessageType"; +import { NotificationQueueMessageType } from './notificationQueueMessageType'; export default class NotificationQueueMessage { type: NotificationQueueMessageType; diff --git a/src/background/runtime.background.ts b/src/background/runtime.background.ts index 71dbe6ec9d..be8441ea52 100644 --- a/src/background/runtime.background.ts +++ b/src/background/runtime.background.ts @@ -1,10 +1,12 @@ import { EnvironmentService } from 'jslib-common/abstractions/environment.service'; import { I18nService } from 'jslib-common/abstractions/i18n.service'; +import { LogService } from 'jslib-common/abstractions/log.service'; import { MessagingService } from 'jslib-common/abstractions/messaging.service'; import { NotificationsService } from 'jslib-common/abstractions/notifications.service'; import { StorageService } from 'jslib-common/abstractions/storage.service'; import { SystemService } from 'jslib-common/abstractions/system.service'; import { ConstantsService } from 'jslib-common/services/constants.service'; + import { AutofillService } from '../services/abstractions/autofill.service'; import BrowserPlatformUtilsService from '../services/browserPlatformUtils.service'; @@ -25,7 +27,8 @@ export default class RuntimeBackground { private platformUtilsService: BrowserPlatformUtilsService, private storageService: StorageService, private i18nService: I18nService, private notificationsService: NotificationsService, private systemService: SystemService, - private environmentService: EnvironmentService, private messagingService: MessagingService) { + private environmentService: EnvironmentService, private messagingService: MessagingService, + private logService: LogService) { // onInstalled listener must be wired up before anything else, so we do it in the ctor chrome.runtime.onInstalled.addListener((details: any) => { @@ -137,7 +140,9 @@ export default class RuntimeBackground { BrowserApi.createNewTab('popup/index.html?uilocation=popout#/sso?code=' + msg.code + '&state=' + msg.state); } - catch { } + catch { + this.logService.error('Unable to open sso popout tab'); + } break; case 'webAuthnResult': const vaultUrl2 = this.environmentService.getWebVaultUrl(); diff --git a/src/background/tabs.background.ts b/src/background/tabs.background.ts index 7ba7a75a3d..7b43d7696a 100644 --- a/src/background/tabs.background.ts +++ b/src/background/tabs.background.ts @@ -2,24 +2,21 @@ import MainBackground from './main.background'; import NotificationBackground from './notification.background'; export default class TabsBackground { - private tabs: any; - constructor(private main: MainBackground, private notificationBackground: NotificationBackground) { - this.tabs = chrome.tabs; } async init() { - if (!this.tabs) { + if (!chrome.tabs) { return; } - this.tabs.onActivated.addListener(async (activeInfo: any) => { + chrome.tabs.onActivated.addListener(async (activeInfo: chrome.tabs.TabActiveInfo) => { await this.main.refreshBadgeAndMenu(); this.main.messagingService.send('tabActivated'); this.main.messagingService.send('tabChanged'); }); - this.tabs.onReplaced.addListener(async (addedTabId: any, removedTabId: any) => { + chrome.tabs.onReplaced.addListener(async (addedTabId: number, removedTabId: number) => { if (this.main.onReplacedRan) { return; } @@ -30,12 +27,12 @@ export default class TabsBackground { this.main.messagingService.send('tabChanged'); }); - this.tabs.onUpdated.addListener(async (tabId: any, changeInfo: any, tab: any) => { + chrome.tabs.onUpdated.addListener(async (tabId: number, changeInfo: chrome.tabs.TabChangeInfo, tab: chrome.tabs.Tab) => { if (this.main.onUpdatedRan) { return; } this.main.onUpdatedRan = true; - await this.notificationBackground.checkNotificationQueue(); + await this.notificationBackground.checkNotificationQueue(tab); await this.main.refreshBadgeAndMenu(); this.main.messagingService.send('tabUpdated'); this.main.messagingService.send('tabChanged'); diff --git a/src/content/notificationBar.ts b/src/content/notificationBar.ts index da3f25d7d4..84964f6f62 100644 --- a/src/content/notificationBar.ts +++ b/src/content/notificationBar.ts @@ -259,7 +259,9 @@ document.addEventListener('DOMContentLoaded', event => { if (fieldData.htmlID != null && fieldData.htmlID !== '') { try { el = form.querySelector('#' + fieldData.htmlID); - } catch { } + } catch { + // Ignore error, we perform fallbacks below. + } } if (el == null && fieldData.htmlName != null && fieldData.htmlName !== '') { el = form.querySelector('input[name="' + fieldData.htmlName + '"]'); @@ -467,6 +469,7 @@ document.addEventListener('DOMContentLoaded', event => { const iframe = document.createElement('iframe'); iframe.style.cssText = 'height: 42px; width: 100%; border: 0; min-height: initial;'; iframe.id = 'bit-notification-bar-iframe'; + iframe.src = barPageUrl; const frameDiv = document.createElement('div'); frameDiv.setAttribute('aria-live', 'polite'); diff --git a/src/popup/accounts/hint.component.ts b/src/popup/accounts/hint.component.ts index 144b3fd4ff..d4bf83da0f 100644 --- a/src/popup/accounts/hint.component.ts +++ b/src/popup/accounts/hint.component.ts @@ -3,6 +3,7 @@ import { Router } from '@angular/router'; import { ApiService } from 'jslib-common/abstractions/api.service'; import { I18nService } from 'jslib-common/abstractions/i18n.service'; +import { LogService } from 'jslib-common/abstractions/log.service'; import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service'; import { HintComponent as BaseHintComponent } from 'jslib-angular/components/hint.component'; @@ -13,7 +14,7 @@ import { HintComponent as BaseHintComponent } from 'jslib-angular/components/hin }) export class HintComponent extends BaseHintComponent { constructor(router: Router, platformUtilsService: PlatformUtilsService, - i18nService: I18nService, apiService: ApiService) { - super(router, i18nService, apiService, platformUtilsService); + i18nService: I18nService, apiService: ApiService, logService: LogService) { + super(router, i18nService, apiService, platformUtilsService, logService); } } diff --git a/src/popup/accounts/lock.component.ts b/src/popup/accounts/lock.component.ts index 684dfc672a..09c9bd22fd 100644 --- a/src/popup/accounts/lock.component.ts +++ b/src/popup/accounts/lock.component.ts @@ -1,5 +1,6 @@ import { Component } from '@angular/core'; import { Router } from '@angular/router'; +import Swal from 'sweetalert2'; import { ConstantsService } from 'jslib-common/services/constants.service'; @@ -7,6 +8,7 @@ import { ApiService } from 'jslib-common/abstractions/api.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 { LogService } from 'jslib-common/abstractions/log.service'; import { MessagingService } from 'jslib-common/abstractions/messaging.service'; import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service'; import { StateService } from 'jslib-common/abstractions/state.service'; @@ -15,7 +17,6 @@ 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'; @Component({ selector: 'app-lock', @@ -29,9 +30,9 @@ export class LockComponent extends BaseLockComponent { userService: UserService, cryptoService: CryptoService, storageService: StorageService, vaultTimeoutService: VaultTimeoutService, environmentService: EnvironmentService, stateService: StateService, - apiService: ApiService) { + apiService: ApiService, logService: LogService) { super(router, i18nService, platformUtilsService, messagingService, userService, cryptoService, - storageService, vaultTimeoutService, environmentService, stateService, apiService); + storageService, vaultTimeoutService, environmentService, stateService, apiService, logService); this.successRoute = '/tabs/current'; this.isInitialLockScreen = (window as any).previousPopupUrl == null; } diff --git a/src/popup/accounts/login.component.ts b/src/popup/accounts/login.component.ts index 08edd398de..460666e573 100644 --- a/src/popup/accounts/login.component.ts +++ b/src/popup/accounts/login.component.ts @@ -5,6 +5,7 @@ import { AuthService } from 'jslib-common/abstractions/auth.service'; import { CryptoFunctionService } from 'jslib-common/abstractions/cryptoFunction.service'; import { EnvironmentService } from 'jslib-common/abstractions/environment.service'; import { I18nService } from 'jslib-common/abstractions/i18n.service'; +import { LogService } from 'jslib-common/abstractions/log.service'; import { PasswordGenerationService } from 'jslib-common/abstractions/passwordGeneration.service'; import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service'; import { StateService } from 'jslib-common/abstractions/state.service'; @@ -23,8 +24,9 @@ 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, logService: LogService) { + super(authService, router, platformUtilsService, i18nService, stateService, environmentService, + passwordGenerationService, cryptoFunctionService, storageService, logService); super.onSuccessfulLogin = async () => { await syncService.fullSync(true); }; diff --git a/src/popup/accounts/register.component.ts b/src/popup/accounts/register.component.ts index 75fbdca157..4428b5fd9d 100644 --- a/src/popup/accounts/register.component.ts +++ b/src/popup/accounts/register.component.ts @@ -11,6 +11,7 @@ import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.se import { StateService } from 'jslib-common/abstractions/state.service'; import { RegisterComponent as BaseRegisterComponent } from 'jslib-angular/components/register.component'; +import { LogService } from 'jslib-common/abstractions/log.service'; @Component({ selector: 'app-register', @@ -20,8 +21,9 @@ export class RegisterComponent extends BaseRegisterComponent { constructor(authService: AuthService, router: Router, i18nService: I18nService, cryptoService: CryptoService, apiService: ApiService, stateService: StateService, platformUtilsService: PlatformUtilsService, - passwordGenerationService: PasswordGenerationService, environmentService: EnvironmentService) { + passwordGenerationService: PasswordGenerationService, environmentService: EnvironmentService, + logService: LogService) { super(authService, router, i18nService, cryptoService, apiService, stateService, platformUtilsService, - passwordGenerationService, environmentService); + passwordGenerationService, environmentService, logService); } } diff --git a/src/popup/accounts/sso.component.ts b/src/popup/accounts/sso.component.ts index 34b3a77c01..1ee79a0aae 100644 --- a/src/popup/accounts/sso.component.ts +++ b/src/popup/accounts/sso.component.ts @@ -10,6 +10,7 @@ import { AuthService } from 'jslib-common/abstractions/auth.service'; import { CryptoFunctionService } from 'jslib-common/abstractions/cryptoFunction.service'; import { EnvironmentService } from 'jslib-common/abstractions/environment.service'; import { I18nService } from 'jslib-common/abstractions/i18n.service'; +import { LogService } from 'jslib-common/abstractions/log.service'; import { PasswordGenerationService } from 'jslib-common/abstractions/passwordGeneration.service'; import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service'; import { StateService } from 'jslib-common/abstractions/state.service'; @@ -29,9 +30,9 @@ export class SsoComponent extends BaseSsoComponent { storageService: StorageService, stateService: StateService, platformUtilsService: PlatformUtilsService, apiService: ApiService, cryptoFunctionService: CryptoFunctionService, passwordGenerationService: PasswordGenerationService, - syncService: SyncService, environmentService: EnvironmentService) { + syncService: SyncService, environmentService: EnvironmentService, logService: LogService) { super(authService, router, i18nService, route, storageService, stateService, platformUtilsService, - apiService, cryptoFunctionService, environmentService, passwordGenerationService); + apiService, cryptoFunctionService, environmentService, passwordGenerationService, logService); const url = this.environmentService.getWebVaultUrl(); diff --git a/src/popup/accounts/two-factor.component.ts b/src/popup/accounts/two-factor.component.ts index ac5e3fbb1b..9d4ed31538 100644 --- a/src/popup/accounts/two-factor.component.ts +++ b/src/popup/accounts/two-factor.component.ts @@ -1,14 +1,8 @@ -import { - ChangeDetectorRef, - Component, - NgZone, -} from '@angular/core'; - +import { Component } from '@angular/core'; import { ActivatedRoute, Router, } from '@angular/router'; - import { first } from 'rxjs/operators'; import { TwoFactorProviderType } from 'jslib-common/enums/twoFactorProviderType'; @@ -17,6 +11,7 @@ import { ApiService } from 'jslib-common/abstractions/api.service'; import { AuthService } from 'jslib-common/abstractions/auth.service'; import { EnvironmentService } from 'jslib-common/abstractions/environment.service'; import { I18nService } from 'jslib-common/abstractions/i18n.service'; +import { LogService } from 'jslib-common/abstractions/log.service'; import { MessagingService } from 'jslib-common/abstractions/messaging.service'; import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service'; import { StateService } from 'jslib-common/abstractions/state.service'; @@ -43,12 +38,12 @@ export class TwoFactorComponent extends BaseTwoFactorComponent { constructor(authService: AuthService, router: Router, i18nService: I18nService, apiService: ApiService, platformUtilsService: PlatformUtilsService, private syncService: SyncService, - environmentService: EnvironmentService, private ngZone: NgZone, - private broadcasterService: BroadcasterService, private changeDetectorRef: ChangeDetectorRef, + environmentService: EnvironmentService, private broadcasterService: BroadcasterService, private popupUtilsService: PopupUtilsService, stateService: StateService, - storageService: StorageService, route: ActivatedRoute, private messagingService: MessagingService) { + storageService: StorageService, route: ActivatedRoute, private messagingService: MessagingService, + logService: LogService) { super(authService, router, i18nService, apiService, platformUtilsService, window, environmentService, - stateService, storageService, route); + stateService, storageService, route, logService); super.onSuccessfulLogin = () => { return syncService.fullSync(true); }; diff --git a/src/popup/accounts/update-temp-password.component.ts b/src/popup/accounts/update-temp-password.component.ts index caf867c60e..b473be0aae 100644 --- a/src/popup/accounts/update-temp-password.component.ts +++ b/src/popup/accounts/update-temp-password.component.ts @@ -3,6 +3,7 @@ import { Component } from '@angular/core'; import { ApiService } from 'jslib-common/abstractions/api.service'; import { CryptoService } from 'jslib-common/abstractions/crypto.service'; import { I18nService } from 'jslib-common/abstractions/i18n.service'; +import { LogService } from 'jslib-common/abstractions/log.service'; import { MessagingService } from 'jslib-common/abstractions/messaging.service'; import { PasswordGenerationService } from 'jslib-common/abstractions/passwordGeneration.service'; import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service'; @@ -57,8 +58,8 @@ export class UpdateTempPasswordComponent extends BaseUpdateTempPasswordComponent passwordGenerationService: PasswordGenerationService, policyService: PolicyService, cryptoService: CryptoService, userService: UserService, messagingService: MessagingService, apiService: ApiService, - syncService: SyncService) { + syncService: SyncService, logService: LogService) { super(i18nService, platformUtilsService, passwordGenerationService, policyService, cryptoService, - userService, messagingService, apiService, syncService); + userService, messagingService, apiService, syncService, logService); } } diff --git a/src/popup/components/password-reprompt.component.html b/src/popup/components/password-reprompt.component.html index fd41a1a5b4..3ef88b7bc7 100644 --- a/src/popup/components/password-reprompt.component.html +++ b/src/popup/components/password-reprompt.component.html @@ -1,4 +1,4 @@ -