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.tokenService = new TokenService(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));
this.userService = new UserService(this.tokenService, 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.cryptoService);
this.notificationsService = new NotificationsService(this.userService, this.syncService, this.appIdService,
this.apiService, this.vaultTimeoutService, () => this.logout(true), this.logService);
this.environmentService = new EnvironmentService(this.apiService, this.storageService,
this.notificationsService);
this.apiService, this.vaultTimeoutService, this.environmentService, () => this.logout(true), this.logService);
this.popupUtilsService = new PopupUtilsService(this.platformUtilsService);
this.systemService = new SystemService(this.storageService, this.vaultTimeoutService,
this.messagingService, this.platformUtilsService, () => {
@ -295,7 +294,7 @@ export default class MainBackground {
await this.setIcon();
this.cleanupNotificationQueue();
this.fullSync(true);
setTimeout(() => this.notificationsService.init(this.environmentService), 2500);
setTimeout(() => this.notificationsService.init(), 2500);
resolve();
}, 500);
});

View File

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

View File

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

View File

@ -29,14 +29,11 @@ export class SsoComponent extends BaseSsoComponent {
storageService: StorageService, stateService: StateService,
platformUtilsService: PlatformUtilsService, apiService: ApiService,
cryptoFunctionService: CryptoFunctionService, passwordGenerationService: PasswordGenerationService,
syncService: SyncService, private environmentService: EnvironmentService) {
syncService: SyncService, environmentService: EnvironmentService) {
super(authService, router, i18nService, route, storageService, stateService, platformUtilsService,
apiService, cryptoFunctionService, passwordGenerationService);
apiService, cryptoFunctionService, environmentService, passwordGenerationService);
let url = this.environmentService.getWebVaultUrl();
if (url == null) {
url = 'https://vault.bitwarden.com';
}
const url = this.environmentService.getWebVaultUrl();
this.redirectUri = url + '/sso-connector.html';
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 { FolderService } from 'jslib-common/abstractions/folder.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 { NotificationsService } from 'jslib-common/abstractions/notifications.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: 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: TotpService, useFactory: getBgService<TotpService>('totpService'), deps: [] },
{ provide: TokenService, useFactory: getBgService<TokenService>('tokenService'), deps: [] },

View File

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