[PM-1389] Fix SSO failure when vault timeout set to "Log Out" (#5286)
* [PM-1389] don't include background page while reloading windows * [PM-1389] update sidebar action apis * [PM-1389] simplify return from getSidebarAction * [PM-1380] fix device type call after browser api change
This commit is contained in:
parent
de6e0c8c3d
commit
4ece57be34
|
@ -1,3 +1,5 @@
|
||||||
|
import { DeviceType } from "@bitwarden/common/enums/device-type.enum";
|
||||||
|
|
||||||
import BrowserPlatformUtilsService from "../services/browserPlatformUtils.service";
|
import BrowserPlatformUtilsService from "../services/browserPlatformUtils.service";
|
||||||
import { TabMessage } from "../types/tab-messages";
|
import { TabMessage } from "../types/tab-messages";
|
||||||
|
|
||||||
|
@ -217,7 +219,7 @@ export class BrowserApi {
|
||||||
static reloadOpenWindows() {
|
static reloadOpenWindows() {
|
||||||
const views = chrome.extension.getViews() as Window[];
|
const views = chrome.extension.getViews() as Window[];
|
||||||
views
|
views
|
||||||
.filter((w) => w.location.href != null)
|
.filter((w) => w.location.href != null && !w.location.href.includes("background.html"))
|
||||||
.forEach((w) => {
|
.forEach((w) => {
|
||||||
w.location.reload();
|
w.location.reload();
|
||||||
});
|
});
|
||||||
|
@ -253,11 +255,13 @@ export class BrowserApi {
|
||||||
return BrowserApi.manifestVersion === 3 ? chrome.action : chrome.browserAction;
|
return BrowserApi.manifestVersion === 3 ? chrome.action : chrome.browserAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
static getSidebarAction(win: Window & typeof globalThis) {
|
static getSidebarAction(
|
||||||
return BrowserPlatformUtilsService.isSafari(win)
|
win: Window & typeof globalThis
|
||||||
? null
|
): OperaSidebarAction | FirefoxSidebarAction | null {
|
||||||
: typeof win.opr !== "undefined" && win.opr.sidebarAction
|
const deviceType = BrowserPlatformUtilsService.getDevice(win);
|
||||||
? win.opr.sidebarAction
|
if (deviceType !== DeviceType.FirefoxExtension && deviceType !== DeviceType.OperaExtension) {
|
||||||
: win.chrome.sidebarAction;
|
return null;
|
||||||
|
}
|
||||||
|
return win.opr?.sidebarAction || browser.sidebarAction;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,25 +105,13 @@ type OperaSidebarAction = {
|
||||||
*
|
*
|
||||||
* @link https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/sidebarAction
|
* @link https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/sidebarAction
|
||||||
*/
|
*/
|
||||||
type FirefoxSidebarAction = Omit<
|
type FirefoxSidebarAction = typeof browser.sidebarAction;
|
||||||
OperaSidebarAction,
|
|
||||||
| "setBadgeText"
|
|
||||||
| "getBadgeText"
|
|
||||||
| "setBadgeBackgroundColor"
|
|
||||||
| "getBadgeBackgroundColor"
|
|
||||||
| "onFocus"
|
|
||||||
| "onBlur"
|
|
||||||
>;
|
|
||||||
|
|
||||||
type Opera = {
|
type Opera = {
|
||||||
addons: OperaAddons;
|
addons: OperaAddons;
|
||||||
sidebarAction: OperaSidebarAction;
|
sidebarAction: OperaSidebarAction;
|
||||||
};
|
};
|
||||||
|
|
||||||
declare namespace chrome {
|
|
||||||
let sidebarAction: FirefoxSidebarAction | undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Window {
|
interface Window {
|
||||||
opr: Opera | undefined;
|
opr: Opera | undefined;
|
||||||
opera: unknown;
|
opera: unknown;
|
||||||
|
|
|
@ -220,10 +220,12 @@ export class UpdateBadge {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.useSyncApiCalls) {
|
if (this.isOperaSidebar(this.sidebarAction)) {
|
||||||
this.sidebarAction.setIcon(options);
|
await new Promise<void>((resolve) =>
|
||||||
|
(this.sidebarAction as OperaSidebarAction).setIcon(options, () => resolve())
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
await new Promise<void>((resolve) => this.sidebarAction.setIcon(options, () => resolve()));
|
await this.sidebarAction.setIcon(options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -159,13 +159,12 @@ export default class BrowserPlatformUtilsService implements PlatformUtilsService
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const sidebarView = this.sidebarViewName();
|
// Opera has "sidebar_panel" as a ViewType but doesn't currently work
|
||||||
const sidebarOpen =
|
if (this.isFirefox() && chrome.extension.getViews({ type: "sidebar" }).length > 0) {
|
||||||
sidebarView != null && chrome.extension.getViews({ type: sidebarView }).length > 0;
|
|
||||||
if (sidebarOpen) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Opera sidebar has type of "tab" (will stick around for a while after closing sidebar)
|
||||||
const tabOpen = chrome.extension.getViews({ type: "tab" }).length > 0;
|
const tabOpen = chrome.extension.getViews({ type: "tab" }).length > 0;
|
||||||
return tabOpen;
|
return tabOpen;
|
||||||
}
|
}
|
||||||
|
@ -326,16 +325,6 @@ export default class BrowserPlatformUtilsService implements PlatformUtilsService
|
||||||
return this.biometricCallback();
|
return this.biometricCallback();
|
||||||
}
|
}
|
||||||
|
|
||||||
sidebarViewName(): string {
|
|
||||||
if (this.win.chrome.sidebarAction && this.isFirefox()) {
|
|
||||||
return "sidebar";
|
|
||||||
} else if (this.isOpera() && typeof opr !== "undefined" && opr.sidebarAction) {
|
|
||||||
return "sidebar_panel";
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
supportsSecureStorage(): boolean {
|
supportsSecureStorage(): boolean {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue