Skip to content

Commit

Permalink
Merge branch 'main' into PM-11777-browser-extension-totp-not-copied-w…
Browse files Browse the repository at this point in the history
…hen-autofilling-passkey
  • Loading branch information
dan-livefront authored Nov 1, 2024
2 parents b86b7fc + 5eae599 commit 4e3e8a8
Show file tree
Hide file tree
Showing 20 changed files with 274 additions and 101 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EVENTS } from "@bitwarden/common/autofill/constants";
import { ThemeType } from "@bitwarden/common/platform/enums";
import { ThemeTypes } from "@bitwarden/common/platform/enums";

import { setElementStyles } from "../../../utils";
import {
Expand Down Expand Up @@ -210,19 +210,19 @@ class AutofillOverlayIframeService implements AutofillOverlayIframeServiceInterf
const { theme } = message;
let borderColor: string;
let verifiedTheme = theme;
if (verifiedTheme === ThemeType.System) {
if (verifiedTheme === ThemeTypes.System) {
verifiedTheme = globalThis.matchMedia("(prefers-color-scheme: dark)").matches
? ThemeType.Dark
: ThemeType.Light;
? ThemeTypes.Dark
: ThemeTypes.Light;
}

if (verifiedTheme === ThemeType.Dark) {
if (verifiedTheme === ThemeTypes.Dark) {
borderColor = "#4c525f";
}
if (theme === ThemeType.Nord) {
if (theme === ThemeTypes.Nord) {
borderColor = "#2E3440";
}
if (theme === ThemeType.SolarizedDark) {
if (theme === ThemeTypes.SolarizedDark) {
borderColor = "#073642";
}
if (borderColor) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { Theme } from "@bitwarden/common/platform/enums";

type NotificationBarIframeInitData = {
type?: string;
isVaultLocked?: boolean;
theme?: string;
theme?: Theme;
removeIndividualVault?: boolean;
importType?: string;
applyRedesign?: boolean;
Expand Down
8 changes: 4 additions & 4 deletions apps/browser/src/autofill/notification/bar.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ThemeType } from "@bitwarden/common/platform/enums";
import { ThemeTypes } from "@bitwarden/common/platform/enums";
import { ConsoleLogService } from "@bitwarden/common/platform/services/console-log.service";
import type { FolderView } from "@bitwarden/common/vault/models/view/folder.view";

Expand Down Expand Up @@ -392,10 +392,10 @@ function setupLogoLink(i18n: Record<string, string>) {

function setNotificationBarTheme() {
let theme = notificationBarIframeInitData.theme;
if (theme === ThemeType.System) {
if (theme === ThemeTypes.System) {
theme = globalThis.matchMedia("(prefers-color-scheme: dark)").matches
? ThemeType.Dark
: ThemeType.Light;
? ThemeTypes.Dark
: ThemeTypes.Light;
}

document.documentElement.classList.add(`theme_${theme}`);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EVENTS } from "@bitwarden/common/autofill/constants";
import { ThemeType } from "@bitwarden/common/platform/enums";
import { ThemeTypes } from "@bitwarden/common/platform/enums";

import { sendExtensionMessage, setElementStyles } from "../../../utils";
import {
Expand Down Expand Up @@ -239,19 +239,19 @@ export class AutofillInlineMenuIframeService implements AutofillInlineMenuIframe
const { theme } = message;
let borderColor: string;
let verifiedTheme = theme;
if (verifiedTheme === ThemeType.System) {
if (verifiedTheme === ThemeTypes.System) {
verifiedTheme = globalThis.matchMedia("(prefers-color-scheme: dark)").matches
? ThemeType.Dark
: ThemeType.Light;
? ThemeTypes.Dark
: ThemeTypes.Light;
}

if (verifiedTheme === ThemeType.Dark) {
if (verifiedTheme === ThemeTypes.Dark) {
borderColor = "#4c525f";
}
if (theme === ThemeType.Nord) {
if (theme === ThemeTypes.Nord) {
borderColor = "#2E3440";
}
if (theme === ThemeType.SolarizedDark) {
if (theme === ThemeTypes.SolarizedDark) {
borderColor = "#073642";
}
if (borderColor) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Theme } from "@bitwarden/common/platform/enums";

export type NotificationTypeData = {
isVaultLocked?: boolean;
theme?: string;
theme?: Theme;
removeIndividualVault?: boolean;
importType?: string;
launchTimestamp?: number;
Expand Down
4 changes: 2 additions & 2 deletions apps/browser/src/autofill/spec/autofill-mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { mock } from "jest-mock-extended";

import { AuthenticationStatus } from "@bitwarden/common/auth/enums/authentication-status";
import { UriMatchStrategy } from "@bitwarden/common/models/domain/domain-service";
import { ThemeType } from "@bitwarden/common/platform/enums";
import { ThemeTypes } from "@bitwarden/common/platform/enums";
import { CipherType } from "@bitwarden/common/vault/enums";
import { CipherRepromptType } from "@bitwarden/common/vault/enums/cipher-reprompt-type";
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
Expand Down Expand Up @@ -210,7 +210,7 @@ export function createInitAutofillInlineMenuListMessageMock(
command: "initAutofillInlineMenuList",
translations: overlayPagesTranslations,
styleSheetUrl: "https://jest-testing-website.com",
theme: ThemeType.Light,
theme: ThemeTypes.Light,
authStatus: AuthenticationStatus.Unlocked,
portKey: "portKey",
inlineMenuFillType: CipherType.Login,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe("SendCreatedComponent", () => {

sendView = {
id: sendId,
deletionDate: new Date(),
deletionDate: new Date(Date.now() + 7 * 24 * 60 * 60 * 1000),
type: SendType.Text,
accessId: "abc",
urlB64Key: "123",
Expand Down Expand Up @@ -127,8 +127,8 @@ describe("SendCreatedComponent", () => {

it("should initialize send, daysAvailable, and hoursAvailable", () => {
expect(component["send"]).toBe(sendView);
expect(component["daysAvailable"]).toBe(0);
expect(component["hoursAvailable"]).toBe(0);
expect(component["daysAvailable"]).toBe(7);
expect(component["hoursAvailable"]).toBe(168);
});

it("should navigate back to the edit send form on close", async () => {
Expand All @@ -140,7 +140,6 @@ describe("SendCreatedComponent", () => {

describe("getHoursAvailable", () => {
it("returns the correct number of hours", () => {
sendView.deletionDate.setDate(sendView.deletionDate.getDate() + 7);
sendViewsSubject.next([sendView]);
fixture.detectChanges();

Expand All @@ -150,31 +149,31 @@ describe("SendCreatedComponent", () => {

describe("formatExpirationDate", () => {
it("returns days plural if expiry is more than 24 hours", () => {
sendView.deletionDate.setDate(sendView.deletionDate.getDate() + 7);
sendView.deletionDate = new Date(Date.now() + 168 * 60 * 60 * 1000);
sendViewsSubject.next([sendView]);
fixture.detectChanges();

expect(component.formatExpirationDate()).toBe("sendExpiresInDays 7");
});

it("returns days singular if expiry is 24 hours", () => {
sendView.deletionDate.setDate(sendView.deletionDate.getDate() + 1);
sendView.deletionDate = new Date(Date.now() + 24 * 60 * 60 * 1000);
sendViewsSubject.next([sendView]);
fixture.detectChanges();

expect(component.formatExpirationDate()).toBe("sendExpiresInDaysSingle");
});

it("returns hours plural if expiry is more than 1 hour but less than 24", () => {
sendView.deletionDate.setHours(sendView.deletionDate.getHours() + 2);
sendView.deletionDate = new Date(Date.now() + 2 * 60 * 60 * 1000);
sendViewsSubject.next([sendView]);
fixture.detectChanges();

expect(component.formatExpirationDate()).toBe("sendExpiresInHours 2");
});

it("returns hours singular if expiry is in 1 hour", () => {
sendView.deletionDate.setHours(sendView.deletionDate.getHours() + 1);
sendView.deletionDate = new Date(Date.now() + 1 * 60 * 60 * 1000);
sendViewsSubject.next([sendView]);
fixture.detectChanges();

Expand Down
9 changes: 8 additions & 1 deletion apps/desktop/desktop_native/core/src/ipc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub fn path(name: &str) -> std::path::PathBuf {
format!(r"\\.\pipe\{hash_b64}.app.{name}").into()
}

#[cfg(target_os = "macos")]
#[cfg(all(target_os = "macos", not(debug_assertions)))]
{
let mut home = dirs::home_dir().unwrap();

Expand All @@ -53,6 +53,13 @@ pub fn path(name: &str) -> std::path::PathBuf {
tmp.join(format!("app.{name}"))
}

#[cfg(all(target_os = "macos", debug_assertions))]
{
// When running in debug mode, we use the tmp dir because the app is not sandboxed
let dir = std::env::temp_dir();
dir.join(format!("app.{name}"))
}

#[cfg(target_os = "linux")]
{
// On Linux, we use the user's cache directory.
Expand Down
3 changes: 2 additions & 1 deletion apps/desktop/src/app/accounts/settings.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,8 @@ export class SettingsComponent implements OnInit, OnDestroy {
async saveBrowserIntegration() {
if (
ipc.platform.deviceType === DeviceType.MacOsDesktop &&
!this.platformUtilsService.isMacAppStore()
!this.platformUtilsService.isMacAppStore() &&
!ipc.platform.isDev
) {
await this.dialogService.openSimpleDialog({
title: { key: "browserIntegrationUnsupportedTitle" },
Expand Down
Loading

0 comments on commit 4e3e8a8

Please sign in to comment.