Skip to content

Commit

Permalink
feat: Run prettier after 2024.5.1 or 2024.6.3 merge upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
zatteo committed Jul 16, 2024
1 parent 1eef67f commit 3352733
Show file tree
Hide file tree
Showing 19 changed files with 69 additions and 45 deletions.
17 changes: 10 additions & 7 deletions apps/browser/src/auth/popup/login.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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;
}
Expand All @@ -246,7 +249,7 @@ export class LoginComponent extends BaseLoginComponent {
"me@" + hostname,
data.masterPassword,
null,
null
null,
);

this.formPromise = this.loginStrategyService.logIn(credentials);
Expand Down Expand Up @@ -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();
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions apps/browser/src/autofill/background/overlay.background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down Expand Up @@ -501,7 +501,7 @@ export class OverlayBackground implements OverlayBackgroundInterface {

return {
fullName,
username: cipher.contact.primaryEmail
username: cipher.contact.primaryEmail,
};
}
// Cozy customization end
Expand Down
2 changes: 1 addition & 1 deletion apps/browser/src/autofill/services/autofill.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ export default class AutofillService implements AutofillServiceInterface {
fillScript,
pageDetails,
filledFields,
options
options,
);

options.cipher.identity = new IdentityView();
Expand Down
10 changes: 4 additions & 6 deletions apps/browser/src/autofill/utils/svg-icons.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
// Cozy customization, replace Bitwarden by Cozy icons
//*
const logoIcon =
`
const logoIcon = `
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='#297EF1' fill-rule='evenodd' d='M21 11a3 3 0 1 1-.83 5.88l-.04-.01-2.95 2.94c-.1.1-.22.16-.35.18l-.1.01h-.99c-.32 0-.68-.24-.73-.55l-.01-.09v-1.03c0-.16.11-.29.26-.32h.42c.16 0 .29-.11.32-.26v-.43c0-.15.11-.28.26-.31h.42c.15 0 .28-.12.31-.26v-.43c0-.15.12-.28.26-.31l.07-.01h.6c.16 0 .3-.11.32-.26l.01-.06v-.48c-.13-.3-.22-.64-.24-.99L18 14a3 3 0 0 1 3-3zM10.94 5a4.24 4.24 0 0 1 4.2 3.67c1.1.1 2.1.61 2.79 1.38a4.99 4.99 0 0 0-1.92 3.68L16 14v.28l.02.12-.04.03-.15.1c-.18.16-.35.35-.48.55l-.09.16-.01.03-.13.07-.15.1c-.24.17-.44.38-.6.62l-.11.2-.16.1c-.27.16-.5.38-.68.64H7.24A4.21 4.21 0 0 1 3 12.82c0-1.1.43-2.13 1.2-2.92a4.24 4.24 0 0 1 2.53-1.22A4.24 4.24 0 0 1 10.93 5zm9.65 7.52l-.16.03h-.04a.57.57 0 0 0-.29.88l.07.08 1.36 1.35c.31.28.82.12.92-.3.02-.08.04-.17.04-.26l.01-.13v-.08c-.02-.35-.14-.7-.38-.98l-.1-.12-.07-.06a1.67 1.67 0 0 0-1.36-.41zm-7.44-.72a.4.4 0 0 0-.4.4v.1l.02.1.03.1-.18.14a3 3 0 0 1-3.42-.13.97.97 0 0 0 .05-.3.4.4 0 0 0-.4-.41.4.4 0 0 0-.42.39.4.4 0 0 1-.1.25l-.05.06-.15.12a.39.39 0 0 0-.06.52.42.42 0 0 0 .5.14l.06-.03.1-.07.23.15a3.81 3.81 0 0 0 4.1-.02l.2-.13.1.07.08.03a.43.43 0 0 0 .49-.14.4.4 0 0 0 0-.46l-.06-.06-.13-.1a.46.46 0 0 1-.09-.1.55.55 0 0 1-.05-.11l-.02-.06-.02-.15a.4.4 0 0 0-.25-.27l-.07-.02-.09-.01z'/></svg>
`
`;

