From 33527334b4d8074461ae0724fad834f90ec50d7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Poizat?= Date: Tue, 16 Jul 2024 17:30:50 +0200 Subject: [PATCH] feat: Run prettier after 2024.5.1 or 2024.6.3 merge upstream --- apps/browser/src/auth/popup/login.component.ts | 17 ++++++++++------- .../autofill/background/overlay.background.ts | 4 ++-- .../src/autofill/services/autofill.service.ts | 2 +- apps/browser/src/autofill/utils/svg-icons.ts | 10 ++++------ apps/browser/src/background/main.background.ts | 7 +++++-- apps/browser/src/popup/tabs.component.ts | 3 +-- .../settings/about-page/about-page.component.ts | 2 +- .../popup/services/vault-popup-items.service.ts | 2 +- .../common/login-strategies/login.strategy.ts | 2 +- .../src/auth/abstractions/token.service.ts | 8 ++++++-- libs/common/src/auth/services/token.service.ts | 17 +++++++++++------ libs/common/src/auth/services/token.state.ts | 13 ++++++++----- .../src/platform/abstractions/crypto.service.ts | 6 +++++- .../src/platform/models/domain/account.ts | 4 ++-- .../services/config/config-api.service.ts | 1 - .../src/platform/services/crypto.service.ts | 4 +++- .../services/default-environment.service.ts | 2 +- .../src/platform/sync/default-sync.service.ts | 6 +++++- .../common/src/vault/services/cipher.service.ts | 4 ++-- 19 files changed, 69 insertions(+), 45 deletions(-) diff --git a/apps/browser/src/auth/popup/login.component.ts b/apps/browser/src/auth/popup/login.component.ts index d1fc4e08c63c..ff4568a1be51 100644 --- a/apps/browser/src/auth/popup/login.component.ts +++ b/apps/browser/src/auth/popup/login.component.ts @@ -20,7 +20,10 @@ import { SsoLoginServiceAbstraction } from "@bitwarden/common/auth/abstractions/ import { WebAuthnLoginServiceAbstraction } from "@bitwarden/common/auth/abstractions/webauthn/webauthn-login.service.abstraction"; import { AppIdService } from "@bitwarden/common/platform/abstractions/app-id.service"; import { CryptoFunctionService } from "@bitwarden/common/platform/abstractions/crypto-function.service"; -import { EnvironmentService, Region } from "@bitwarden/common/platform/abstractions/environment.service"; +import { + EnvironmentService, + Region, +} from "@bitwarden/common/platform/abstractions/environment.service"; import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; import { LogService } from "@bitwarden/common/platform/abstractions/log.service"; import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service"; @@ -140,7 +143,7 @@ export class LoginComponent extends BaseLoginComponent { const syncPromise = syncService.fullSync(true).then(() => { this.cozyClientService.saveCozyCredentials( sanitizeUrlInput(this.formGroup.value.email, this.cozySanitizeUrlService), - this.formGroup.value.masterPassword + this.formGroup.value.masterPassword, ); }); this.konnectorsService.getKonnectorsOrganization(); @@ -226,7 +229,7 @@ export class LoginComponent extends BaseLoginComponent { this.platformUtilsService.showToast( "error", this.i18nService.t("errorOccurred"), - this.i18nService.t("masterPassRequired") + this.i18nService.t("masterPassRequired"), ); return; } @@ -246,7 +249,7 @@ export class LoginComponent extends BaseLoginComponent { "me@" + hostname, data.masterPassword, null, - null + null, ); this.formPromise = this.loginStrategyService.logIn(credentials); @@ -307,7 +310,7 @@ export class LoginComponent extends BaseLoginComponent { //* async configureTheme() { const useContrastedThemeByDefault = await this.cozyClientService.getFlagValue( - "passwords.theme.default-contrasted" + "passwords.theme.default-contrasted", ); const isUserSetTheme = await this.stateService.getIsUserSetTheme(); @@ -333,7 +336,7 @@ export class LoginComponent extends BaseLoginComponent { this.platformUtilsService.showToast( "error", this.i18nService.t("errorOccurred"), - this.i18nService.t("cozyUrlRequired") + this.i18nService.t("cozyUrlRequired"), ); return; } @@ -347,7 +350,7 @@ export class LoginComponent extends BaseLoginComponent { this.platformUtilsService.showToast( "error", this.i18nService.t("errorOccurred"), - this.i18nService.t("invalidCozyUrl") + this.i18nService.t("invalidCozyUrl"), ); return; } diff --git a/apps/browser/src/autofill/background/overlay.background.ts b/apps/browser/src/autofill/background/overlay.background.ts index 4277bf66f61f..c03eaccb8d2e 100644 --- a/apps/browser/src/autofill/background/overlay.background.ts +++ b/apps/browser/src/autofill/background/overlay.background.ts @@ -291,7 +291,7 @@ export class OverlayBackground implements OverlayBackgroundInterface { await this.cipherService.getAllDecryptedForUrl(currentTab.url, [ CipherType.Card, CipherType.Identity, - CipherType.Contact // Cozy customization; add contact to autofill + CipherType.Contact, // Cozy customization; add contact to autofill ]) ).sort((a, b) => this.cipherService.sortCiphersByLastUsedThenName(a, b)); for (let cipherIndex = 0; cipherIndex < cipherViews.length; cipherIndex++) { @@ -501,7 +501,7 @@ export class OverlayBackground implements OverlayBackgroundInterface { return { fullName, - username: cipher.contact.primaryEmail + username: cipher.contact.primaryEmail, }; } // Cozy customization end diff --git a/apps/browser/src/autofill/services/autofill.service.ts b/apps/browser/src/autofill/services/autofill.service.ts index aaa6b7ad2736..647289dcfd39 100644 --- a/apps/browser/src/autofill/services/autofill.service.ts +++ b/apps/browser/src/autofill/services/autofill.service.ts @@ -665,7 +665,7 @@ export default class AutofillService implements AutofillServiceInterface { fillScript, pageDetails, filledFields, - options + options, ); options.cipher.identity = new IdentityView(); diff --git a/apps/browser/src/autofill/utils/svg-icons.ts b/apps/browser/src/autofill/utils/svg-icons.ts index 4f35797e5a2d..0fce8043293a 100644 --- a/apps/browser/src/autofill/utils/svg-icons.ts +++ b/apps/browser/src/autofill/utils/svg-icons.ts @@ -1,14 +1,12 @@ // Cozy customization, replace Bitwarden by Cozy icons //* -const logoIcon = - ` +const logoIcon = ` - ` + `; -const logoLockedIcon = -` +const logoLockedIcon = ` -` +`; /*/ const logoIcon = ''; diff --git a/apps/browser/src/background/main.background.ts b/apps/browser/src/background/main.background.ts index a5b1ca304be7..bbb09b7382c8 100755 --- a/apps/browser/src/background/main.background.ts +++ b/apps/browser/src/background/main.background.ts @@ -142,7 +142,10 @@ import { StateEventRegistrarService } from "@bitwarden/common/platform/state/sta import { SyncService } from "@bitwarden/common/platform/sync"; // eslint-disable-next-line no-restricted-imports -- Needed for service creation import { DefaultSyncService } from "@bitwarden/common/platform/sync/internal"; -import { DefaultThemeStateService, ThemeStateService } from "@bitwarden/common/platform/theming/theme-state.service"; +import { + DefaultThemeStateService, + ThemeStateService, +} from "@bitwarden/common/platform/theming/theme-state.service"; import { ApiService } from "@bitwarden/common/services/api.service"; import { AuditService } from "@bitwarden/common/services/audit.service"; import { EventCollectionService } from "@bitwarden/common/services/event/event-collection.service"; @@ -651,7 +654,7 @@ export default class MainBackground { this.logService, (logoutReason: LogoutReason, userId?: UserId) => this.logout(logoutReason, userId), this.vaultTimeoutSettingsService, - this.buildUserAgent() + this.buildUserAgent(), ); this.domainSettingsService = new DefaultDomainSettingsService(this.stateProvider); diff --git a/apps/browser/src/popup/tabs.component.ts b/apps/browser/src/popup/tabs.component.ts index 7b0240a0922f..4abb3b137439 100644 --- a/apps/browser/src/popup/tabs.component.ts +++ b/apps/browser/src/popup/tabs.component.ts @@ -1,4 +1,3 @@ - // Cozy customization, file is heavily modified to manage premium banner //* import { Component, NgZone, OnInit } from "@angular/core"; @@ -72,7 +71,7 @@ export class TabsComponent implements OnInit { } TabsComponent.showBanner = - !await this.cozyClientService.getFlagValue("passwords.can-share-organizations") && + !(await this.cozyClientService.getFlagValue("passwords.can-share-organizations")) && TabsComponent.isVaultTooOld && !TabsComponent.closedByUser; } diff --git a/apps/browser/src/tools/popup/settings/about-page/about-page.component.ts b/apps/browser/src/tools/popup/settings/about-page/about-page.component.ts index a1f311eee2b7..93daf63ec0f7 100644 --- a/apps/browser/src/tools/popup/settings/about-page/about-page.component.ts +++ b/apps/browser/src/tools/popup/settings/about-page/about-page.component.ts @@ -52,7 +52,7 @@ export class AboutPageComponent { private dialogService: DialogService, private environmentService: EnvironmentService, private platformUtilsService: PlatformUtilsService, - private cozyClientService: CozyClientService + private cozyClientService: CozyClientService, ) {} about() { diff --git a/apps/browser/src/vault/popup/services/vault-popup-items.service.ts b/apps/browser/src/vault/popup/services/vault-popup-items.service.ts index 33b2fc41be2d..bccc15ef685a 100644 --- a/apps/browser/src/vault/popup/services/vault-popup-items.service.ts +++ b/apps/browser/src/vault/popup/services/vault-popup-items.service.ts @@ -254,7 +254,7 @@ export class VaultPopupItemsService { [CipherType.Identity]: 3, [CipherType.SecureNote]: 4, [CipherType.Paper]: 1000, - [CipherType.Contact]: 1001 + [CipherType.Contact]: 1001, }; // Compare types first diff --git a/libs/auth/src/common/login-strategies/login.strategy.ts b/libs/auth/src/common/login-strategies/login.strategy.ts index 9a8b30714957..293f22996544 100644 --- a/libs/auth/src/common/login-strategies/login.strategy.ts +++ b/libs/auth/src/common/login-strategies/login.strategy.ts @@ -177,7 +177,7 @@ export abstract class LoginStrategy { await this.tokenService.setCozyTokens( tokenResponse.accessToken, tokenResponse.clientId, - tokenResponse.registrationAccessToken + tokenResponse.registrationAccessToken, ); // Cozy customization end diff --git a/libs/common/src/auth/abstractions/token.service.ts b/libs/common/src/auth/abstractions/token.service.ts index f79d6f5792a0..6b62e87f4f60 100644 --- a/libs/common/src/auth/abstractions/token.service.ts +++ b/libs/common/src/auth/abstractions/token.service.ts @@ -223,8 +223,12 @@ export abstract class TokenService { setSecurityStamp: (securityStamp: string, userId?: UserId) => Promise; // Cozy customization - setCozyTokens: (accessToken: string, clientId: string, registrationAccessToken: string) => Promise; + setCozyTokens: ( + accessToken: string, + clientId: string, + registrationAccessToken: string, + ) => Promise; - getCozyTokens: () => Promise<{clientId: string, registrationAccessToken: string}>; + getCozyTokens: () => Promise<{ clientId: string; registrationAccessToken: string }>; // Cozy customization end } diff --git a/libs/common/src/auth/services/token.service.ts b/libs/common/src/auth/services/token.service.ts index 8aa9e11dd2be..5cffe454d96d 100644 --- a/libs/common/src/auth/services/token.service.ts +++ b/libs/common/src/auth/services/token.service.ts @@ -1120,7 +1120,7 @@ export class TokenService implements TokenServiceAbstraction { } // Cozy customization - async getCozyTokens(): Promise<{clientId: string, registrationAccessToken: string} | null> { + async getCozyTokens(): Promise<{ clientId: string; registrationAccessToken: string } | null> { const userId = await firstValueFrom(this.activeUserIdGlobalState.state$); if (!userId) { @@ -1128,12 +1128,19 @@ export class TokenService implements TokenServiceAbstraction { } const clientId = await this.getStateValueByUserIdAndKeyDef(userId, CLIENT_ID_DISK); - const registrationAccessToken = await this.getStateValueByUserIdAndKeyDef(userId, REGISTRATION_ACCESS_TOKEN_DISK); + const registrationAccessToken = await this.getStateValueByUserIdAndKeyDef( + userId, + REGISTRATION_ACCESS_TOKEN_DISK, + ); return { clientId, registrationAccessToken }; } - async setCozyTokens(accessToken: string, clientId: string, registrationAccessToken: string): Promise { + async setCozyTokens( + accessToken: string, + clientId: string, + registrationAccessToken: string, + ): Promise { // get user id the access token const userId: UserId = await this.getUserIdFromAccessToken(accessToken); @@ -1141,9 +1148,7 @@ export class TokenService implements TokenServiceAbstraction { throw new Error("User id not found. Cannot set cozy tokens."); } - await this.singleUserStateProvider - .get(userId, CLIENT_ID_DISK) - .update((_) => clientId); + await this.singleUserStateProvider.get(userId, CLIENT_ID_DISK).update((_) => clientId); await this.singleUserStateProvider .get(userId, REGISTRATION_ACCESS_TOKEN_DISK) diff --git a/libs/common/src/auth/services/token.state.ts b/libs/common/src/auth/services/token.state.ts index 0b53a18d0d23..739c60ac1935 100644 --- a/libs/common/src/auth/services/token.state.ts +++ b/libs/common/src/auth/services/token.state.ts @@ -81,9 +81,12 @@ export const CLIENT_ID_DISK = new UserKeyDefinition(TOKEN_DISK, "clientI clearOn: [], // Manually handled }); - -export const REGISTRATION_ACCESS_TOKEN_DISK = new UserKeyDefinition(TOKEN_DISK, "registrationAccessToken", { - deserializer: (registrationAccessToken) => registrationAccessToken, - clearOn: [], // Manually handled -}); +export const REGISTRATION_ACCESS_TOKEN_DISK = new UserKeyDefinition( + TOKEN_DISK, + "registrationAccessToken", + { + deserializer: (registrationAccessToken) => registrationAccessToken, + clearOn: [], // Manually handled + }, +); // Cozy customization end diff --git a/libs/common/src/platform/abstractions/crypto.service.ts b/libs/common/src/platform/abstractions/crypto.service.ts index 7a120c42d1fa..52ef0f0bc989 100644 --- a/libs/common/src/platform/abstractions/crypto.service.ts +++ b/libs/common/src/platform/abstractions/crypto.service.ts @@ -386,7 +386,11 @@ export abstract class CryptoService { ): Promise; // Cozy customization - abstract upsertOrganizationKey(userId: UserId, organizationId: OrganizationId, key: string): Promise + abstract upsertOrganizationKey( + userId: UserId, + organizationId: OrganizationId, + key: string, + ): Promise; // Cozy customization end /** diff --git a/libs/common/src/platform/models/domain/account.ts b/libs/common/src/platform/models/domain/account.ts index fb62e6406f97..af22bab926c5 100644 --- a/libs/common/src/platform/models/domain/account.ts +++ b/libs/common/src/platform/models/domain/account.ts @@ -123,8 +123,8 @@ export class Account { //* settings: { profilesCleanDeadline?: string; - } - //*/ + }; + //*/ constructor(init: Partial) { Object.assign(this, { diff --git a/libs/common/src/platform/services/config/config-api.service.ts b/libs/common/src/platform/services/config/config-api.service.ts index 064ce3a155f7..b9cb1c775dc2 100644 --- a/libs/common/src/platform/services/config/config-api.service.ts +++ b/libs/common/src/platform/services/config/config-api.service.ts @@ -26,6 +26,5 @@ export class ConfigApiService implements ConfigApiServiceAbstraction { const r = await this.apiService.send("GET", "/config", null, authed, true); return new ServerConfigResponse(r); //*/ - } } diff --git a/libs/common/src/platform/services/crypto.service.ts b/libs/common/src/platform/services/crypto.service.ts index 3c80d3a7372a..f91a4fdd2116 100644 --- a/libs/common/src/platform/services/crypto.service.ts +++ b/libs/common/src/platform/services/crypto.service.ts @@ -898,7 +898,9 @@ export class CryptoService implements CryptoServiceAbstraction { return; } - const encOrgKeys = await firstValueFrom(this.stateProvider.getUser(userId, USER_ENCRYPTED_ORGANIZATION_KEYS).state$); + const encOrgKeys = await firstValueFrom( + this.stateProvider.getUser(userId, USER_ENCRYPTED_ORGANIZATION_KEYS).state$, + ); encOrgKeys[organizationId] = key as unknown as EncryptedOrganizationKeyData; diff --git a/libs/common/src/platform/services/default-environment.service.ts b/libs/common/src/platform/services/default-environment.service.ts index 4d9a48846bd7..a532e4d322b9 100644 --- a/libs/common/src/platform/services/default-environment.service.ts +++ b/libs/common/src/platform/services/default-environment.service.ts @@ -128,7 +128,7 @@ export class DefaultEnvironmentService implements EnvironmentService { protected webVaultUrlSync: string; getWebVaultUrlSync() { - return this.webVaultUrlSync + return this.webVaultUrlSync; } // We intentionally don't want the helper on account service, we want the null back if there is no active user diff --git a/libs/common/src/platform/sync/default-sync.service.ts b/libs/common/src/platform/sync/default-sync.service.ts index db8c6209e203..e9832381fa5a 100644 --- a/libs/common/src/platform/sync/default-sync.service.ts +++ b/libs/common/src/platform/sync/default-sync.service.ts @@ -463,7 +463,11 @@ export class DefaultSyncService extends CoreSyncService { const remoteOrganizationKey = await this.getOrganizationKey(organizationId); - await this.cryptoService.upsertOrganizationKey(userId as UserId, organizationId as OrganizationId, remoteOrganizationKey); + await this.cryptoService.upsertOrganizationKey( + userId as UserId, + organizationId as OrganizationId, + remoteOrganizationKey, + ); } protected async syncUpsertOrganization(organizationId: string, isEdit: boolean) { diff --git a/libs/common/src/vault/services/cipher.service.ts b/libs/common/src/vault/services/cipher.service.ts index 8ab3587a093a..94609562728b 100644 --- a/libs/common/src/vault/services/cipher.service.ts +++ b/libs/common/src/vault/services/cipher.service.ts @@ -394,7 +394,7 @@ export class CipherService implements CipherServiceAbstraction { (await this.getAll()).filter( (cipher) => !cipher.organizationId || orgIds.includes(cipher.organizationId), ), - activeUserId + activeUserId, ); /*/ @@ -959,7 +959,7 @@ export class CipherService implements CipherServiceAbstraction { // which is very costly with our papers and contacts. Instead we manually update decrypted ciphers below. await this.encryptedCiphersState.update(() => ciphers); - const decryptedCiphers = await firstValueFrom(this.cipherViews$) + const decryptedCiphers = await firstValueFrom(this.cipherViews$); if (decryptedCiphers == null) { return; }