1
0
mirror of https://github.com/bitwarden/web synced 2025-12-11 05:43:16 +00:00

[Account Switching] [Refactor] Implement new account centric services (#1220)

* [chore] updated services.module to use account services

* [refactor] sorted services provided by services.module

* [chore] removed references to deleted jslib services

* [chore] used activeAccount over storageService for account level storage items

* [chore] resolved linter warnings

* Refactor activeAccountService to stateService

* [bug] Remove uneeded calls to state service on logout

This was causing console erros on logout. Clearing of data is handled fully in dedicated services, clearing them in state afterwards is essentially a redundant call.

* [bug] Add back null locked callback to VaultTimeoutService

* Move call to get showUpdateKey

* [bug] Ensure HtmlStorageService does not override StateService options and locations

* [bug] Adjust theme logic to pull from the new storage locations

* [bug] Correct theme not sticking on refresh

* [bug] Add enableFullWidth to the account model

* [bug] fix theme option empty when light is selected

* [bug] init state on application start

* [bug] Reinit state when coming back from a lock

* [style] Fix lint complaints

* [bug] Clean state on logout

* [chore] Resolved merge issues

* [bug] Correct default for enableGravitars

* Bump angular to 12.

* Remove angular.json

* Bump rxjs

* Fix build errors, remove file-loader with asset/resource

* Use contenthash

* Bump jslib

* Bump ngx-toastr

* [chore] resolve issues from merge

* [chore] resolve issues from merge

* [bug] Add missing bracket

* Use newer import syntax

* [bug] Correct service orge

* [style] Fix lint complaints

* [chore] update jslib

* [review] Address code review

* [review] Address code review

* [review] Rename providerService to webProviderService

Co-authored-by: Robyn MacCallum <robyntmaccallum@gmail.com>
Co-authored-by: Hinton <oscar@oscarhinton.com>
This commit is contained in:
Addison Beck
2021-12-14 11:10:26 -05:00
committed by GitHub
parent 71075cf878
commit 17ae5ee57c
101 changed files with 839 additions and 649 deletions

View File

@@ -22,7 +22,6 @@ import { JslibServicesModule } from 'jslib-angular/services/jslib-services.modul
import { ModalService as ModalServiceAbstraction } from 'jslib-angular/services/modal.service';
import { AuthService } from 'jslib-common/services/auth.service';
import { ConstantsService } from 'jslib-common/services/constants.service';
import { ContainerService } from 'jslib-common/services/container.service';
import { CryptoService } from 'jslib-common/services/crypto.service';
import { EventService as EventLoggingService } from 'jslib-common/services/event.service';
@@ -57,6 +56,7 @@ export function initFactory(window: Window, storageService: StorageServiceAbstra
platformUtilsService: PlatformUtilsServiceAbstraction, cryptoService: CryptoServiceAbstraction): Function {
return async () => {
await (storageService as HtmlStorageService).init();
await stateService.init();
const urls = process.env.URLS as Urls;
urls.base ??= window.location.origin;
@@ -65,7 +65,7 @@ export function initFactory(window: Window, storageService: StorageServiceAbstra
setTimeout(() => notificationsService.init(), 3000);
vaultTimeoutService.init(true);
const locale = await storageService.get<string>(ConstantsService.localeKey);
const locale = await stateService.getLocale();
await i18nService.init(locale);
eventLoggingService.init(true);
authService.init();
@@ -74,17 +74,13 @@ export function initFactory(window: Window, storageService: StorageServiceAbstra
// Initial theme is set in index.html which must be updated if there are any changes to theming logic
platformUtilsService.onDefaultSystemThemeChange(async sysTheme => {
const bwTheme = await storageService.get<ThemeType>(ConstantsService.themeKey);
const bwTheme = await stateService.getTheme();
if (bwTheme === ThemeType.System) {
htmlEl.classList.remove('theme_' + ThemeType.Light, 'theme_' + ThemeType.Dark);
htmlEl.classList.add('theme_' + sysTheme);
}
});
stateService.save(ConstantsService.disableFaviconKey,
await storageService.get<boolean>(ConstantsService.disableFaviconKey));
stateService.save('enableGravatars', await storageService.get<boolean>('enableGravatars'));
const containerService = new ContainerService(cryptoService);
containerService.attachToWindow(window);
};
@@ -130,13 +126,13 @@ export function initFactory(window: Window, storageService: StorageServiceAbstra
{
provide: PlatformUtilsServiceAbstraction,
useFactory: (i18nService: I18nServiceAbstraction, messagingService: MessagingServiceAbstraction,
logService: LogService, injector: Injector) => new WebPlatformUtilsService(i18nService,
messagingService, logService, () => injector.get(StorageServiceAbstraction)),
logService: LogService, stateService: StateServiceAbstraction) => new WebPlatformUtilsService(i18nService,
messagingService, logService, stateService),
deps: [
I18nServiceAbstraction,
MessagingServiceAbstraction,
LogService,
Injector, // TODO: Get rid of circular dependency!
StateServiceAbstraction,
],
},
{ provide: MessagingServiceAbstraction, useClass: BroadcasterMessagingService },
@@ -156,19 +152,12 @@ export function initFactory(window: Window, storageService: StorageServiceAbstra
},
{
provide: CryptoServiceAbstraction,
useFactory: (storageService: StorageServiceAbstraction, secureStorageService: StorageServiceAbstraction,
cryptoFunctionService: CryptoFunctionServiceAbstraction,
platformUtilsService: PlatformUtilsServiceAbstraction, logService: LogService) => {
const storageImplementation = platformUtilsService.isDev() ? storageService : secureStorageService;
return new CryptoService(storageService, storageImplementation, cryptoFunctionService,
platformUtilsService, logService);
},
useClass: CryptoService,
deps: [
StorageServiceAbstraction,
'SECURE_STORAGE',
CryptoFunctionServiceAbstraction,
PlatformUtilsServiceAbstraction,
LogService,
StateServiceAbstraction,
],
},
],