Update selected item color in Pass menu
[ProtonMail-WebClient.git] / packages / pass / lib / client / index.ts
blob357ce1c2dfac64803779c50bbc0d9ed7e79077a3
1 /**
2  * Be very careful when editing these predicates :
3  * They are used accross the worker code-base in order
4  * to safe-guard certain actions or block them. Some
5  * of them are also used in the UI code to trigger
6  * certain effects.
7  */
8 import type { PassConfig } from '@proton/pass/hooks/usePassConfig';
9 import { AppStatus } from '@proton/pass/types';
10 import { eq, oneOf, or } from '@proton/pass/utils/fp/predicates';
12 export const clientAuthorized = eq(AppStatus.AUTHORIZED);
13 export const clientErrored = eq(AppStatus.ERROR);
14 export const clientOffline = eq(AppStatus.OFFLINE);
15 export const clientPasswordLocked = oneOf(AppStatus.PASSWORD_LOCKED, AppStatus.BIOMETRICS_LOCKED);
16 export const clientReady = eq(AppStatus.READY);
17 export const clientSessionLocked = eq(AppStatus.SESSION_LOCKED);
18 export const clientStale = eq(AppStatus.IDLE);
19 export const clientUnauthorized = eq(AppStatus.UNAUTHORIZED);
20 export const clientMissingScope = eq(AppStatus.MISSING_SCOPE);
22 export const clientBusy = oneOf(AppStatus.IDLE, AppStatus.AUTHORIZED, AppStatus.AUTHORIZING, AppStatus.BOOTING);
23 export const clientBooted = oneOf(AppStatus.READY, AppStatus.OFFLINE);
25 export const clientCanBoot = or(clientAuthorized, clientUnauthorized, clientErrored);
26 export const clientHasSession = or(clientBooted, clientSessionLocked, clientPasswordLocked);
27 export const clientNeedsSession = or(clientErrored, clientUnauthorized, clientMissingScope);
28 export const clientStatusResolved = or(clientHasSession, clientNeedsSession);
29 export const clientDisabled = or(clientUnauthorized, clientErrored, clientStale);
30 export const clientLocked = or(clientSessionLocked, clientPasswordLocked, clientMissingScope);
32 export const isTaggedBuild = (config: PassConfig) => ENV === 'production' && config.BRANCH.startsWith('proton-pass@');