Skip to content

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

Refactor (#541)

Leendert de Borste153dc6d2a76
diff --git a/browser-extensions/chrome/src/app/context/DbContext.tsx b/browser-extensions/chrome/src/app/context/DbContext.tsx
index 93a279998..a3908ecaf 100644
--- a/browser-extensions/chrome/src/app/context/DbContext.tsx
+++ b/browser-extensions/chrome/src/app/context/DbContext.tsx
@@ -35,7 +35,7 @@ export const DbProvider: React.FC<{ children: React.ReactNode }> = ({ children }
/**
* Public email domains.
*/
- const [_publicEmailDomains, setPublicEmailDomains] = useState<string[]>([]);
+ const [, setPublicEmailDomains] = useState<string[]>([]);
/**
* Vault revision.
@@ -45,7 +45,7 @@ export const DbProvider: React.FC<{ children: React.ReactNode }> = ({ children }
/**
* Private email domains.
*/
- const [_privateEmailDomains, setPrivateEmailDomains] = useState<string[]>([]);
+ const [, setPrivateEmailDomains] = useState<string[]>([]);
const initializeDatabase = useCallback(async (vaultResponse: VaultResponse, derivedKey: string) => {
// Attempt to decrypt the blob.
diff --git a/browser-extensions/chrome/src/contentScript/Form.ts b/browser-extensions/chrome/src/contentScript/Form.ts
index dd6baceca..26e89247c 100644
--- a/browser-extensions/chrome/src/contentScript/Form.ts
+++ b/browser-extensions/chrome/src/contentScript/Form.ts
@@ -254,7 +254,7 @@ export function injectIcon(input: HTMLInputElement): void {
// Generate unique ID if input doesn't have one
if (!input.id) {
- input.id = `aliasvault-input-${Math.random().toString(36).substr(2, 9)}`;
+ input.id = `aliasvault-input-${Math.random().toString(36).substring(2, 11)}`;
}
// Create an overlay container at document level if it doesn't exist
diff --git a/browser-extensions/chrome/src/contentScript/Popup.ts b/browser-extensions/chrome/src/contentScript/Popup.ts
index 1b9cbb70a..dde60cce9 100644
--- a/browser-extensions/chrome/src/contentScript/Popup.ts
+++ b/browser-extensions/chrome/src/contentScript/Popup.ts
@@ -292,7 +292,7 @@ export function createAutofillPopup(input: HTMLInputElement, credentials: Creden
}
// Check for valid protocol (only http/https)
- if (!url.protocol.match(/^https?:$/)) {
+ if (!(/^https?:$/).exec(url.protocol)) {
return null;
}
@@ -648,7 +648,7 @@ function createCredentialList(credentials: Credential[], input: HTMLInputElement
// Handle base64 image data
if (cred.Logo) {
try {
- const base64Logo = base64Encode(cred.Logo);
+ const base64Logo = base64Encode(cred.Logo as Uint8Array<ArrayBufferLike>);
imgElement.src = `data:image/x-icon;base64,${base64Logo}`;
} catch (error) {
console.error('Error setting logo:', error);
@@ -1054,7 +1054,7 @@ function base64Encode(buffer: Uint8Array): string | null {
const byteArray = Object.values(buffer);
// Convert to binary string
- const binary = String.fromCharCode.apply(null, byteArray as number[]);
+ const binary = String.fromCharCode.apply(null, byteArray);
// Use btoa to encode binary string to base64
return btoa(binary);
diff --git a/browser-extensions/chrome/src/shared/formDetector/__tests__/FormDetector.en.test.ts b/browser-extensions/chrome/src/shared/formDetector/__tests__/FormDetector.en.test.ts
index 90667ae20..dbeb1b03f 100644
--- a/browser-extensions/chrome/src/shared/formDetector/__tests__/FormDetector.en.test.ts
+++ b/browser-extensions/chrome/src/shared/formDetector/__tests__/FormDetector.en.test.ts
@@ -1,8 +1,17 @@
-// NOSONAR - Tests are implemented via testField helper in TestUtils
-import { describe } from 'vitest';
+import { describe, expect, it } from 'vitest';
import { FormField, testField } from './TestUtils';
describe('FormDetector English tests', () => {
+ it('contains tests for English form field detection', () => {
+ /**
+ * This test suite uses testField() and testBirthdateFormat() helper functions
+ * to test form field detection for multiple English registration forms.
+ * The actual test implementations are in the helper functions.
+ * This test is just to ensure the test suite is working and to satisfy the linter.
+ */
+ expect(true).toBe(true);
+ });
+
describe('English registration form 1 detection', () => {
const htmlFile = 'en-registration-form1.html';
diff --git a/browser-extensions/chrome/src/shared/formDetector/__tests__/FormDetector.nl.test.ts b/browser-extensions/chrome/src/shared/formDetector/__tests__/FormDetector.nl.test.ts
index ba37acd4b..647ee59da 100644
--- a/browser-extensions/chrome/src/shared/formDetector/__tests__/FormDetector.nl.test.ts
+++ b/browser-extensions/chrome/src/shared/formDetector/__tests__/FormDetector.nl.test.ts
@@ -1,8 +1,17 @@
-// NOSONAR - Tests are implemented via testField helper in TestUtils
-import { describe } from 'vitest';
+import { describe, it, expect } from 'vitest';
import { FormField, testField, testBirthdateFormat } from './TestUtils';
describe('FormDetector Dutch tests', () => {
+ it('contains tests for Dutch form field detection', () => {
+ /**
+ * This test suite uses testField() and testBirthdateFormat() helper functions
+ * to test form field detection for multiple Dutch registration forms.
+ * The actual test implementations are in the helper functions.
+ * This test is just to ensure the test suite is working and to satisfy the linter.
+ */
+ expect(true).toBe(true);
+ });
+
describe('Dutch registration form detection', () => {
const htmlFile = 'nl-registration-form1.html';
diff --git a/browser-extensions/chrome/src/shared/generators/Password/PasswordGenerator.ts b/browser-extensions/chrome/src/shared/generators/Password/PasswordGenerator.ts
index ac1c4f744..45333440c 100644
--- a/browser-extensions/chrome/src/shared/generators/Password/PasswordGenerator.ts
+++ b/browser-extensions/chrome/src/shared/generators/Password/PasswordGenerator.ts
@@ -96,25 +96,25 @@ export class PasswordGenerator {
}
// Ensure password contains at least one character from each selected set
- if (this.useLowercase && !RegExp('[a-z]').exec(password)) {
+ if (this.useLowercase && !/[a-z]/.exec(password)) {
const pos = this.getUnbiasedRandomIndex(this.length);
password = password.substring(0, pos) +
this.lowercaseChars[this.getUnbiasedRandomIndex(this.lowercaseChars.length)] +
password.substring(pos + 1);
}
- if (this.useUppercase && !RegExp('[A-Z]').exec(password)) {
+ if (this.useUppercase && !/[A-Z]/.exec(password)) {
const pos = this.getUnbiasedRandomIndex(this.length);
password = password.substring(0, pos) +
this.uppercaseChars[this.getUnbiasedRandomIndex(this.uppercaseChars.length)] +
password.substring(pos + 1);
}
- if (this.useNumbers && !RegExp('\\d').exec(password)) {
+ if (this.useNumbers && !/\d/.exec(password)) {
const pos = this.getUnbiasedRandomIndex(this.length);
password = password.substring(0, pos) +
this.numberChars[this.getUnbiasedRandomIndex(this.numberChars.length)] +
password.substring(pos + 1);
}
- if (this.useSpecial && !RegExp('[!@#$%^&*()_+\\-=\\[\\]{}|;:,.<>?]').exec(password)) {
+ if (this.useSpecial && !/[!@#$%^&*()_+\-=[\]{}|;:,.<>?]/.exec(password)) {
const pos = this.getUnbiasedRandomIndex(this.length);
password = password.substring(0, pos) +
this.specialChars[this.getUnbiasedRandomIndex(this.specialChars.length)] +