Skip to content

Commit

Permalink
Merge branch 'main' into auth/pm-8221/route-user-to-email-otp-entry-c…
Browse files Browse the repository at this point in the history
…lients
  • Loading branch information
alec-livefront authored Jan 14, 2025
2 parents 100103d + 6f018e1 commit 052d9d8
Show file tree
Hide file tree
Showing 205 changed files with 793 additions and 392 deletions.
1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"@typescript-eslint/no-floating-promises": "error",
"@typescript-eslint/no-misused-promises": ["error", { "checksVoidReturn": false }],
"@typescript-eslint/no-this-alias": ["error", { "allowedNames": ["self"] }],
"@typescript-eslint/no-unused-expressions": ["error", { "allowTernary": true }],
"@typescript-eslint/no-unused-vars": ["error", { "args": "none" }],
"no-console": "error",
"import/no-unresolved": "off", // TODO: Look into turning off once each package is an actual package.
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,9 @@ jobs:
ref: ${{ github.event.pull_request.head.sha }}

- name: Scan with SonarCloud
uses: sonarsource/sonarcloud-github-action@02ef91109b2d589e757aefcfb2854c2783fd7b19 # v4.0.0
uses: sonarsource/sonarqube-scan-action@bfd4e558cda28cda6b5defafb9232d191be8c203 # v4.2.1
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
args: >
-Dsonar.organization=${{ github.repository_owner }}
Expand Down
2 changes: 1 addition & 1 deletion apps/browser/postcss.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable no-undef */
/* eslint-disable no-undef, @typescript-eslint/no-require-imports */
module.exports = {
plugins: [require("tailwindcss"), require("autoprefixer"), require("postcss-nested")],
};
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,18 @@ export class AccountSecurityComponent implements OnInit, OnDestroy {

const biometricsPromise = async () => {
try {
const result = await this.biometricsService.authenticateWithBiometrics();
const userId = await firstValueFrom(
this.accountService.activeAccount$.pipe(map((a) => a.id)),
);
let result = false;
try {
const userKey = await this.biometricsService.unlockWithBiometricsForUser(userId);
result = await this.keyService.validateUserKey(userKey, userId);
// FIXME: Remove when updating file. Eslint update
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (e) {
result = false;
}

// prevent duplicate dialog
biometricsResponseReceived = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -453,12 +453,16 @@ describe("AutoSubmitLoginBackground", () => {

sendMockExtensionMessage({ command: "triggerAutoSubmitLogin" }, sender);

// FIXME: Remove when updating file. Eslint update
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
expect(autofillService.doAutoFillOnTab).not.toHaveBeenCalled;
});

it("skips acting on messages whose command does not have a registered handler", () => {
sendMockExtensionMessage({ command: "someInvalidCommand" }, sender);

// FIXME: Remove when updating file. Eslint update
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
expect(autofillService.doAutoFillOnTab).not.toHaveBeenCalled;
});

Expand Down
2 changes: 2 additions & 0 deletions apps/browser/src/autofill/content/auto-submit-login.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ describe("AutoSubmitLogin content script", () => {
beforeEach(() => {
jest.useFakeTimers();
setupEnvironmentDefaults();
// FIXME: Remove when updating file. Eslint update
// eslint-disable-next-line @typescript-eslint/no-require-imports
require("./auto-submit-login");
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ export function EditButton({
title=${buttonText}
class=${editButtonStyles({ disabled, theme })}
@click=${(event: Event) => {
// FIXME: Remove when updating file. Eslint update
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
!disabled && buttonAction(event);
}}
>
Expand Down
4 changes: 4 additions & 0 deletions apps/browser/src/autofill/content/components/cipher/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// FIXME: Remove when updating file. Eslint update
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const CipherTypes = {
Login: 1,
SecureNote: 2,
Expand All @@ -7,6 +9,8 @@ const CipherTypes = {

type CipherType = (typeof CipherTypes)[keyof typeof CipherTypes];

// FIXME: Remove when updating file. Eslint update
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const CipherRepromptTypes = {
None: 0,
Password: 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ describe("ContentMessageHandler", () => {
);

beforeEach(() => {
// FIXME: Remove when updating file. Eslint update
// eslint-disable-next-line @typescript-eslint/no-require-imports
require("./content-message-handler");
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ describe("TriggerAutofillScriptInjection", () => {

describe("init", () => {
it("sends a message to the extension background", () => {
// FIXME: Remove when updating file. Eslint update
// eslint-disable-next-line @typescript-eslint/no-require-imports
require("../content/trigger-autofill-script-injection");

expect(chrome.runtime.sendMessage).toHaveBeenCalledWith({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { AutofillOverlayElement } from "../../../../enums/autofill-overlay.enum"

import AutofillOverlayButton from "./autofill-overlay-button.deprecated";

// FIXME: Remove when updating file. Eslint update
// eslint-disable-next-line @typescript-eslint/no-require-imports
require("./legacy-button.scss");

(function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { AutofillOverlayElement } from "../../../../enums/autofill-overlay.enum"

import AutofillOverlayList from "./autofill-overlay-list.deprecated";

// FIXME: Remove when updating file. Eslint update
// eslint-disable-next-line @typescript-eslint/no-require-imports
require("./legacy-list.scss");

(function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ describe("Fido2 Content Script", () => {
chrome.runtime.connect = jest.fn(() => portSpy);

it("destroys the messenger when the port is disconnected", () => {
// FIXME: Remove when updating file. Eslint update
// eslint-disable-next-line @typescript-eslint/no-require-imports
require("./fido2-content-script");

triggerPortOnDisconnectEvent(portSpy);
Expand All @@ -75,6 +77,8 @@ describe("Fido2 Content Script", () => {
const mockResult = { credentialId: "mock" } as CreateCredentialResult;
jest.spyOn(chrome.runtime, "sendMessage").mockResolvedValue(mockResult);

// FIXME: Remove when updating file. Eslint update
// eslint-disable-next-line @typescript-eslint/no-require-imports
require("./fido2-content-script");

const response = await messenger.handler!(message, new AbortController());
Expand All @@ -99,6 +103,8 @@ describe("Fido2 Content Script", () => {
data: mock<InsecureCreateCredentialParams>(),
});

// FIXME: Remove when updating file. Eslint update
// eslint-disable-next-line @typescript-eslint/no-require-imports
require("./fido2-content-script");

await messenger.handler!(message, new AbortController());
Expand All @@ -121,6 +127,8 @@ describe("Fido2 Content Script", () => {
const abortController = new AbortController();
const abortSpy = jest.spyOn(abortController.signal, "removeEventListener");

// FIXME: Remove when updating file. Eslint update
// eslint-disable-next-line @typescript-eslint/no-require-imports
require("./fido2-content-script");

await messenger.handler!(message, abortController);
Expand All @@ -141,6 +149,8 @@ describe("Fido2 Content Script", () => {
abortController.abort();
});

// FIXME: Remove when updating file. Eslint update
// eslint-disable-next-line @typescript-eslint/no-require-imports
require("./fido2-content-script");

await messenger.handler!(message, abortController);
Expand All @@ -161,6 +171,8 @@ describe("Fido2 Content Script", () => {
const abortController = new AbortController();
jest.spyOn(chrome.runtime, "sendMessage").mockResolvedValue({ error: errorMessage });

// FIXME: Remove when updating file. Eslint update
// eslint-disable-next-line @typescript-eslint/no-require-imports
require("./fido2-content-script");
const result = messenger.handler!(message, abortController);

Expand All @@ -175,6 +187,8 @@ describe("Fido2 Content Script", () => {
contentType: "application/json",
}));

// FIXME: Remove when updating file. Eslint update
// eslint-disable-next-line @typescript-eslint/no-require-imports
require("./fido2-content-script");

expect(messengerForDOMCommunicationSpy).not.toHaveBeenCalled();
Expand All @@ -193,6 +207,8 @@ describe("Fido2 Content Script", () => {
},
}));

// FIXME: Remove when updating file. Eslint update
// eslint-disable-next-line @typescript-eslint/no-require-imports
require("./fido2-content-script");

expect(messengerForDOMCommunicationSpy).not.toHaveBeenCalled();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ describe("FIDO2 page-script for manifest v2", () => {
it("skips appending the `page-script.js` file if the document contentType is not `text/html`", () => {
Object.defineProperty(window.document, "contentType", { value: "text/plain", writable: true });

// FIXME: Remove when updating file. Eslint update
// eslint-disable-next-line @typescript-eslint/no-require-imports
require("./fido2-page-script-append.mv2");

expect(window.document.createElement).not.toHaveBeenCalled();
Expand All @@ -33,6 +35,8 @@ describe("FIDO2 page-script for manifest v2", () => {
return node;
});

// FIXME: Remove when updating file. Eslint update
// eslint-disable-next-line @typescript-eslint/no-require-imports
require("./fido2-page-script-append.mv2");

expect(window.document.createElement).toHaveBeenCalledWith("script");
Expand All @@ -48,6 +52,8 @@ describe("FIDO2 page-script for manifest v2", () => {
return node;
});

// FIXME: Remove when updating file. Eslint update
// eslint-disable-next-line @typescript-eslint/no-require-imports
require("./fido2-page-script-append.mv2");

expect(window.document.createElement).toHaveBeenCalledWith("script");
Expand Down
2 changes: 2 additions & 0 deletions apps/browser/src/autofill/fido2/content/fido2-page-script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,8 @@ import { Messenger } from "./messaging/messenger";

clearWaitForFocus();
void messenger.destroy();
// FIXME: Remove when updating file. Eslint update
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (e) {
/** empty */
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ describe("Fido2 page script with native WebAuthn support", () => {
setupMockedWebAuthnSupport();

beforeAll(() => {
// FIXME: Remove when updating file. Eslint update
// eslint-disable-next-line @typescript-eslint/no-require-imports
require("./fido2-page-script");
});

Expand Down Expand Up @@ -166,6 +168,8 @@ describe("Fido2 page script with native WebAuthn support", () => {
contentType: "json/application",
}));

// FIXME: Remove when updating file. Eslint update
// eslint-disable-next-line @typescript-eslint/no-require-imports
require("./fido2-content-script");

expect(Messenger.forDOMCommunication).not.toHaveBeenCalled();
Expand All @@ -184,6 +188,8 @@ describe("Fido2 page script with native WebAuthn support", () => {
},
}));

// FIXME: Remove when updating file. Eslint update
// eslint-disable-next-line @typescript-eslint/no-require-imports
require("./fido2-content-script");

expect(Messenger.forDOMCommunication).not.toHaveBeenCalled();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ describe("Fido2 page script without native WebAuthn support", () => {
const mockCreateCredentialsResult = createCreateCredentialResultMock();
const mockCredentialRequestOptions = createCredentialRequestOptionsMock();
const mockCredentialAssertResult = createAssertCredentialResultMock();
// FIXME: Remove when updating file. Eslint update
// eslint-disable-next-line @typescript-eslint/no-require-imports
require("./fido2-page-script");

afterEach(() => {
Expand Down
2 changes: 2 additions & 0 deletions apps/browser/src/autofill/notification/bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import {
NotificationBarIframeInitData,
} from "./abstractions/notification-bar";

// FIXME: Remove when updating file. Eslint update
// eslint-disable-next-line @typescript-eslint/no-require-imports
require("./bar.scss");

const logService = new ConsoleLogService(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { AutofillOverlayElement } from "../../../../enums/autofill-overlay.enum"

import { AutofillInlineMenuButton } from "./autofill-inline-menu-button";

// FIXME: Remove when updating file. Eslint update
// eslint-disable-next-line @typescript-eslint/no-require-imports
require("./button.scss");

(function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { AutofillOverlayElement } from "../../../../enums/autofill-overlay.enum"

import { AutofillInlineMenuList } from "./autofill-inline-menu-list";

// FIXME: Remove when updating file. Eslint update
// eslint-disable-next-line @typescript-eslint/no-require-imports
require("./list.scss");

(function () {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// FIXME: Remove when updating file. Eslint update
// eslint-disable-next-line @typescript-eslint/no-require-imports
require("./menu-container.scss");

import { AutofillInlineMenuContainer } from "./autofill-inline-menu-container";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1417,6 +1417,8 @@ export class AutofillOverlayContentService implements AutofillOverlayContentServ
url.origin + pathWithoutTrailingSlashAndSearch,
url.origin + pathWithoutTrailingSlashSearchAndHash,
]);
// FIXME: Remove when updating file. Eslint update
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (_error) {
return null;
}
Expand Down
2 changes: 2 additions & 0 deletions apps/browser/src/autofill/services/dom-query.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ export class DomQueryService implements DomQueryServiceInterface {
if ((chrome as any).dom?.openOrClosedShadowRoot) {
try {
return (chrome as any).dom.openOrClosedShadowRoot(node);
// FIXME: Remove when updating file. Eslint update
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (error) {
return null;
}
Expand Down
12 changes: 7 additions & 5 deletions apps/browser/src/background/main.background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -632,11 +632,6 @@ export default class MainBackground {

this.i18nService = new I18nService(BrowserApi.getUILanguage(), this.globalStateProvider);

this.biometricsService = new BackgroundBrowserBiometricsService(
runtimeNativeMessagingBackground,
this.logService,
);

this.kdfConfigService = new DefaultKdfConfigService(this.stateProvider);

this.pinService = new PinService(
Expand Down Expand Up @@ -665,6 +660,13 @@ export default class MainBackground {
this.kdfConfigService,
);

this.biometricsService = new BackgroundBrowserBiometricsService(
runtimeNativeMessagingBackground,
this.logService,
this.keyService,
this.biometricStateService,
);

this.appIdService = new AppIdService(this.storageService, this.logService);

this.userDecryptionOptionsService = new UserDecryptionOptionsService(this.stateProvider);
Expand Down
2 changes: 2 additions & 0 deletions apps/browser/src/background/nativeMessaging.background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,8 @@ export class NativeMessagingBackground {
};
}
this.port.postMessage(msg);
// FIXME: Remove when updating file. Eslint update
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (e) {
this.logService.info(
"[Native Messaging IPC] Disconnected from Bitwarden Desktop app because of the native port disconnecting.",
Expand Down
Loading

0 comments on commit 052d9d8

Please sign in to comment.