Add support for helpers in environment service (#1967)

This commit is contained in:
Oscar Hinton 2021-07-23 22:32:42 +02:00 committed by GitHub
parent 55917b6cb0
commit 7cf4cfe3d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 15 additions and 29 deletions

2
jslib

@ -1 +1 @@
Subproject commit c77441b35348c821af7fd6261b6dc72732d5ebad Subproject commit e1ce72136490b9055d8d6a03988e9d39ac560a89

View File

@ -178,7 +178,8 @@ export default class MainBackground {
this.cryptoFunctionService, this.platformUtilsService, this.logService); this.cryptoFunctionService, this.platformUtilsService, this.logService);
this.tokenService = new TokenService(this.storageService); this.tokenService = new TokenService(this.storageService);
this.appIdService = new AppIdService(this.storageService); this.appIdService = new AppIdService(this.storageService);
this.apiService = new ApiService(this.tokenService, this.platformUtilsService, this.environmentService = new EnvironmentService(this.storageService);
this.apiService = new ApiService(this.tokenService, this.platformUtilsService, this.environmentService,
(expired: boolean) => this.logout(expired)); (expired: boolean) => this.logout(expired));
this.userService = new UserService(this.tokenService, this.storageService); this.userService = new UserService(this.tokenService, this.storageService);
this.settingsService = new SettingsService(this.userService, this.storageService); this.settingsService = new SettingsService(this.userService, this.storageService);
@ -224,9 +225,7 @@ export default class MainBackground {
this.exportService = new ExportService(this.folderService, this.cipherService, this.apiService, this.exportService = new ExportService(this.folderService, this.cipherService, this.apiService,
this.cryptoService); this.cryptoService);
this.notificationsService = new NotificationsService(this.userService, this.syncService, this.appIdService, this.notificationsService = new NotificationsService(this.userService, this.syncService, this.appIdService,
this.apiService, this.vaultTimeoutService, () => this.logout(true), this.logService); this.apiService, this.vaultTimeoutService, this.environmentService, () => this.logout(true), this.logService);
this.environmentService = new EnvironmentService(this.apiService, this.storageService,
this.notificationsService);
this.popupUtilsService = new PopupUtilsService(this.platformUtilsService); this.popupUtilsService = new PopupUtilsService(this.platformUtilsService);
this.systemService = new SystemService(this.storageService, this.vaultTimeoutService, this.systemService = new SystemService(this.storageService, this.vaultTimeoutService,
this.messagingService, this.platformUtilsService, () => { this.messagingService, this.platformUtilsService, () => {
@ -295,7 +294,7 @@ export default class MainBackground {
await this.setIcon(); await this.setIcon();
this.cleanupNotificationQueue(); this.cleanupNotificationQueue();
this.fullSync(true); this.fullSync(true);
setTimeout(() => this.notificationsService.init(this.environmentService), 2500); setTimeout(() => this.notificationsService.init(), 2500);
resolve(); resolve();
}, 500); }, 500);
}); });

View File

