Skip to content

Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.

Fix all linting issues (#581)

Leendert de Borstfd5244a68619
diff --git a/browser-extension/src/entrypoints/background.ts b/browser-extension/src/entrypoints/background.ts
index 5ca9f4c2c..1fb31986f 100644
--- a/browser-extension/src/entrypoints/background.ts
+++ b/browser-extension/src/entrypoints/background.ts
@@ -1,4 +1,5 @@
import { browser } from "wxt/browser";
+import { defineBackground } from 'wxt/sandbox';
import { onMessage } from "webext-bridge/background";
import { setupContextMenus, handleContextMenuClick } from './background/ContextMenu';
import { handleClearVault, handleCreateIdentity, handleGetCredentials, handleGetDefaultEmailDomain, handleGetDerivedKey, handleGetVault, handleStoreVault, handleSyncVault } from './background/VaultMessageHandler';
@@ -6,12 +7,14 @@ import { handleOpenPopup, handlePopupWithCredential } from './background/PopupMe
export default defineBackground({
/**
- *
+ * This is the main entry point for the background script.
*/
main() {
// Set up context menus
setupContextMenus();
- browser.contextMenus.onClicked.addListener(handleContextMenuClick as any);
+ browser.contextMenus.onClicked.addListener((info: browser.menus.OnClickData, tab?: browser.tabs.Tab) =>
+ handleContextMenuClick(info, tab)
+ );
// Listen for messages using webext-bridge
onMessage('STORE_VAULT', ({ data }) => handleStoreVault(data));
diff --git a/browser-extension/src/entrypoints/background/PopupMessageHandler.ts b/browser-extension/src/entrypoints/background/PopupMessageHandler.ts
index 5802f6546..4e8940a8f 100644
--- a/browser-extension/src/entrypoints/background/PopupMessageHandler.ts
+++ b/browser-extension/src/entrypoints/background/PopupMessageHandler.ts
@@ -5,7 +5,7 @@ import { BoolResponse } from '../../utils/types/messaging/BoolResponse';
* Handle opening the popup.
*/
export function handleOpenPopup() : Promise<BoolResponse> {
- return (async () => {
+ return (async () : Promise<BoolResponse> => {
browser.windows.create({
url: browser.runtime.getURL('/popup.html?mode=inline_unlock'),
type: 'popup',
@@ -21,7 +21,7 @@ export function handleOpenPopup() : Promise<BoolResponse> {
* Handle opening the popup with a credential.
*/
export function handlePopupWithCredential(message: any) : Promise<BoolResponse> {
- return (async () => {
+ return (async () : Promise<BoolResponse> => {
browser.windows.create({
url: browser.runtime.getURL(`/popup.html#/credentials/${message.credentialId}`),
type: 'popup',
diff --git a/browser-extension/src/entrypoints/background/VaultMessageHandler.ts b/browser-extension/src/entrypoints/background/VaultMessageHandler.ts
index 6c60793e7..00d4ecc20 100644
--- a/browser-extension/src/entrypoints/background/VaultMessageHandler.ts
+++ b/browser-extension/src/entrypoints/background/VaultMessageHandler.ts
@@ -194,7 +194,7 @@ export async function getEmailAddressesForVault(
*/
export function handleGetDefaultEmailDomain(
) : Promise<messageDefaultEmailDomainResponse> {
- return (async () => {
+ return (async () : Promise<messageDefaultEmailDomainResponse> => {
try {
const privateEmailDomains = await storage.getItem('session:privateEmailDomains') as string[];
const publicEmailDomains = await storage.getItem('session:publicEmailDomains') as string[];
diff --git a/browser-extension/src/entrypoints/content.ts b/browser-extension/src/entrypoints/content.ts
index c4597df1b..bb17c5917 100644
--- a/browser-extension/src/entrypoints/content.ts
+++ b/browser-extension/src/entrypoints/content.ts
@@ -2,11 +2,13 @@ import { FormDetector } from '../utils/formDetector/FormDetector';
import { isAutoShowPopupDisabled, openAutofillPopup, removeExistingPopup } from './contentScript/Popup';
import { canShowPopup, injectIcon } from './contentScript/Form';
import { onMessage } from "webext-bridge/content-script";
+import { BoolResponse as messageBoolResponse } from '../utils/types/messaging/BoolResponse';
+import { defineContentScript } from 'wxt/sandbox';
export default defineContentScript({
matches: ['<all_urls>'],
/**
- *
+ * Main entry point for the content script.
*/
main(ctx) {
if (ctx.isInvalid) {
@@ -53,16 +55,15 @@ export default defineContentScript({
});
// Listen for messages from the background script
- onMessage('OPEN_AUTOFILL_POPUP', async (message: any) => {
- const { data, sender } = message;
+ onMessage('OPEN_AUTOFILL_POPUP', async (message: { data: { elementIdentifier: string } }) : Promise<messageBoolResponse> => {
+ const { data } = message;
const { elementIdentifier } = data;
if (!elementIdentifier) {
return { success: false, error: 'No element identifier provided' };
}
- const target = document.getElementById(elementIdentifier) ||
- document.getElementsByName(elementIdentifier)[0];
+ const target = document.getElementById(elementIdentifier) ?? document.getElementsByName(elementIdentifier)[0];
if (!(target instanceof HTMLInputElement)) {
return { success: false, error: 'Target element is not an input field' };
diff --git a/browser-extension/src/entrypoints/contentScript/Popup.ts b/browser-extension/src/entrypoints/contentScript/Popup.ts
index 1c8c3ed35..2424bd9f9 100644
--- a/browser-extension/src/entrypoints/contentScript/Popup.ts
+++ b/browser-extension/src/entrypoints/contentScript/Popup.ts
@@ -1055,10 +1055,9 @@ export function openAutofillPopup(input: HTMLInputElement) : void {
document.addEventListener('keydown', handleEnterKey);
- (async () => {
+ (async () : Promise<void> => {
const response = await sendMessage('GET_CREDENTIALS', { }, 'background') as CredentialsResponse;
- console.log('response', response);
if (response.success) {
createAutofillPopup(input, response.credentials);
} else {
diff --git a/browser-extension/src/entrypoints/popup/pages/AuthSettings.tsx b/browser-extension/src/entrypoints/popup/pages/AuthSettings.tsx
index 5168af549..a95ef2031 100644
--- a/browser-extension/src/entrypoints/popup/pages/AuthSettings.tsx
+++ b/browser-extension/src/entrypoints/popup/pages/AuthSettings.tsx
@@ -1,5 +1,6 @@
import React, { useState, useEffect } from 'react';
import { AppInfo } from '../../../utils/AppInfo';
+import { storage } from 'wxt/storage';
type ApiOption = {
label: string;
@@ -21,9 +22,9 @@ const AuthSettings: React.FC = () => {
useEffect(() => {
/**
- *
+ * Load the stored settings from the storage.
*/
- const loadStoredSettings = async () => {
+ const loadStoredSettings = async () : Promise<void> => {
const apiUrl = await storage.getItem('local:apiUrl') as string;
const clientUrl = await storage.getItem('local:clientUrl') as string;
const matchingOption = DEFAULT_OPTIONS.find(opt => opt.value === apiUrl);
diff --git a/browser-extension/src/entrypoints/popup/pages/Login.tsx b/browser-extension/src/entrypoints/popup/pages/Login.tsx
index 5cf58f536..408105aa6 100644
--- a/browser-extension/src/entrypoints/popup/pages/Login.tsx
+++ b/browser-extension/src/entrypoints/popup/pages/Login.tsx
@@ -11,7 +11,7 @@ import { VaultResponse } from '../../../utils/types/webapi/VaultResponse';
import { LoginResponse } from '../../../utils/types/webapi/Login';
import LoginServerInfo from '../components/LoginServerInfo';
import { AppInfo } from '../../../utils/AppInfo';
-
+import { storage } from 'wxt/storage';
/**
* Login page
*/
diff --git a/browser-extension/src/utils/WebApiService.ts b/browser-extension/src/utils/WebApiService.ts
index 00347b910..d05077040 100644
--- a/browser-extension/src/utils/WebApiService.ts
+++ b/browser-extension/src/utils/WebApiService.ts
@@ -1,6 +1,7 @@
import { AppInfo } from "./AppInfo";
import { StatusResponse } from "./types/webapi/StatusResponse";
import { VaultResponse } from "./types/webapi/VaultResponse";
+import { storage } from 'wxt/storage';
type RequestInit = globalThis.RequestInit;