1 import type { APP_NAMES } from '../constants';
2 import { APPS } from '../constants';
3 import { isElectronApp } from '../helpers/desktop';
4 import type { User } from '../interfaces';
5 import { getIsPublicUserWithoutProtonAddress, getIsSSOVPNOnlyAccount } from '../keys';
7 type AppContext = 'dropdown' | 'app';
9 export const getPublicUserProtonAddressApps = (context: AppContext): APP_NAMES[] => {
10 const result: APP_NAMES[] = [APPS.PROTONPASS, APPS.PROTONVPN_SETTINGS, APPS.PROTONDRIVE];
12 // Proton Docs is never shown in the dropdown context, but we still need it in this list to ensure it's an allowed app.
13 if (context === 'app') {
14 result.push(APPS.PROTONDOCS);
20 export const getSSOVPNOnlyAccountApps = (): APP_NAMES[] => {
21 return [APPS.PROTONVPN_SETTINGS];
24 export const getAvailableApps = (options: { user?: User; context: AppContext }) => {
25 if (getIsSSOVPNOnlyAccount(options.user)) {
26 return getSSOVPNOnlyAccountApps();
28 if (getIsPublicUserWithoutProtonAddress(options.user)) {
29 return getPublicUserProtonAddressApps(options.context);
32 return [APPS.PROTONMAIL, APPS.PROTONCALENDAR];
35 const apps: APP_NAMES[] = [
39 APPS.PROTONVPN_SETTINGS,