Merge branch 'feat/inda-383-daily-stat' into 'main'
[ProtonMail-WebClient.git] / packages / shared / lib / interfaces / User.ts
blob35ba0c0e0ab88b9fe98bb3ff118a27e2a92e3c59
1 import type { Currency, UNPAID_STATE } from '@proton/payments';
3 import type { USER_ROLES } from '../constants';
4 import type { Key } from './Key';
6 export enum MNEMONIC_STATUS {
7     DISABLED = 0,
8     ENABLED = 1,
9     OUTDATED = 2,
10     SET = 3,
11     PROMPT = 4,
14 export enum UserType {
15     PROTON = 1,
16     MANAGED = 2,
17     EXTERNAL = 3,
20 export enum SessionRecoveryState {
21     NONE = 0,
22     GRACE_PERIOD = 1,
23     CANCELLED = 2,
24     INSECURE = 3,
25     EXPIRED = 4,
28 export enum SessionRecoveryReason {
29     NONE = 0,
30     CANCELLED = 1,
31     AUTHENTICATION = 2,
34 export enum ChargebeeEnabled {
35     INHOUSE_FORCED = 0,
36     CHARGEBEE_ALLOWED = 1,
37     CHARGEBEE_FORCED = 2,
40 export type ChargebeeUserExists = number;
42 export enum UserLockedFlags {
43     BASE_STORAGE_EXCEEDED = 1,
44     DRIVE_STORAGE_EXCEEDED = 2,
45     STORAGE_EXCEEDED = BASE_STORAGE_EXCEEDED | DRIVE_STORAGE_EXCEEDED,
46     ORG_ISSUE_FOR_PRIMARY_ADMIN = 4,
47     ORG_ISSUE_FOR_MEMBER = 8,
50 export interface User {
51     ID: string;
52     Name: string;
53     UsedSpace: number;
54     UsedBaseSpace: number;
55     UsedDriveSpace: number;
56     Currency: Currency;
57     Credit: number;
58     MaxSpace: number;
59     MaxBaseSpace: number;
60     MaxDriveSpace: number;
61     MaxUpload: number;
62     NumAI: number;
63     Role: USER_ROLES;
64     Private: number;
65     Type: UserType;
66     Subscribed: number;
67     Services: number;
68     Delinquent: UNPAID_STATE;
69     Email: string;
70     DisplayName: string;
71     OrganizationPrivateKey?: string;
72     Keys: Key[];
73     DriveEarlyAccess: number;
74     ToMigrate: 0 | 1;
75     MnemonicStatus: MNEMONIC_STATUS;
76     ProductUsedSpace: {
77         Calendar: number;
78         Contact: number;
79         Drive: number;
80         Mail: number;
81         Pass: number;
82     };
83     Idle: 0 | 1;
84     CreateTime: number;
85     Flags: {
86         protected: boolean;
87         'drive-early-access': boolean;
88         'onboard-checklist-storage-granted': boolean;
89         'has-temporary-password': boolean;
90         'test-account': boolean;
91         'no-login': boolean;
92         'no-proton-address': boolean;
93         'recovery-attempt': boolean;
94         'pass-lifetime': boolean;
95         sso: boolean;
96     };
97     AccountRecovery: {
98         State: SessionRecoveryState;
99         StartTime: number;
100         EndTime: number;
101         Reason: SessionRecoveryReason | null;
102         UID: string;
103     } | null;
104     ChargebeeUser: ChargebeeEnabled;
105     LockedFlags?: number;
106     Billed?: boolean;
107     ChargebeeUserExists?: ChargebeeUserExists;
110 export function isBilledUser(user: User | undefined): boolean {
111     if (!user) {
112         return false;
113     }
115     return !!user.Billed;
118 export interface UserModel extends User {
119     isAdmin: boolean;
120     isMember: boolean;
121     isFree: boolean;
122     isPaid: boolean;
123     isPrivate: boolean;
124     isSubUser: boolean;
125     isDelinquent: boolean;
126     hasNonDelinquentScope: boolean;
127     hasPaidMail: boolean;
128     hasPaidVpn: boolean;
129     hasPaidDrive: boolean;
130     hasPaidPass: boolean;
131     hasPassLifetime: boolean;
132     canPay: boolean;