mirror of
https://github.com/aliasvault/aliasvault.git
synced 2026-03-26 02:22:17 -04:00
Merge branch 'main' of https://github.com/aliasvault/aliasvault
* 'main' of https://github.com/aliasvault/aliasvault: Make browser extension passkey auth flow look at full domain including subdomain (#1806)
This commit is contained in:
@@ -7,7 +7,7 @@ import { handleGetEncryptionKey } from '@/entrypoints/background/VaultMessageHan
|
||||
|
||||
import type { PasskeyWithItem } from '@/utils/db/mappers/PasskeyMapper';
|
||||
import { EncryptionUtility } from '@/utils/EncryptionUtility';
|
||||
import { extractDomain, extractRootDomain } from '@/utils/itemMatcher/ItemMatcher';
|
||||
import { extractDomain } from '@/utils/itemMatcher/ItemMatcher';
|
||||
import { LocalPreferencesService } from '@/utils/LocalPreferencesService';
|
||||
import { PasskeyHelper } from '@/utils/passkey/PasskeyHelper';
|
||||
import type {
|
||||
@@ -48,15 +48,15 @@ export async function handleGetWebAuthnSettings(data: any): Promise<WebAuthnSett
|
||||
return { enabled: false };
|
||||
}
|
||||
|
||||
// If hostname is provided, check if it's disabled for that site
|
||||
const { hostname } = data || {};
|
||||
if (hostname) {
|
||||
// Extract base domain for matching
|
||||
const baseDomain = await extractRootDomain(await extractDomain(hostname));
|
||||
// If URL is provided, check if it's disabled for that site
|
||||
const { url } = data || {};
|
||||
if (url) {
|
||||
// Extract domain for matching
|
||||
const domain = await extractDomain(url);
|
||||
|
||||
// Check disabled sites
|
||||
const disabledSites = await LocalPreferencesService.getPasskeyDisabledSites();
|
||||
if (disabledSites.includes(baseDomain)) {
|
||||
if (disabledSites.includes(domain)) {
|
||||
return { enabled: false };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -262,7 +262,7 @@ export async function initializeWebAuthnInterceptor(_ctx: any): Promise<void> {
|
||||
export async function isWebAuthnInterceptionEnabled(): Promise<boolean> {
|
||||
try {
|
||||
const response = await sendMessage('GET_WEBAUTHN_SETTINGS', {
|
||||
hostname: window.location.hostname
|
||||
url: window.location.href
|
||||
}, 'background') as unknown as WebAuthnSettingsResponse;
|
||||
return response.enabled ?? false;
|
||||
} catch {
|
||||
|
||||
@@ -10,7 +10,7 @@ import { useDb } from '@/entrypoints/popup/context/DbContext';
|
||||
import { useLoading } from '@/entrypoints/popup/context/LoadingContext';
|
||||
import { useVaultLockRedirect } from '@/entrypoints/popup/hooks/useVaultLockRedirect';
|
||||
|
||||
import { extractDomain, extractRootDomain } from '@/utils/itemMatcher/ItemMatcher';
|
||||
import { extractDomain } from '@/utils/itemMatcher/ItemMatcher';
|
||||
import { LocalPreferencesService } from '@/utils/LocalPreferencesService';
|
||||
import { PasskeyAuthenticator } from '@/utils/passkey/PasskeyAuthenticator';
|
||||
import { PasskeyHelper } from '@/utils/passkey/PasskeyHelper';
|
||||
@@ -313,13 +313,12 @@ const PasskeyAuthenticate: React.FC = () => {
|
||||
}
|
||||
|
||||
if (choice === 'always') {
|
||||
// Add to permanent disabled list
|
||||
const hostname = new URL(request.origin).hostname;
|
||||
const baseDomain = await extractRootDomain(await extractDomain(hostname));
|
||||
// Add to permanent disabled list (for this specific subdomain)
|
||||
const domain = await extractDomain(request.origin);
|
||||
|
||||
const disabledSites = await LocalPreferencesService.getPasskeyDisabledSites();
|
||||
if (!disabledSites.includes(baseDomain)) {
|
||||
disabledSites.push(baseDomain);
|
||||
if (!disabledSites.includes(domain)) {
|
||||
disabledSites.push(domain);
|
||||
await LocalPreferencesService.setPasskeyDisabledSites(disabledSites);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ import { useVaultMutate } from '@/entrypoints/popup/hooks/useVaultMutate';
|
||||
|
||||
import type { Item, Passkey } from '@/utils/dist/core/models/vault';
|
||||
import { FieldKey, ItemTypes, getFieldValue, createSystemField } from '@/utils/dist/core/models/vault';
|
||||
import { extractDomain, extractRootDomain, filterItems, AutofillMatchingMode } from '@/utils/itemMatcher/ItemMatcher';
|
||||
import { extractDomain, filterItems, AutofillMatchingMode } from '@/utils/itemMatcher/ItemMatcher';
|
||||
import { LocalPreferencesService } from '@/utils/LocalPreferencesService';
|
||||
import { PasskeyAuthenticator } from '@/utils/passkey/PasskeyAuthenticator';
|
||||
import { PasskeyHelper } from '@/utils/passkey/PasskeyHelper';
|
||||
@@ -490,13 +490,12 @@ const PasskeyCreate: React.FC = () => {
|
||||
}
|
||||
|
||||
if (choice === 'always') {
|
||||
// Add to permanent disabled list
|
||||
const hostname = new URL(request.origin).hostname;
|
||||
const baseDomain = await extractRootDomain(await extractDomain(hostname));
|
||||
// Add to permanent disabled list (for this specific subdomain)
|
||||
const domain = await extractDomain(request.origin);
|
||||
|
||||
const disabledSites = await LocalPreferencesService.getPasskeyDisabledSites();
|
||||
if (!disabledSites.includes(baseDomain)) {
|
||||
disabledSites.push(baseDomain);
|
||||
if (!disabledSites.includes(domain)) {
|
||||
disabledSites.push(domain);
|
||||
await LocalPreferencesService.setPasskeyDisabledSites(disabledSites);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { useLoading } from '@/entrypoints/popup/context/LoadingContext';
|
||||
|
||||
import { extractDomain, extractRootDomain } from '@/utils/itemMatcher/ItemMatcher';
|
||||
import { extractDomain } from '@/utils/itemMatcher/ItemMatcher';
|
||||
import { LocalPreferencesService } from '@/utils/LocalPreferencesService';
|
||||
|
||||
import { browser } from "#imports";
|
||||
@@ -45,19 +45,19 @@ const PasskeySettings: React.FC = () => {
|
||||
*/
|
||||
const loadSettings = useCallback(async () : Promise<void> => {
|
||||
const tab = await getCurrentTab();
|
||||
const hostname = new URL(tab.url ?? '').hostname;
|
||||
const baseDomain = await extractRootDomain(await extractDomain(hostname));
|
||||
const url = tab.url ?? '';
|
||||
const domain = await extractDomain(url);
|
||||
|
||||
// Load settings using LocalPreferencesService
|
||||
const disabledUrls = await LocalPreferencesService.getPasskeyDisabledSites();
|
||||
const isGloballyEnabled = await LocalPreferencesService.getPasskeyProviderEnabled();
|
||||
|
||||
// Check if current base domain is disabled
|
||||
const isEnabled = !disabledUrls.includes(baseDomain);
|
||||
// Check if current domain is disabled
|
||||
const isEnabled = !disabledUrls.includes(domain);
|
||||
|
||||
setSettings({
|
||||
disabledUrls,
|
||||
currentUrl: baseDomain,
|
||||
currentUrl: domain,
|
||||
isEnabled,
|
||||
isGloballyEnabled
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user