mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-22 11:45:59 +01:00
[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 { TabMessage } from "../types/tab-messages";
|
||||
|
||||
@ -217,7 +219,7 @@ export class BrowserApi {
|
||||
static reloadOpenWindows() {
|
||||
const views = chrome.extension.getViews() as Window[];
|
||||
views
|
||||
.filter((w) => w.location.href != null)
|
||||
.filter((w) => w.location.href != null && !w.location.href.includes("background.html"))
|
||||
.forEach((w) => {
|
||||
w.location.reload();
|
||||
});
|
||||
@ -253,11 +255,13 @@ export class BrowserApi {
|
||||
return BrowserApi.manifestVersion === 3 ? chrome.action : chrome.browserAction;
|
||||
}
|
||||
|
||||
static getSidebarAction(win: Window & typeof globalThis) {
|
||||
return BrowserPlatformUtilsService.isSafari(win)
|
||||
? null
|
||||
: typeof win.opr !== "undefined" && win.opr.sidebarAction
|
||||
? win.opr.sidebarAction
|
||||
: win.chrome.sidebarAction;
|
||||
static getSidebarAction(
|
||||
win: Window & typeof globalThis
|
||||
): OperaSidebarAction | FirefoxSidebarAction | null {
|
||||
const deviceType = BrowserPlatformUtilsService.getDevice(win);
|
||||
if (deviceType !== DeviceType.FirefoxExtension && deviceType !== DeviceType.OperaExtension) {
|
||||
return null;
|
||||
}
|
||||
return win.opr?.sidebarAction || browser.sidebarAction;
|
||||
}
|
||||
}
|
||||
|
14
apps/browser/src/globals.d.ts
vendored
14
apps/browser/src/globals.d.ts
vendored
@ -105,25 +105,13 @@ type OperaSidebarAction = {
|
||||
*
|
||||
* @link https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/sidebarAction
|
||||
*/
|
||||
type FirefoxSidebarAction = Omit<
|
||||
OperaSidebarAction,
|
||||
| "setBadgeText"
|
||||
| "getBadgeText"
|
||||
| "setBadgeBackgroundColor"
|
||||
| "getBadgeBackgroundColor"
|
||||
| "onFocus"
|
||||
| "onBlur"
|
||||
>;
|
||||
type FirefoxSidebarAction = typeof browser.sidebarAction;
|
||||
|
||||
type Opera = {
|
||||
addons: OperaAddons;
|
||||
sidebarAction: OperaSidebarAction;
|
||||
};
|
||||
|
||||
declare namespace chrome {
|
||||
let sidebarAction: FirefoxSidebarAction | undefined;
|
||||
}
|
||||
|
||||
interface Window {
|
||||
opr: Opera | undefined;
|
||||
opera: unknown;
|
||||
|
@ -220,10 +220,12 @@ export class UpdateBadge {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.useSyncApiCalls) {
|
||||
this.sidebarAction.setIcon(options);
|
||||
if (this.isOperaSidebar(this.sidebarAction)) {
|
||||
await new Promise<void>((resolve) =>
|
||||
(this.sidebarAction as OperaSidebarAction).setIcon(options, () => resolve())
|
||||
);
|
||||
} 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;
|
||||
}
|
||||
|
||||
const sidebarView = this.sidebarViewName();
|
||||
const sidebarOpen =
|
||||
sidebarView != null && chrome.extension.getViews({ type: sidebarView }).length > 0;
|
||||
if (sidebarOpen) {
|
||||
// Opera has "sidebar_panel" as a ViewType but doesn't currently work
|
||||
if (this.isFirefox() && chrome.extension.getViews({ type: "sidebar" }).length > 0) {
|
||||
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;
|
||||
return tabOpen;
|
||||
}
|
||||
@ -326,16 +325,6 @@ export default class BrowserPlatformUtilsService implements PlatformUtilsService
|
||||
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 {
|
||||
return false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user