mirror of
https://github.com/bitwarden/browser.git
synced 2025-03-11 13:30:39 +01:00
[PM-4766] Disable fido2 integration on bw vault page (#6861)
* [PM-4766] feat: disable fido2 integration on bw vault page * [PM-4766] fix: lint
This commit is contained in:
parent
43bda8b139
commit
29841605fb
@ -21,7 +21,7 @@ async function getFromLocalStorage(keys: string | string[]): Promise<Record<stri
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function isDomainExcluded() {
|
async function getActiveUserSettings() {
|
||||||
// TODO: This is code copied from `notification-bar.tsx`. We should refactor this into a shared function.
|
// TODO: This is code copied from `notification-bar.tsx`. We should refactor this into a shared function.
|
||||||
// Look up the active user id from storage
|
// Look up the active user id from storage
|
||||||
const activeUserIdKey = "activeUserId";
|
const activeUserIdKey = "activeUserId";
|
||||||
@ -32,10 +32,14 @@ async function isDomainExcluded() {
|
|||||||
activeUserId = activeUserStorageValue[activeUserIdKey];
|
activeUserId = activeUserStorageValue[activeUserIdKey];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Look up the user's settings from storage
|
const settingsStorage = await getFromLocalStorage(activeUserId);
|
||||||
const userSettingsStorageValue = await getFromLocalStorage(activeUserId);
|
|
||||||
|
|
||||||
const excludedDomains = userSettingsStorageValue[activeUserId]?.settings?.neverDomains;
|
// Look up the user's settings from storage
|
||||||
|
return settingsStorage?.[activeUserId]?.settings;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function isDomainExcluded(activeUserSettings: Record<string, any>) {
|
||||||
|
const excludedDomains = activeUserSettings?.neverDomains;
|
||||||
return excludedDomains && window.location.hostname in excludedDomains;
|
return excludedDomains && window.location.hostname in excludedDomains;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,6 +57,10 @@ function isSameOriginWithAncestors() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function isLocationBitwardenVault(activeUserSettings: Record<string, any>) {
|
||||||
|
return window.location.origin === activeUserSettings.serverConfig.environment.vault;
|
||||||
|
}
|
||||||
|
|
||||||
function initializeFido2ContentScript() {
|
function initializeFido2ContentScript() {
|
||||||
const s = document.createElement("script");
|
const s = document.createElement("script");
|
||||||
s.src = chrome.runtime.getURL("content/fido2/page-script.js");
|
s.src = chrome.runtime.getURL("content/fido2/page-script.js");
|
||||||
@ -132,9 +140,21 @@ function initializeFido2ContentScript() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function run() {
|
async function run() {
|
||||||
if ((await hasActiveUser()) && (await isFido2FeatureEnabled()) && !(await isDomainExcluded())) {
|
if (!(await hasActiveUser())) {
|
||||||
initializeFido2ContentScript();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const activeUserSettings = await getActiveUserSettings();
|
||||||
|
if (
|
||||||
|
activeUserSettings == null ||
|
||||||
|
!(await isFido2FeatureEnabled()) ||
|
||||||
|
(await isDomainExcluded(activeUserSettings)) ||
|
||||||
|
(await isLocationBitwardenVault(activeUserSettings))
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
initializeFido2ContentScript();
|
||||||
}
|
}
|
||||||
|
|
||||||
run();
|
run();
|
||||||
|
Loading…
Reference in New Issue
Block a user