1 import { PASS_CHROME_URL, PASS_FIREFOX_URL } from '@proton/pass/constants';
2 import { type MaybeNull } from '@proton/pass/types';
3 import type { Browser } from '@proton/pass/types/browser';
4 import { isBrave, isChrome, isEdge } from '@proton/shared/lib/helpers/browser';
5 import { Clients } from '@proton/shared/lib/pass/constants';
7 const global = globalThis as any;
9 /* Based on https://github.com/mozilla/webextension-polyfill Chrome check */
10 export const detectBrowser = (): Browser =>
11 typeof global.browser === 'undefined' || Object.getPrototypeOf(global.browser) !== Object.prototype
15 export const getWebStoreUrl = (): string => ({ chrome: PASS_CHROME_URL, firefox: PASS_FIREFOX_URL })[detectBrowser()];
17 export type SupportedExtensionClient = Clients.Chrome | Clients.Brave | Clients.Edge | Clients.Firefox;
19 export const getExtensionSupportedBrowser = (): MaybeNull<SupportedExtensionClient> => {
20 if (isChrome()) return Clients.Chrome;
21 if (isBrave()) return Clients.Brave;
22 if (isEdge()) return Clients.Edge;
23 // TEMP disable FF if (isFirefox()) return Clients.Firefox;