Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Refactor code and enforce 2 space indents (#541)
Leendert de Borst908efadceca6
diff --git a/browser-extensions/.editorconfig b/browser-extensions/.editorconfignew file mode 100644index 000000000..429f1a67a--- /dev/null+++ b/browser-extensions/.editorconfig@@ -0,0 +1,28 @@+# Child EditorConfig file that enforces 2 space indent for Typescript projects+root = false++# Unix-style newlines with a newline ending every file+[*]+end_of_line = lf+insert_final_newline = true+charset = utf-8+trim_trailing_whitespace = true++# TypeScript and JavaScript files+[*.{ts,tsx,js,jsx}]+indent_style = space+indent_size = 2++# JSON files+[*.json]+indent_style = space+indent_size = 2++# YAML files+[*.{yml,yaml}]+indent_style = space+indent_size = 2++# Markdown files+[*.md]+trim_trailing_whitespace = false\ No newline at end of filediff --git a/browser-extensions/chrome/eslint.config.js b/browser-extensions/chrome/eslint.config.jsindex 4ed5be7f4..a8dc3b7e5 100644--- a/browser-extensions/chrome/eslint.config.js+++ b/browser-extensions/chrome/eslint.config.js@@ -38,6 +38,20 @@ export default [...reactHooksPlugin.configs.recommended.rules,"react/react-in-jsx-scope": "off","@typescript-eslint/explicit-module-boundary-types": "off",+ "indent": ["error", 2, {+ "SwitchCase": 1,+ "VariableDeclarator": 1,+ "outerIIFEBody": 1,+ "MemberExpression": 1,+ "FunctionDeclaration": { "parameters": 1, "body": 1 },+ "FunctionExpression": { "parameters": 1, "body": 1 },+ "CallExpression": { "arguments": 1 },+ "ArrayExpression": 1,+ "ObjectExpression": 1,+ "ImportDeclaration": 1,+ "flatTernaryExpressions": false,+ "ignoreComments": false+ }],"no-multiple-empty-lines": ["error", { "max": 1, "maxEOF": 1, "maxBOF": 0 }],"no-console": ["error", { allow: ["warn", "error", "info", "debug"] }],"jsdoc/require-jsdoc": ["error", {diff --git a/browser-extensions/chrome/package.json b/browser-extensions/chrome/package.jsonindex e3f3db80c..d265d22b3 100644--- a/browser-extensions/chrome/package.json+++ b/browser-extensions/chrome/package.json@@ -8,6 +8,7 @@"dev": "vite","preview": "vite preview","lint": "eslint src",+ "lint:custom": "eslint","lint:fix": "eslint src --fix","build": "vite build && npm run build:content-css","watch": "vite build --watch",diff --git a/browser-extensions/chrome/src/contentscript/Filter.ts b/browser-extensions/chrome/src/contentscript/Filter.tsindex f25434e69..eec0e4475 100644--- a/browser-extensions/chrome/src/contentscript/Filter.ts+++ b/browser-extensions/chrome/src/contentscript/Filter.ts@@ -5,49 +5,49 @@ import { Credential } from "../types/Credential";* in the autofill popup.*/export function filterCredentials(credentials: Credential[], currentUrl: string, pageTitle: string): Credential[] {- const urlObject = new URL(currentUrl);- const baseUrl = `${urlObject.protocol}//${urlObject.hostname}`;+ const urlObject = new URL(currentUrl);+ const baseUrl = `${urlObject.protocol}//${urlObject.hostname}`;++ // 1. Exact URL match+ let filtered = credentials.filter(cred =>+ cred.ServiceUrl?.toLowerCase() === currentUrl.toLowerCase()+ );++ // 2. Base URL match with fuzzy domain comparison if no exact matches+ if (filtered.length === 0) {+ filtered = credentials.filter(cred => {+ if (!cred.ServiceUrl) return false;+ try {+ const credUrlObject = new URL(cred.ServiceUrl);+ const currentUrlObject = new URL(baseUrl);++ // Extract root domains by splitting on dots and taking last two parts+ const credDomainParts = credUrlObject.hostname.toLowerCase().split('.');+ const currentDomainParts = currentUrlObject.hostname.toLowerCase().split('.');++ // Get root domain (last two parts, e.g., 'dumpert.nl')+ const credRootDomain = credDomainParts.slice(-2).join('.');+ const currentRootDomain = currentDomainParts.slice(-2).join('.');++ // Compare protocols and root domains+ return credUrlObject.protocol === currentUrlObject.protocol &&+ credRootDomain === currentRootDomain;+ } catch {+ return false;+ }+ });+ }- // 1. Exact URL match- let filtered = credentials.filter(cred =>- cred.ServiceUrl?.toLowerCase() === currentUrl.toLowerCase()+ // 3. Page title word match if still no matches+ if (filtered.length === 0 && pageTitle.length > 0) {+ const titleWords = pageTitle.toLowerCase().split(/\s+/);+ filtered = credentials.filter(cred =>+ titleWords.some(word =>+ cred.ServiceName.toLowerCase().includes(word)+ ));-- // 2. Base URL match with fuzzy domain comparison if no exact matches- if (filtered.length === 0) {- filtered = credentials.filter(cred => {- if (!cred.ServiceUrl) return false;- try {- const credUrlObject = new URL(cred.ServiceUrl);- const currentUrlObject = new URL(baseUrl);-- // Extract root domains by splitting on dots and taking last two parts- const credDomainParts = credUrlObject.hostname.toLowerCase().split('.');- const currentDomainParts = currentUrlObject.hostname.toLowerCase().split('.');-- // Get root domain (last two parts, e.g., 'dumpert.nl')- const credRootDomain = credDomainParts.slice(-2).join('.');- const currentRootDomain = currentDomainParts.slice(-2).join('.');-- // Compare protocols and root domains- return credUrlObject.protocol === currentUrlObject.protocol &&- credRootDomain === currentRootDomain;- } catch {- return false;- }- });- }-- // 3. Page title word match if still no matches- if (filtered.length === 0 && pageTitle.length > 0) {- const titleWords = pageTitle.toLowerCase().split(/\s+/);- filtered = credentials.filter(cred =>- titleWords.some(word =>- cred.ServiceName.toLowerCase().includes(word)- )- );- }-- // Show max 3 results- return filtered.slice(0, 3);}++ // Show max 3 results+ return filtered.slice(0, 3);+}diff --git a/browser-extensions/chrome/src/contentscript/Form.ts b/browser-extensions/chrome/src/contentscript/Form.tsindex 6333426d9..1666d55dd 100644--- a/browser-extensions/chrome/src/contentscript/Form.ts+++ b/browser-extensions/chrome/src/contentscript/Form.ts@@ -1,136 +1,138 @@import { FormDetector } from "../utils/form-detector/FormDetector";import { Credential } from "../types/Credential";+import { openAutofillPopup } from "./Popup";/*** Fill credential into current form.*/export function fillCredential(credential: Credential) : void {- const formDetector = new FormDetector(document);- const forms = formDetector.detectForms();+ const formDetector = new FormDetector(document);+ const forms = formDetector.detectForms();- if (!forms.length) return;+ if (!forms.length) return;- const form = forms[0];- if (form.usernameField) {- form.usernameField.value = credential.Username;- triggerInputEvents(form.usernameField);- }- if (form.passwordField) {- form.passwordField.value = credential.Password;- triggerInputEvents(form.passwordField);- }- if (form.passwordConfirmField) {- form.passwordConfirmField.value = credential.Password;- triggerInputEvents(form.passwordConfirmField);- }- if (form.emailField) {- form.emailField.value = credential.Email;- triggerInputEvents(form.emailField);- }- if (form.emailConfirmField) {- form.emailConfirmField.value = credential.Email;- triggerInputEvents(form.emailConfirmField);- }- if (form.firstNameField) {- form.firstNameField.value = credential.Alias.FirstName;- triggerInputEvents(form.firstNameField);+ const form = forms[0];+ if (form.usernameField) {+ form.usernameField.value = credential.Username;+ triggerInputEvents(form.usernameField);+ }+ if (form.passwordField) {+ form.passwordField.value = credential.Password;+ triggerInputEvents(form.passwordField);+ }+ if (form.passwordConfirmField) {+ form.passwordConfirmField.value = credential.Password;+ triggerInputEvents(form.passwordConfirmField);+ }+ if (form.emailField) {+ form.emailField.value = credential.Email;+ triggerInputEvents(form.emailField);+ }+ if (form.emailConfirmField) {+ form.emailConfirmField.value = credential.Email;+ triggerInputEvents(form.emailConfirmField);+ }+ if (form.firstNameField) {+ form.firstNameField.value = credential.Alias.FirstName;+ triggerInputEvents(form.firstNameField);+ }+ if (form.lastNameField) {+ form.lastNameField.value = credential.Alias.LastName;+ triggerInputEvents(form.lastNameField);+ }++ // Handle birthdate with input events+ if (form.birthdateField.single) {+ if (credential.Alias.BirthDate) {+ const birthDate = new Date(credential.Alias.BirthDate);+ const day = birthDate.getDate().toString().padStart(2, '0');+ const month = (birthDate.getMonth() + 1).toString().padStart(2, '0');+ const year = birthDate.getFullYear().toString();++ let formattedDate = '';+ switch (form.birthdateField.format) {+ case 'dd-mm-yyyy':+ formattedDate = `${day}-${month}-${year}`;+ break;+ case 'mm-dd-yyyy':+ formattedDate = `${month}-${day}-${year}`;+ break;+ case 'yyyy-mm-dd':+ default:+ formattedDate = `${year}-${month}-${day}`;+ break;+ }++ form.birthdateField.single.value = formattedDate;+ triggerInputEvents(form.birthdateField.single);}- if (form.lastNameField) {- form.lastNameField.value = credential.Alias.LastName;- triggerInputEvents(form.lastNameField);+ } else {+ if (credential.Alias.BirthDate) {+ const birthDate = new Date(credential.Alias.BirthDate);+ if (form.birthdateField.day) {+ form.birthdateField.day.value = birthDate.getDate().toString().padStart(2, '0');+ triggerInputEvents(form.birthdateField.day);+ }+ if (form.birthdateField.month) {+ form.birthdateField.month.value = (birthDate.getMonth() + 1).toString().padStart(2, '0');+ triggerInputEvents(form.birthdateField.month);+ }+ if (form.birthdateField.year) {+ form.birthdateField.year.value = birthDate.getFullYear().toString();+ triggerInputEvents(form.birthdateField.year);+ }}+ }- // Handle birthdate with input events- if (form.birthdateField.single) {- if (credential.Alias.BirthDate) {- const birthDate = new Date(credential.Alias.BirthDate);- const day = birthDate.getDate().toString().padStart(2, '0');- const month = (birthDate.getMonth() + 1).toString().padStart(2, '0');- const year = birthDate.getFullYear().toString();-- let formattedDate = '';- switch (form.birthdateField.format) {- case 'dd-mm-yyyy':- formattedDate = `${day}-${month}-${year}`;+ // Handle gender with input events+ switch (form.genderField.type) {+ case 'select':+ if (form.genderField.field) {+ switch (credential.Alias.Gender) {+ case 'Male':+ (form.genderField.field as HTMLSelectElement).value = 'M';break;- case 'mm-dd-yyyy':- formattedDate = `${month}-${day}-${year}`;- break;- case 'yyyy-mm-dd':- default:- formattedDate = `${year}-${month}-${day}`;+ case 'Female':+ (form.genderField.field as HTMLSelectElement).value = 'F';break;}-- form.birthdateField.single.value = formattedDate;- triggerInputEvents(form.birthdateField.single);}- } else {- if (credential.Alias.BirthDate) {- const birthDate = new Date(credential.Alias.BirthDate);- if (form.birthdateField.day) {- form.birthdateField.day.value = birthDate.getDate().toString().padStart(2, '0');- triggerInputEvents(form.birthdateField.day);- }- if (form.birthdateField.month) {- form.birthdateField.month.value = (birthDate.getMonth() + 1).toString().padStart(2, '0');- triggerInputEvents(form.birthdateField.month);- }- if (form.birthdateField.year) {- form.birthdateField.year.value = birthDate.getFullYear().toString();- triggerInputEvents(form.birthdateField.year);- }+ break;+ case 'radio': {+ const radioButtons = form.genderField.radioButtons;+ if (!radioButtons) break;++ let selectedRadio: HTMLInputElement | null = null;+ if (credential.Alias.Gender === 'Male' && radioButtons.male) {+ radioButtons.male.checked = true;+ selectedRadio = radioButtons.male;+ } else if (credential.Alias.Gender === 'Female' && radioButtons.female) {+ radioButtons.female.checked = true;+ selectedRadio = radioButtons.female;+ } else if (credential.Alias.Gender === 'Other' && radioButtons.other) {+ radioButtons.other.checked = true;+ selectedRadio = radioButtons.other;}- }- // Handle gender with input events- switch (form.genderField.type) {- case 'select':- if (form.genderField.field) {- switch (credential.Alias.Gender) {- case 'Male':- (form.genderField.field as HTMLSelectElement).value = 'M';- break;- case 'Female':- (form.genderField.field as HTMLSelectElement).value = 'F';- break;- }- }- break;- case 'radio':- const radioButtons = form.genderField.radioButtons;- if (!radioButtons) break;-- let selectedRadio: HTMLInputElement | null = null;- if (credential.Alias.Gender === 'Male' && radioButtons.male) {- radioButtons.male.checked = true;- selectedRadio = radioButtons.male;- } else if (credential.Alias.Gender === 'Female' && radioButtons.female) {- radioButtons.female.checked = true;- selectedRadio = radioButtons.female;- } else if (credential.Alias.Gender === 'Other' && radioButtons.other) {- radioButtons.other.checked = true;- selectedRadio = radioButtons.other;- }-- if (selectedRadio) {- triggerInputEvents(selectedRadio);- }- break;- case 'text':- if (form.genderField.field && credential.Alias.Gender) {- (form.genderField.field as HTMLInputElement).value = credential.Alias.Gender;- triggerInputEvents(form.genderField.field as HTMLInputElement);- }- break;+ if (selectedRadio) {+ triggerInputEvents(selectedRadio);+ }+ break;}+ case 'text':+ if (form.genderField.field && credential.Alias.Gender) {+ (form.genderField.field as HTMLInputElement).value = credential.Alias.Gender;+ triggerInputEvents(form.genderField.field as HTMLInputElement);+ }+ break;}+}/*** Inject icon for a focused input element*/export function injectIcon(input: HTMLInputElement): void {- const aliasvaultIconSvg = `<?xml version="1.0" encoding="UTF-8"?>+ const aliasvaultIconSvg = `<?xml version="1.0" encoding="UTF-8"?><svg enable-background="new 0 0 500 500" version="1.1" viewBox="0 0 500 500" xml:space="preserve" xmlns="http://www.w3.org/2000/svg"><path d="m459.87 294.95c0.016205 5.4005 0.03241 10.801-0.35022 16.873-1.111 6.3392-1.1941 12.173-2.6351 17.649-10.922 41.508-36.731 69.481-77.351 83.408-7.2157 2.4739-14.972 3.3702-22.479 4.995-23.629 0.042205-47.257 0.11453-70.886 0.12027-46.762 0.011322-93.523-0.01416-140.95-0.43411-8.59-2.0024-16.766-2.8352-24.398-5.3326-21.595-7.0666-39.523-19.656-53.708-37.552-10.227-12.903-17.579-27.17-21.28-43.221-1.475-6.3967-2.4711-12.904-3.6852-19.361-0.051849-5.747-0.1037-11.494 0.26915-17.886 4.159-42.973 27.68-71.638 63.562-92.153 0-0.70761-0.001961-1.6988 3.12e-4 -2.69 0.022484-9.8293-1.3071-19.894 0.35664-29.438 3.2391-18.579 11.08-35.272 23.763-49.773 12.098-13.832 26.457-23.989 43.609-30.029 7.813-2.7512 16.14-4.0417 24.234-5.9948 7.392-0.025734 14.784-0.05146 22.835 0.32253 4.1959 0.95392 7.7946 1.2538 11.258 2.1053 17.16 4.2192 32.287 12.176 45.469 24.104 2.2558 2.0411 4.372 6.6241 9.621 3.868 16.839-8.8419 34.718-11.597 53.603-8.594 16.791 2.6699 31.602 9.4308 44.236 20.636 11.531 10.227 19.84 22.841 25.393 37.236 6.3436 16.445 10.389 33.163 6.0798 49.389 7.9587 8.9321 15.807 16.704 22.421 25.414 9.162 12.065 15.33 25.746 18.144 40.776 0.97046 5.1848 1.9111 10.375 2.8654 15.563m-71.597 71.012c5.5615-5.2284 12.002-9.7986 16.508-15.817 10.474-13.992 14.333-29.916 11.288-47.446-2.2496-12.95-8.1973-24.076-17.243-33.063-12.746-12.663-28.865-18.614-46.786-18.569-69.912 0.17712-139.82 0.56831-209.74 0.96176-15.922 0.089599-29.168 7.4209-39.685 18.296-14.45 14.944-20.408 33.343-16.655 54.368 2.2763 12.754 8.2167 23.748 17.158 32.66 13.299 13.255 30.097 18.653 48.728 18.651 59.321-0.005188 118.64 0.042358 177.96-0.046601 9.5912-0.014374 19.181-0.86588 28.773-0.88855 10.649-0.025146 19.978-3.825 29.687-9.1074z" fill="#EEC170"/><path d="m162.77 293c15.654 4.3883 20.627 22.967 10.304 34.98-5.3104 6.1795-14.817 8.3208-24.278 5.0472-7.0723-2.4471-12.332-10.362-12.876-17.933-1.0451-14.542 11.089-23.176 21.705-23.046 1.5794 0.019287 3.1517 0.61566 5.1461 0.95184z" fill="#EEC170"/>@@ -139,7 +141,7 @@ export function injectIcon(input: HTMLInputElement): void {<path d="m336.91 333.41c-9.0175-4.2491-15.337-14.349-13.829-21.682 3.0825-14.989 13.341-20.304 23.018-19.585 10.653 0.79141 17.93 7.407 19.765 17.547 1.9588 10.824-4.1171 19.939-13.494 23.703-5.272 2.1162-10.091 1.5086-15.46 0.017883z" fill="#EEC170"/></svg>`;- const ICON_HTML = `+ const ICON_HTML = `<div class="aliasvault-input-icon" style="display: flex;align-items: center;@@ -157,25 +159,25 @@ export function injectIcon(input: HTMLInputElement): void {</div>`;- // Generate unique ID if input doesn't have one- if (!input.id) {- input.id = `aliasvault-input-${Math.random().toString(36).substr(2, 9)}`;- }+ // Generate unique ID if input doesn't have one+ if (!input.id) {+ input.id = `aliasvault-input-${Math.random().toString(36).substr(2, 9)}`;+ }- // Don't inject if already exists- if (document.querySelector(`[data-icon-for="${input.id}"]`)) {- return;- }+ // Don't inject if already exists+ if (document.querySelector(`[data-icon-for="${input.id}"]`)) {+ return;+ }- const iconDiv = document.createElement('div');- iconDiv.innerHTML = ICON_HTML;- const icon = iconDiv.firstElementChild as HTMLElement;+ const iconDiv = document.createElement('div');+ iconDiv.innerHTML = ICON_HTML;+ const icon = iconDiv.firstElementChild as HTMLElement;- // Get input's position and dimensions- const inputRect = input.getBoundingClientRect();+ // Get input's position and dimensions+ const inputRect = input.getBoundingClientRect();- // Position icon absolutely relative to viewport- icon.style.cssText = `+ // Position icon absolutely relative to viewport+ icon.style.cssText = `position: fixed;z-index: 9999;cursor: pointer;@@ -188,53 +190,58 @@ export function injectIcon(input: HTMLInputElement): void {transition: opacity 0.2s ease-in-out;`;- icon.setAttribute('data-icon-for', input.id);+ icon.setAttribute('data-icon-for', input.id);- icon.addEventListener('click', () => {- openAutofillPopup(input);- });+ icon.addEventListener('click', () => {+ openAutofillPopup(input);+ });- // Add to body- document.body.appendChild(icon);+ // Add to body+ document.body.appendChild(icon);- // Fade in the icon- requestAnimationFrame(() => {- icon.style.opacity = '1';- });+ // Fade in the icon+ requestAnimationFrame(() => {+ icon.style.opacity = '1';+ });- // Remove icon when input loses focus, except when clicking the icon- const handleBlur = (e: FocusEvent) => {- // Don't remove if clicking the icon itself- if (e.relatedTarget === icon) {- return;- }+ // Remove icon when input loses focus, except when clicking the icon+ /**+ *+ */+ const handleBlur = (e: FocusEvent) : void => {+ // Don't remove if clicking the icon itself+ if (e.relatedTarget === icon) {+ return;+ }- // Fade out and remove icon- icon.style.opacity = '0';- setTimeout(() => {- icon.remove();- input.removeEventListener('blur', handleBlur);- }, 200); // Match transition duration- };+ // Fade out and remove icon+ icon.style.opacity = '0';+ setTimeout(() => {+ icon.remove();+ input.removeEventListener('blur', handleBlur);+ }, 200); // Match transition duration+ };- input.addEventListener('blur', handleBlur);- }+ input.addEventListener('blur', handleBlur);+}/*** Trigger input events for an element to trigger form validation* which some websites require before the "continue" button is enabled.*/function triggerInputEvents(element: HTMLInputElement) : void {- // Basic events- element.dispatchEvent(new Event('input', { bubbles: true }));- element.dispatchEvent(new Event('change', { bubbles: true }));-- // For radio buttons, we need additional events in order for form validation- // to be triggered correctly.- if (element.type === 'radio') {- // Click events- element.dispatchEvent(new MouseEvent('mousedown', { bubbles: true }));- element.dispatchEvent(new MouseEvent('mouseup', { bubbles: true }));- element.dispatchEvent(new MouseEvent('click', { bubbles: true }));- }+ // Basic events+ element.dispatchEvent(new Event('input', { bubbles: true }));+ element.dispatchEvent(new Event('change', { bubbles: true }));++ /*+ * For radio buttons, we need additional events in order for form validation+ * to be triggered correctly.+ */+ if (element.type === 'radio') {+ // Click events+ element.dispatchEvent(new MouseEvent('mousedown', { bubbles: true }));+ element.dispatchEvent(new MouseEvent('mouseup', { bubbles: true }));+ element.dispatchEvent(new MouseEvent('click', { bubbles: true }));}+}diff --git a/browser-extensions/chrome/src/contentscript/Popup.ts b/browser-extensions/chrome/src/contentscript/Popup.tsindex b4a3e1d0e..f218ad1ac 100644--- a/browser-extensions/chrome/src/contentscript/Popup.ts+++ b/browser-extensions/chrome/src/contentscript/Popup.ts@@ -11,23 +11,31 @@ import { FormDetector } from '../utils/form-detector/FormDetector';*/const placeholderBase64 = 'UklGRjoEAABXRUJQVlA4IC4EAAAwFwCdASqAAIAAPpFCm0olo6Ihp5IraLASCWUA0eb/0s56RrLtCnYfLPiBshdXWMx8j1Ez65f169iA4xUDBTEV6ylMQeCIj2b7RngGi7gKZ9WjKdSoy9R8JcgOmjCMlDmLG20KhNo/i/Dc/Ah5GAvGfm8kfniV3AkR6fxN6eKwjDc6xrDgSfS48G5uGV6WzQt24YAVlLSK9BMwndzfHnePK1KFchFrL7O3ulB8cGNCeomu4o+l0SrS/JKblJ4WTzj0DAD++lCUEouSfgRKdiV2TiYCD+H+l3tANKSPQFPQuzi7rbvxqGeRmXB9kDwURaoSTTpYjA9REMUi9uA6aV7PWtBNXgUzMLowYMZeos6Xvyhb34GmufswMHA5ZyYpxzjTphOak4ZjNOiz8aScO5ygiTx99SqwX/uL+HSeVOSraHw8IymrMwm+jLxqN8BS8dGcItLlm/ioulqH2j4V8glDgSut+ExkxiD7m8TGPrrjCQNJbRDzpOFsyCyfBZupvp8QjGKW2KGziSZeIWes4aTB9tRmeEBhnUrmTDZQuXcc67Fg82KHrSfaeeOEq6jjuUjQ8wUnzM4Zz3dhrwSyslVz/WvnKqYkr4V/TTXPFF5EjF4rM1bHZ8bK63EfTnK41+n3n4gEFoYP4mXkNH0hntnYcdTqiE7Gn+q0BpRRxnkpBSZlA6Wa70jpW0FGqkw5e591A5/H+OV+60WAo+4Mi+NlsKrvLZ9EiVaPnoEFZlJQx1fA777AJ2MjXJ4KSsrWDWJi1lE8yPs8V6XvcC0chDTYt8456sKXAagCZyY+fzQriFMaddXyKQdG8qBqcdYjAsiIcjzaRFBBoOK9sU+sFY7N6B6+xtrlu3c37rQKkI3O2EoiJOris54EjJ5OFuumA0M6riNUuBf/MEPFBVx1JRcUEs+upEBsCnwYski7FT3TTqHrx7v5AjgFN97xhPTkmVpu6sxRnWBi1fxIRp8eWZeFM6mUcGgVk1WeVb1yhdV9hoMo2TsNEPE0tHo/wvuSJSzbZo7wibeXM9v/rRfKcx7X93rfiXVnyQ9f/5CaAQ4lxedPp/6uzLtOS4FyL0bCNeZ6L5w+AiuyWCTDFIYaUzhwfG+/YTQpWyeZCdQIKzhV+3GeXI2cxoP0ER/DlOKymf1gm+zRU3sqf1lBVQ0y+mK/Awl9bS3uaaQmI0FUyUwHUKP7PKuXnO+LcwDv4OfPT6hph8smc1EtMe5ib/apar/qZ9dyaEaElALJ1KKxnHziuvVl8atk1fINSQh7OtXDyqbPw9o/nGIpTnv5iFmwmWJLis2oyEgPkJqyx0vYI8rjkVEzKc8eQavAJBYSpjMwM193Swt+yJyjvaGYWPnqExxKiNarpB2WSO7soCAZXhS1uEYHryrK47BH6W1dRiruqT0xpLih3MXiwU3VDwAAAA==';+/**+ * Response from the background script.+ */+type CredentialResponse = {+ status: 'OK' | 'LOCKED';+ credentials?: Credential[];+}+/*** Create basic popup with default style.*/export function createBasePopup(input: HTMLInputElement) : HTMLElement {- // Remove existing popup and its event listeners- removeExistingPopup();+ // Remove existing popup and its event listeners+ removeExistingPopup();- const popup = document.createElement('div');- popup.id = 'aliasvault-credential-popup';+ const popup = document.createElement('div');+ popup.id = 'aliasvault-credential-popup';- // Get input width- const inputWidth = input.offsetWidth;+ // Get input width+ const inputWidth = input.offsetWidth;- // Set popup width to match input width, with min/max constraints- const popupWidth = Math.max(360, Math.min(640, inputWidth));+ // Set popup width to match input width, with min/max constraints+ const popupWidth = Math.max(360, Math.min(640, inputWidth));- popup.style.cssText = `+ popup.style.cssText = `position: absolute;z-index: 999999;background: ${isDarkMode() ? '#1f2937' : 'white'};@@ -40,19 +48,22 @@ export function createBasePopup(input: HTMLInputElement) : HTMLElement {font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif !important;`;- // Position popup below input- const rect = input.getBoundingClientRect();- popup.style.top = `${rect.bottom + window.scrollY + 2}px`;- popup.style.left = `${rect.left + window.scrollX}px`;+ // Position popup below input+ const rect = input.getBoundingClientRect();+ popup.style.top = `${rect.bottom + window.scrollY + 2}px`;+ popup.style.left = `${rect.left + window.scrollX}px`;- return popup;+ return popup;}/*** Create a loading popup.*/export function createLoadingPopup(input: HTMLInputElement, message: string) : HTMLElement {- const getLoadingHtml = (message: string): string => `+ /**+ *+ */+ const getLoadingHtml = (message: string): string => `<div style="display: flex;align-items: center;@@ -68,43 +79,45 @@ export function createLoadingPopup(input: HTMLInputElement, message: string) : H</div>`;- const popup = createBasePopup(input);- popup.innerHTML = getLoadingHtml(message);+ const popup = createBasePopup(input);+ popup.innerHTML = getLoadingHtml(message);- document.body.appendChild(popup);- return popup;+ document.body.appendChild(popup);+ return popup;}/*** Update the credential list content in the popup.*/export function updatePopupContent(credentials: Credential[], credentialList: HTMLElement | null) : void {- if (!credentialList) {- credentialList = document.getElementById('aliasvault-credential-list') as HTMLElement;- }+ if (!credentialList) {+ credentialList = document.getElementById('aliasvault-credential-list') as HTMLElement;+ }- if (!credentialList) return;+ if (!credentialList) return;- // Clear existing content- credentialList.innerHTML = '';+ // Clear existing content+ credentialList.innerHTML = '';- // Add credentials using the shared function- const credentialElements = createCredentialList(credentials);- credentialElements.forEach(element => credentialList.appendChild(element));+ // Add credentials using the shared function+ const credentialElements = createCredentialList(credentials);+ credentialElements.forEach(element => credentialList.appendChild(element));}/*** Remove existing popup (if any exists).*/export function removeExistingPopup() : void {- const existing = document.getElementById('aliasvault-credential-popup');- if (existing) {- // Remove the mousedown event listener before removing the popup- // TODO: remove if not needed- //document.removeEventListener('mousedown', handleClickOutside);- existing.remove();- }+ const existing = document.getElementById('aliasvault-credential-popup');+ if (existing) {+ /*+ * Remove the mousedown event listener before removing the popup+ * TODO: remove if not needed+ * document.removeEventListener('mousedown', handleClickOutside);+ */+ existing.remove();}+}/*** Create auto-fill popup@@ -270,11 +283,6 @@ export function createAutofillPopup(input: HTMLInputElement, credentials: CredenclearTimeout(searchTimeout);const searchTerm = searchInput.value.toLowerCase();- type CredentialResponse = {- status: 'OK' | 'LOCKED';- credentials?: Credential[];- }-// Request credentials from background scriptchrome.runtime.sendMessage({ type: 'GET_CREDENTIALS_FOR_URL', url: window.location.href }, (response: CredentialResponse) => {if (response.status === 'OK' && response.credentials) {@@ -339,6 +347,9 @@ export function createAutofillPopup(input: HTMLInputElement, credentials: Credenpopup.appendChild(actionContainer);// Define handleClickOutside+ /**+ *+ */const handleClickOutside = (event: MouseEvent) : void => {const popup = document.getElementById('aliasvault-credential-popup');const target = event.target as Node;@@ -458,16 +469,16 @@ export function createVaultLockedPopup(input: HTMLInputElement): void {document.body.appendChild(popup);}- /**+/*** Create credential list content for popup*/function createCredentialList(credentials: Credential[]): HTMLElement[] {- const elements: HTMLElement[] = [];+ const elements: HTMLElement[] = [];- if (credentials.length > 0) {- credentials.forEach(cred => {- const item = document.createElement('div');- item.style.cssText = `+ if (credentials.length > 0) {+ credentials.forEach(cred => {+ const item = document.createElement('div');+ item.style.cssText = `padding: 8px 16px;cursor: pointer;display: flex;@@ -479,9 +490,9 @@ function createCredentialList(credentials: Credential[]): HTMLElement[] {margin: 0 4px;`;- // Create container for credential info (logo + username)- const credentialInfo = document.createElement('div');- credentialInfo.style.cssText = `+ // Create container for credential info (logo + username)+ const credentialInfo = document.createElement('div');+ credentialInfo.style.cssText = `display: flex;align-items: center;gap: 16px;@@ -491,35 +502,35 @@ function createCredentialList(credentials: Credential[]): HTMLElement[] {transition: background-color 0.2s ease;`;- const imgElement = document.createElement('img');- imgElement.style.width = '20px';- imgElement.style.height = '20px';-- // Handle base64 image data- if (cred.Logo) {- try {- const base64Logo = base64Encode(cred.Logo);- imgElement.src = `data:image/x-icon;base64,${base64Logo}`;- } catch (error) {- console.error('Error setting logo:', error);- imgElement.src = `data:image/x-icon;base64,${placeholderBase64}`;- }- } else {+ const imgElement = document.createElement('img');+ imgElement.style.width = '20px';+ imgElement.style.height = '20px';++ // Handle base64 image data+ if (cred.Logo) {+ try {+ const base64Logo = base64Encode(cred.Logo);+ imgElement.src = `data:image/x-icon;base64,${base64Logo}`;+ } catch (error) {+ console.error('Error setting logo:', error);imgElement.src = `data:image/x-icon;base64,${placeholderBase64}`;}+ } else {+ imgElement.src = `data:image/x-icon;base64,${placeholderBase64}`;+ }- credentialInfo.appendChild(imgElement);- const credTextContainer = document.createElement('div');- credTextContainer.style.cssText = `+ credentialInfo.appendChild(imgElement);+ const credTextContainer = document.createElement('div');+ credTextContainer.style.cssText = `display: flex;flex-direction: column;flex-grow: 1;min-width: 0; /* Enable text truncation in flex container */`;- // Service name (primary text)- const serviceName = document.createElement('div');- serviceName.style.cssText = `+ // Service name (primary text)+ const serviceName = document.createElement('div');+ serviceName.style.cssText = `font-weight: 500;white-space: nowrap;overflow: hidden;@@ -527,11 +538,11 @@ function createCredentialList(credentials: Credential[]): HTMLElement[] {text-overflow: ellipsis;color: ${isDarkMode() ? '#f3f4f6' : '#111827'};`;- serviceName.textContent = cred.ServiceName;+ serviceName.textContent = cred.ServiceName;- // Details container (secondary text)- const detailsContainer = document.createElement('div');- detailsContainer.style.cssText = `+ // Details container (secondary text)+ const detailsContainer = document.createElement('div');+ detailsContainer.style.cssText = `font-size: 0.85em;white-space: nowrap;overflow: hidden;@@ -540,28 +551,28 @@ function createCredentialList(credentials: Credential[]): HTMLElement[] {color: ${isDarkMode() ? '#9ca3af' : '#6b7280'};`;- // Combine full name (if available) and username- const details = [];- if (cred.Alias?.FirstName && cred.Alias?.LastName) {- details.push(`${cred.Alias.FirstName} ${cred.Alias.LastName}`);- }- details.push(cred.Username);- detailsContainer.textContent = details.join(' · ');+ // Combine full name (if available) and username+ const details = [];+ if (cred.Alias?.FirstName && cred.Alias?.LastName) {+ details.push(`${cred.Alias.FirstName} ${cred.Alias.LastName}`);+ }+ details.push(cred.Username);+ detailsContainer.textContent = details.join(' · ');- credTextContainer.appendChild(serviceName);- credTextContainer.appendChild(detailsContainer);- credentialInfo.appendChild(credTextContainer);+ credTextContainer.appendChild(serviceName);+ credTextContainer.appendChild(detailsContainer);+ credentialInfo.appendChild(credTextContainer);- // Add popout icon- const popoutIcon = document.createElement('div');- popoutIcon.style.cssText = `+ // Add popout icon+ const popoutIcon = document.createElement('div');+ popoutIcon.style.cssText = `display: flex;align-items: center;padding: 4px;opacity: 0.6;border-radius: 4px;`;- popoutIcon.innerHTML = `+ popoutIcon.innerHTML = `<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"></path><polyline points="15 3 21 3 21 9"></polyline>@@ -569,101 +580,100 @@ function createCredentialList(credentials: Credential[]): HTMLElement[] {</svg>`;- // Add hover effects- popoutIcon.addEventListener('mouseenter', () => {- popoutIcon.style.opacity = '1';- popoutIcon.style.backgroundColor = isDarkMode() ? '#ffffff' : '#000000';- popoutIcon.style.color = isDarkMode() ? '#000000' : '#ffffff';- });+ // Add hover effects+ popoutIcon.addEventListener('mouseenter', () => {+ popoutIcon.style.opacity = '1';+ popoutIcon.style.backgroundColor = isDarkMode() ? '#ffffff' : '#000000';+ popoutIcon.style.color = isDarkMode() ? '#000000' : '#ffffff';+ });- popoutIcon.addEventListener('mouseleave', () => {- popoutIcon.style.opacity = '0.6';- popoutIcon.style.backgroundColor = 'transparent';- popoutIcon.style.color = isDarkMode() ? '#ffffff' : '#000000';- });+ popoutIcon.addEventListener('mouseleave', () => {+ popoutIcon.style.opacity = '0.6';+ popoutIcon.style.backgroundColor = 'transparent';+ popoutIcon.style.color = isDarkMode() ? '#ffffff' : '#000000';+ });- // Handle popout click- popoutIcon.addEventListener('click', (e) => {- e.stopPropagation(); // Prevent credential fill- chrome.runtime.sendMessage({- type: 'OPEN_POPUP_WITH_CREDENTIAL',- credentialId: cred.Id- });- removeExistingPopup();+ // Handle popout click+ popoutIcon.addEventListener('click', (e) => {+ e.stopPropagation(); // Prevent credential fill+ chrome.runtime.sendMessage({+ type: 'OPEN_POPUP_WITH_CREDENTIAL',+ credentialId: cred.Id});+ removeExistingPopup();+ });- item.appendChild(credentialInfo);- item.appendChild(popoutIcon);-- // Update hover effect for the entire item- item.addEventListener('mouseenter', () => {- item.style.backgroundColor = isDarkMode() ? '#2d3748' : '#f3f4f6';- popoutIcon.style.opacity = '1';- });+ item.appendChild(credentialInfo);+ item.appendChild(popoutIcon);- item.addEventListener('mouseleave', () => {- item.style.backgroundColor = 'transparent';- popoutIcon.style.opacity = '0.6';- });+ // Update hover effect for the entire item+ item.addEventListener('mouseenter', () => {+ item.style.backgroundColor = isDarkMode() ? '#2d3748' : '#f3f4f6';+ popoutIcon.style.opacity = '1';+ });- // Update click handler to only trigger on credentialInfo- credentialInfo.addEventListener('click', () => {- fillCredential(cred);- removeExistingPopup();- });+ item.addEventListener('mouseleave', () => {+ item.style.backgroundColor = 'transparent';+ popoutIcon.style.opacity = '0.6';+ });- elements.push(item);+ // Update click handler to only trigger on credentialInfo+ credentialInfo.addEventListener('click', () => {+ fillCredential(cred);+ removeExistingPopup();});- } else {- const noMatches = document.createElement('div');- noMatches.style.cssText = `++ elements.push(item);+ });+ } else {+ const noMatches = document.createElement('div');+ noMatches.style.cssText = `padding: 8px 16px;color: ${isDarkMode() ? '#9ca3af' : '#6b7280'};font-style: italic;font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif !important;`;- noMatches.textContent = 'No matches found';- elements.push(noMatches);- }-- return elements;+ noMatches.textContent = 'No matches found';+ elements.push(noMatches);}- const DISABLED_SITES_KEY = 'aliasvault_disabled_sites';+ return elements;+}+const DISABLED_SITES_KEY = 'aliasvault_disabled_sites';- /**+/*** Check if auto-popup is disabled for current site*/export async function isAutoShowPopupDisabled(): Promise<boolean> {- const result = await chrome.storage.local.get(DISABLED_SITES_KEY);- const disabledSites = result[DISABLED_SITES_KEY] || [];- return disabledSites.includes(window.location.hostname);- }+ const result = await chrome.storage.local.get(DISABLED_SITES_KEY);+ const disabledSites = result[DISABLED_SITES_KEY] || [];+ return disabledSites.includes(window.location.hostname);+}- /**- * Disable auto-popup for current site- */- export async function disableAutoShowPopup(): Promise<void> {- const result = await chrome.storage.local.get(DISABLED_SITES_KEY);- const disabledSites = result[DISABLED_SITES_KEY] || [];- if (!disabledSites.includes(window.location.hostname)) {- disabledSites.push(window.location.hostname);- await chrome.storage.local.set({ [DISABLED_SITES_KEY]: disabledSites });- }+/**+ * Disable auto-popup for current site+ */+export async function disableAutoShowPopup(): Promise<void> {+ const result = await chrome.storage.local.get(DISABLED_SITES_KEY);+ const disabledSites = result[DISABLED_SITES_KEY] || [];+ if (!disabledSites.includes(window.location.hostname)) {+ disabledSites.push(window.location.hostname);+ await chrome.storage.local.set({ [DISABLED_SITES_KEY]: disabledSites });}+}- /**+/*** Create edit name popup. Part of the "create new alias" flow.*/export async function createEditNamePopup(defaultName: string): Promise<string | null> {- // Close existing popup- removeExistingPopup();+ // Close existing popup+ removeExistingPopup();- return new Promise((resolve) => {- // Create modal overlay- const overlay = document.createElement('div');- overlay.style.cssText = `+ return new Promise((resolve) => {+ // Create modal overlay+ const overlay = document.createElement('div');+ overlay.style.cssText = `position: fixed;top: 0;left: 0;@@ -676,8 +686,8 @@ export async function createEditNamePopup(defaultName: string): Promise<string |justify-content: center;`;- const popup = document.createElement('div');- popup.style.cssText = `+ const popup = document.createElement('div');+ popup.style.cssText = `position: relative;z-index: 1000000;background: ${isDarkMode() ? '#1f2937' : 'white'};@@ -695,7 +705,7 @@ export async function createEditNamePopup(defaultName: string): Promise<string |font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif !important;`;- popup.innerHTML = `+ popup.innerHTML = `<h3 style="margin: 0 0 16px 0; font-size: 18px; font-weight: 600; color: ${isDarkMode() ? '#f8f9fa' : '#000000'}">New alias name</h3>@@ -740,168 +750,158 @@ export async function createEditNamePopup(defaultName: string): Promise<string |</div>`;- overlay.appendChild(popup);- document.body.appendChild(overlay);-- // Add hover and focus styles- const input = popup.querySelector('#service-name-input') as HTMLInputElement;- const saveBtn = popup.querySelector('#save-btn') as HTMLButtonElement;- const cancelBtn = popup.querySelector('#cancel-btn') as HTMLButtonElement;+ overlay.appendChild(popup);+ document.body.appendChild(overlay);- input.addEventListener('focus', () => {- input.style.borderColor = '#2563eb';- input.style.boxShadow = '0 0 0 3px rgba(37, 99, 235, 0.1)';- });+ // Add hover and focus styles+ const input = popup.querySelector('#service-name-input') as HTMLInputElement;+ const saveBtn = popup.querySelector('#save-btn') as HTMLButtonElement;+ const cancelBtn = popup.querySelector('#cancel-btn') as HTMLButtonElement;- input.addEventListener('blur', () => {- input.style.borderColor = isDarkMode() ? '#374151' : '#ccc';- input.style.boxShadow = 'none';- });+ input.addEventListener('focus', () => {+ input.style.borderColor = '#2563eb';+ input.style.boxShadow = '0 0 0 3px rgba(37, 99, 235, 0.1)';+ });- saveBtn.addEventListener('mouseenter', () => {- saveBtn.style.background = '#1d4ed8';- saveBtn.style.transform = 'translateY(-1px)';- });+ input.addEventListener('blur', () => {+ input.style.borderColor = isDarkMode() ? '#374151' : '#ccc';+ input.style.boxShadow = 'none';+ });- saveBtn.addEventListener('mouseleave', () => {- saveBtn.style.background = '#2563eb';- saveBtn.style.transform = 'translateY(0)';- });+ saveBtn.addEventListener('mouseenter', () => {+ saveBtn.style.background = '#1d4ed8';+ saveBtn.style.transform = 'translateY(-1px)';+ });- cancelBtn.addEventListener('mouseenter', () => {- cancelBtn.style.background = isDarkMode() ? '#374151' : '#f3f4f6';- });+ saveBtn.addEventListener('mouseleave', () => {+ saveBtn.style.background = '#2563eb';+ saveBtn.style.transform = 'translateY(0)';+ });- cancelBtn.addEventListener('mouseleave', () => {- cancelBtn.style.background = 'transparent';- });+ cancelBtn.addEventListener('mouseenter', () => {+ cancelBtn.style.background = isDarkMode() ? '#374151' : '#f3f4f6';+ });- // Animate in- requestAnimationFrame(() => {- popup.style.transform = 'scale(1)';- popup.style.opacity = '1';- });+ cancelBtn.addEventListener('mouseleave', () => {+ cancelBtn.style.background = 'transparent';+ });- // Select input text- input.select();+ // Animate in+ requestAnimationFrame(() => {+ popup.style.transform = 'scale(1)';+ popup.style.opacity = '1';+ });- // Add variable to track if text is being selected- let isSelecting = false;+ // Select input text+ input.select();- // Add mousedown handler to input- input.addEventListener('mousedown', () => {- isSelecting = true;- });+ /**+ *+ */+ const closePopup = (value: string | null) : void => {+ popup.style.transform = 'scale(0.95)';+ popup.style.opacity = '0';+ setTimeout(() => {+ overlay.remove();+ resolve(value);+ }, 200);+ };- // Add mouseup handler to document- document.addEventListener('mouseup', () => {- // Use setTimeout to ensure click handler runs after mouseup- setTimeout(() => {- isSelecting = false;- }, 0);- });+ // Handle save+ saveBtn.addEventListener('click', () => {+ const value = input.value.trim();+ if (value) {+ closePopup(value);+ }+ });- const closePopup = (value: string | null) => {- popup.style.transform = 'scale(0.95)';- popup.style.opacity = '0';- setTimeout(() => {- overlay.remove();- resolve(value);- }, 200);- };+ // Handle cancel+ cancelBtn.addEventListener('click', () => {+ closePopup(null);+ });- // Handle save- saveBtn.addEventListener('click', () => {+ // Handle Enter key+ input.addEventListener('keyup', (e) => {+ if (e.key === 'Enter') {const value = input.value.trim();if (value) {closePopup(value);}- });-- // Handle cancel- cancelBtn.addEventListener('click', () => {- closePopup(null);- });-- // Handle Enter key- input.addEventListener('keyup', (e) => {- if (e.key === 'Enter') {- const value = input.value.trim();- if (value) {- closePopup(value);- }- }- });+ }+ });- // Handle click outside- overlay.addEventListener('click', (e) => {- if (e.target === overlay) {- // Check if there's any text selected in the input- const selectedText = input.value.substring(input.selectionStart || 0, input.selectionEnd || 0);+ // Handle click outside+ overlay.addEventListener('click', (e) => {+ if (e.target === overlay) {+ // Check if there's any text selected in the input+ const selectedText = input.value.substring(input.selectionStart || 0, input.selectionEnd || 0);- // Only close if no text is selected- if (!selectedText) {- closePopup(null);- }+ // Only close if no text is selected+ if (!selectedText) {+ closePopup(null);}- });+ }});- };+ });+};- /**+/*** Open (or refresh) the autofill popup including check if vault is locked.*/export function openAutofillPopup(input: HTMLInputElement) : void {- const formDetector = new FormDetector(document);- const forms = formDetector.detectForms();+ const formDetector = new FormDetector(document);+ const forms = formDetector.detectForms();- if (!forms.length) return;-- // Add keydown event listener for Enter key- const handleEnterKey = (e: KeyboardEvent) => {- if (e.key === 'Enter') {- removeExistingPopup();- // Remove the event listener to clean up- document.removeEventListener('keydown', handleEnterKey);- }- };- document.addEventListener('keydown', handleEnterKey);+ if (!forms.length) return;- // Request credentials from background script- chrome.runtime.sendMessage({ type: 'GET_CREDENTIALS_FOR_URL', url: window.location.href }, (response: CredentialResponse) => {- switch (response.status) {- case 'OK':- if (response.credentials?.length) {- createAutofillPopup(input, response.credentials);- }- break;+ // Add keydown event listener for Enter key+ /**+ *+ */+ const handleEnterKey = (e: KeyboardEvent) : void => {+ if (e.key === 'Enter') {+ removeExistingPopup();+ // Remove the event listener to clean up+ document.removeEventListener('keydown', handleEnterKey);+ }+ };+ document.addEventListener('keydown', handleEnterKey);++ // Request credentials from background script+ chrome.runtime.sendMessage({ type: 'GET_CREDENTIALS_FOR_URL', url: window.location.href }, (response: CredentialResponse) => {+ switch (response.status) {+ case 'OK':+ if (response.credentials?.length) {+ createAutofillPopup(input, response.credentials);+ }+ break;- case 'LOCKED':- createVaultLockedPopup(input);- break;- }- });- }+ case 'LOCKED':+ createVaultLockedPopup(input);+ break;+ }+ });+}/*** Base64 encode binary data.*/function base64Encode(buffer: Uint8Array): string | null {- if (!buffer || typeof buffer !== 'object') {- return null;- }+ if (!buffer || typeof buffer !== 'object') {+ return null;+ }- try {- // Convert object to array of numbers- const byteArray = Object.values(buffer);+ try {+ // Convert object to array of numbers+ const byteArray = Object.values(buffer);- // Convert to binary string- const binary = String.fromCharCode.apply(null, byteArray as number[]);+ // Convert to binary string+ const binary = String.fromCharCode.apply(null, byteArray as number[]);- // Use btoa to encode binary string to base64- return btoa(binary);- } catch (error) {- console.error('Error encoding to base64:', error);- return null;- }- }\ No newline at end of file+ // Use btoa to encode binary string to base64+ return btoa(binary);+ } catch (error) {+ console.error('Error encoding to base64:', error);+ return null;+ }+}\ No newline at end of filediff --git a/browser-extensions/chrome/src/contentscript/Shared.ts b/browser-extensions/chrome/src/contentscript/Shared.tsindex 210ef4829..1949eb217 100644--- a/browser-extensions/chrome/src/contentscript/Shared.ts+++ b/browser-extensions/chrome/src/contentscript/Shared.ts@@ -2,5 +2,5 @@* Check if the current theme is dark.*/export function isDarkMode(): boolean {- return window.matchMedia('(prefers-color-scheme: dark)').matches;+ return window.matchMedia('(prefers-color-scheme: dark)').matches;}\ No newline at end of file