@ -161,10 +161,7 @@ export default class RuntimeBackground {
} }
break; break;
case 'authResult': case 'authResult':
let vaultUrl = this.environmentService.getWebVaultUrl(); const vaultUrl = this.environmentService.getWebVaultUrl();
if (vaultUrl == null) {
vaultUrl = 'https://vault.bitwarden.com';
}
if (msg.referrer == null || Utils.getHostname(vaultUrl) !== msg.referrer) { if (msg.referrer == null || Utils.getHostname(vaultUrl) !== msg.referrer) {
return; return;
@ -177,10 +174,7 @@ export default class RuntimeBackground {
catch { } catch { }
break; break;
case 'webAuthnResult': case 'webAuthnResult':
let vaultUrl2 = this.environmentService.getWebVaultUrl(); const vaultUrl2 = this.environmentService.getWebVaultUrl();
if (vaultUrl2 == null) {
vaultUrl2 = 'https://vault.bitwarden.com';
}
if (msg.referrer == null || Utils.getHostname(vaultUrl2) !== msg.referrer) { if (msg.referrer == null || Utils.getHostname(vaultUrl2) !== msg.referrer) {
return; return;

View File

@ -19,9 +19,8 @@ import { RegisterComponent as BaseRegisterComponent } from 'jslib-angular/compon
export class RegisterComponent extends BaseRegisterComponent { export class RegisterComponent extends BaseRegisterComponent {
constructor(authService: AuthService, router: Router, constructor(authService: AuthService, router: Router,
i18nService: I18nService, cryptoService: CryptoService, i18nService: I18nService, cryptoService: CryptoService,
apiService: ApiService, stateService: StateService, apiService: ApiService, stateService: StateService, platformUtilsService: PlatformUtilsService,
platformUtilsService: PlatformUtilsService, passwordGenerationService: PasswordGenerationService, passwordGenerationService: PasswordGenerationService, environmentService: EnvironmentService) {
environmentService: EnvironmentService) {
super(authService, router, i18nService, cryptoService, apiService, stateService, platformUtilsService, super(authService, router, i18nService, cryptoService, apiService, stateService, platformUtilsService,
passwordGenerationService, environmentService); passwordGenerationService, environmentService);
} }

View File

@ -29,14 +29,11 @@ export class SsoComponent extends BaseSsoComponent {
storageService: StorageService, stateService: StateService, storageService: StorageService, stateService: StateService,
platformUtilsService: PlatformUtilsService, apiService: ApiService, platformUtilsService: PlatformUtilsService, apiService: ApiService,
cryptoFunctionService: CryptoFunctionService, passwordGenerationService: PasswordGenerationService, cryptoFunctionService: CryptoFunctionService, passwordGenerationService: PasswordGenerationService,
syncService: SyncService, private environmentService: EnvironmentService) { syncService: SyncService, environmentService: EnvironmentService) {
super(authService, router, i18nService, route, storageService, stateService, platformUtilsService, super(authService, router, i18nService, route, storageService, stateService, platformUtilsService,
apiService, cryptoFunctionService, passwordGenerationService); apiService, cryptoFunctionService, environmentService, passwordGenerationService);
let url = this.environmentService.getWebVaultUrl(); const url = this.environmentService.getWebVaultUrl();
if (url == null) {
url = 'https://vault.bitwarden.com';
}
this.redirectUri = url + '/sso-connector.html'; this.redirectUri = url + '/sso-connector.html';
this.clientId = 'browser'; this.clientId = 'browser';

View File

@ -31,7 +31,7 @@ import { ExportService } from 'jslib-common/abstractions/export.service';
import { FileUploadService } from 'jslib-common/abstractions/fileUpload.service'; import { FileUploadService } from 'jslib-common/abstractions/fileUpload.service';
import { FolderService } from 'jslib-common/abstractions/folder.service'; import { FolderService } from 'jslib-common/abstractions/folder.service';
import { I18nService } from 'jslib-common/abstractions/i18n.service'; import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { LogService } from 'jslib-common/abstractions/log.service'; import { LogService as LogServiceAbstraction } from 'jslib-common/abstractions/log.service';
import { MessagingService } from 'jslib-common/abstractions/messaging.service'; import { MessagingService } from 'jslib-common/abstractions/messaging.service';
import { NotificationsService } from 'jslib-common/abstractions/notifications.service'; import { NotificationsService } from 'jslib-common/abstractions/notifications.service';
import { PasswordGenerationService } from 'jslib-common/abstractions/passwordGeneration.service'; import { PasswordGenerationService } from 'jslib-common/abstractions/passwordGeneration.service';
@ -140,7 +140,7 @@ export function initFactory(platformUtilsService: PlatformUtilsService, i18nServ
}, },
{ provide: FolderService, useFactory: getBgService<FolderService>('folderService'), deps: [] }, { provide: FolderService, useFactory: getBgService<FolderService>('folderService'), deps: [] },
{ provide: CollectionService, useFactory: getBgService<CollectionService>('collectionService'), deps: [] }, { provide: CollectionService, useFactory: getBgService<CollectionService>('collectionService'), deps: [] },
{ provide: LogService, useFactory: getBgService<ConsoleLogService>('logService'), deps: [] }, { provide: LogServiceAbstraction, useFactory: getBgService<ConsoleLogService>('logService'), deps: [] },
{ provide: EnvironmentService, useFactory: getBgService<EnvironmentService>('environmentService'), deps: [] }, { provide: EnvironmentService, useFactory: getBgService<EnvironmentService>('environmentService'), deps: [] },
{ provide: TotpService, useFactory: getBgService<TotpService>('totpService'), deps: [] }, { provide: TotpService, useFactory: getBgService<TotpService>('totpService'), deps: [] },
{ provide: TokenService, useFactory: getBgService<TokenService>('tokenService'), deps: [] }, { provide: TokenService, useFactory: getBgService<TokenService>('tokenService'), deps: [] },

View File

@ -318,10 +318,7 @@ export class SettingsComponent implements OnInit {
} }
async webVault() { async webVault() {
let url = this.environmentService.getWebVaultUrl(); const url = this.environmentService.getWebVaultUrl();
if (url == null) {
url = 'https://vault.bitwarden.com';
}
BrowserApi.createNewTab(url); BrowserApi.createNewTab(url);
} }