const logoLockedIcon =
`
const logoLockedIcon = `
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='#297EF1' fill-rule='evenodd' d='M21 11a3 3 0 1 1-.83 5.88l-.04-.01-2.95 2.94c-.1.1-.22.16-.35.18l-.1.01h-.99c-.32 0-.68-.24-.73-.55l-.01-.09v-1.03c0-.16.11-.29.26-.32h.42c.16 0 .29-.11.32-.26v-.43c0-.15.11-.28.26-.31h.42c.15 0 .28-.12.31-.26v-.43c0-.15.12-.28.26-.31l.07-.01h.6c.16 0 .3-.11.32-.26l.01-.06v-.48c-.13-.3-.22-.64-.24-.99L18 14a3 3 0 0 1 3-3zM10.94 5a4.24 4.24 0 0 1 4.2 3.67c1.1.1 2.1.61 2.79 1.38a4.99 4.99 0 0 0-1.92 3.68L16 14v.28l.02.12-.04.03-.15.1c-.18.16-.35.35-.48.55l-.09.16-.01.03-.13.07-.15.1c-.24.17-.44.38-.6.62l-.11.2-.16.1c-.27.16-.5.38-.68.64H7.24A4.21 4.21 0 0 1 3 12.82c0-1.1.43-2.13 1.2-2.92a4.24 4.24 0 0 1 2.53-1.22A4.24 4.24 0 0 1 10.93 5zm9.65 7.52l-.16.03h-.04a.57.57 0 0 0-.29.88l.07.08 1.36 1.35c.31.28.82.12.92-.3.02-.08.04-.17.04-.26l.01-.13v-.08c-.02-.35-.14-.7-.38-.98l-.1-.12-.07-.06a1.67 1.67 0 0 0-1.36-.41zm-7.44-.72a.4.4 0 0 0-.4.4v.1l.02.1.03.1-.18.14a3 3 0 0 1-3.42-.13.97.97 0 0 0 .05-.3.4.4 0 0 0-.4-.41.4.4 0 0 0-.42.39.4.4 0 0 1-.1.25l-.05.06-.15.12a.39.39 0 0 0-.06.52.42.42 0 0 0 .5.14l.06-.03.1-.07.23.15a3.81 3.81 0 0 0 4.1-.02l.2-.13.1.07.08.03a.43.43 0 0 0 .49-.14.4.4 0 0 0 0-.46l-.06-.06-.13-.1a.46.46 0 0 1-.09-.1.55.55 0 0 1-.05-.11l-.02-.06-.02-.15a.4.4 0 0 0-.25-.27l-.07-.02-.09-.01z'/></svg>
`
`;
/*/
const logoIcon =
'<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 14 14" fill="none"><path fill="#175DDC" d="M12.66.175A.566.566 0 0 0 12.25 0H1.75a.559.559 0 0 0-.409.175.561.561 0 0 0-.175.41v7c.002.532.105 1.06.305 1.554.189.488.444.948.756 1.368.322.42.682.81 1.076 1.163.365.335.75.649 1.152.939.35.248.718.483 1.103.706.385.222.656.372.815.45.16.08.29.141.386.182A.53.53 0 0 0 7 14a.509.509 0 0 0 .238-.055c.098-.043.225-.104.387-.182.162-.079.438-.23.816-.45.378-.222.75-.459 1.102-.707.403-.29.788-.604 1.154-.939a8.435 8.435 0 0 0 1.076-1.163c.312-.42.567-.88.757-1.367a4.19 4.19 0 0 0 .304-1.555v-7a.55.55 0 0 0-.174-.407Z"/><path fill="#fff" d="M7 12.365s4.306-2.18 4.306-4.717V1.5H7v10.865Z"/></svg>';
Expand Down
7 changes: 5 additions & 2 deletions apps/browser/src/background/main.background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions apps/browser/src/popup/tabs.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

// Cozy customization, file is heavily modified to manage premium banner
//*
import { Component, NgZone, OnInit } from "@angular/core";
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class AboutPageComponent {
private dialogService: DialogService,
private environmentService: EnvironmentService,
private platformUtilsService: PlatformUtilsService,
private cozyClientService: CozyClientService
private cozyClientService: CozyClientService,
) {}

about() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion libs/auth/src/common/login-strategies/login.strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ export abstract class LoginStrategy {
await this.tokenService.setCozyTokens(
tokenResponse.accessToken,
tokenResponse.clientId,
tokenResponse.registrationAccessToken
tokenResponse.registrationAccessToken,
);
// Cozy customization end

Expand Down
8 changes: 6 additions & 2 deletions libs/common/src/auth/abstractions/token.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,12 @@ export abstract class TokenService {
setSecurityStamp: (securityStamp: string, userId?: UserId) => Promise<void>;

// Cozy customization
setCozyTokens: (accessToken: string, clientId: string, registrationAccessToken: string) => Promise<void>;
setCozyTokens: (
accessToken: string,
clientId: string,
registrationAccessToken: string,
) => Promise<void>;

getCozyTokens: () => Promise<{clientId: string, registrationAccessToken: string}>;
getCozyTokens: () => Promise<{ clientId: string; registrationAccessToken: string }>;
// Cozy customization end
}
17 changes: 11 additions & 6 deletions libs/common/src/auth/services/token.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1120,30 +1120,35 @@ 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) {
throw new Error("User id not found. Cannot get cozy tokens.");
}

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<void> {
async setCozyTokens(
accessToken: string,
clientId: string,
registrationAccessToken: string,
): Promise<void> {
// get user id the access token
const userId: UserId = await this.getUserIdFromAccessToken(accessToken);

if (!userId) {
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)
Expand Down
13 changes: 8 additions & 5 deletions libs/common/src/auth/services/token.state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,12 @@ export const CLIENT_ID_DISK = new UserKeyDefinition<string>(TOKEN_DISK, "clientI
clearOn: [], // Manually handled
});


export const REGISTRATION_ACCESS_TOKEN_DISK = new UserKeyDefinition<string>(TOKEN_DISK, "registrationAccessToken", {
deserializer: (registrationAccessToken) => registrationAccessToken,
clearOn: [], // Manually handled
});
export const REGISTRATION_ACCESS_TOKEN_DISK = new UserKeyDefinition<string>(
TOKEN_DISK,
"registrationAccessToken",
{
deserializer: (registrationAccessToken) => registrationAccessToken,
clearOn: [], // Manually handled
},
);
// Cozy customization end
6 changes: 5 additions & 1 deletion libs/common/src/platform/abstractions/crypto.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,11 @@ export abstract class CryptoService {
): Promise<Uint8Array>;

// Cozy customization
abstract upsertOrganizationKey(userId: UserId, organizationId: OrganizationId, key: string): Promise<void>
abstract upsertOrganizationKey(
userId: UserId,
organizationId: OrganizationId,
key: string,
): Promise<void>;
// Cozy customization end

/**
Expand Down
4 changes: 2 additions & 2 deletions libs/common/src/platform/models/domain/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ export class Account {
//*
settings: {
profilesCleanDeadline?: string;
}
//*/
};
//*/

constructor(init: Partial<Account>) {
Object.assign(this, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,5 @@ export class ConfigApiService implements ConfigApiServiceAbstraction {
const r = await this.apiService.send("GET", "/config", null, authed, true);
return new ServerConfigResponse(r);
//*/

}
}
4 changes: 3 additions & 1 deletion libs/common/src/platform/services/crypto.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion libs/common/src/platform/sync/default-sync.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions libs/common/src/vault/services/cipher.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ export class CipherService implements CipherServiceAbstraction {
(await this.getAll()).filter(
(cipher) => !cipher.organizationId || orgIds.includes(cipher.organizationId),
),
activeUserId
activeUserId,
);

/*/
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 3352733

Please sign in to comment.