1 import type { DENSITY, NEWSLETTER_SUBSCRIPTIONS } from '@proton/shared/lib/constants';
6 SETTINGS_LOG_AUTH_STATE,
9 } from '@proton/shared/lib/interfaces';
10 import type { ThemeSetting, ThemeTypes } from '@proton/shared/lib/themes/themes';
12 import type { RegistrationOptions } from '../../lib/webauthn/interface';
14 export const TOTP_WRONG_ERROR = 12060;
16 export const getSettings = () => ({
17 url: 'core/v4/settings',
21 export const updateUsername = (data: { Username: string }) => ({
22 url: 'core/v4/settings/username',
27 export const updatePassword = (data: { PersistPasswordScope: boolean }) => ({
28 url: 'core/v4/settings/password',
33 export const upgradePassword = () => ({
34 url: 'core/v4/settings/password/upgrade',
38 export const updateLocale = (Locale: string) => ({
39 url: 'core/v4/settings/locale',
44 export const getNews = () => ({
45 url: 'core/v4/settings/news',
49 export const patchNews = (data: Partial<Record<NEWSLETTER_SUBSCRIPTIONS, boolean>>) => ({
50 url: 'core/v4/settings/news',
55 export const getNewsExternal = () => ({
56 url: 'core/v4/settings/news/external',
60 export const patchNewsExternal = (data: Partial<Record<NEWSLETTER_SUBSCRIPTIONS, boolean>>) => ({
61 url: 'core/v4/settings/news/external',
66 export const updateInvoiceText = (InvoiceText: string) => ({
67 url: 'core/v4/settings/invoicetext',
69 data: { InvoiceText },
72 export const updateLogAuth = (LogAuth: SETTINGS_LOG_AUTH_STATE) => ({
73 url: 'core/v4/settings/logauth',
78 export const enableHighSecurity = () => ({
79 url: 'core/v4/settings/highsecurity',
84 export const disableHighSecurity = () => ({
85 url: 'core/v4/settings/highsecurity',
90 export const updateDensity = (Density: DENSITY) => ({
91 url: 'core/v4/settings/density',
96 export const updateEmail = (data: { Email: string; PersistPasswordScope?: boolean }) => ({
97 url: 'core/v4/settings/email',
102 export const updateNotifyEmail = (Notify: number) => ({
103 url: 'core/v4/settings/email/notify',
108 export const updateResetEmail = (data: { Reset: number; PersistPasswordScope?: boolean }) => ({
109 url: 'core/v4/settings/email/reset',
114 export const verifyEmail = (Token: string) => ({
115 url: 'core/v4/settings/email/verify',
120 export const updatePhone = (data: { Phone: string; PersistPasswordScope?: boolean }) => ({
121 url: 'core/v4/settings/phone',
126 export const updateNotifyPhone = (Notify: string) => ({
127 url: 'core/v4/settings/phone/notify',
132 export const updateResetPhone = (data: { Reset: number; PersistPasswordScope?: boolean }) => ({
133 url: 'core/v4/settings/phone/reset',
138 export const verifyPhone = (Token: string) => ({
139 url: 'core/v4/settings/phone/verify',
144 export const registerSecurityKey = (data: {
145 RegistrationOptions: RegistrationOptions;
147 AttestationObject: string;
148 Transports: string[];
151 url: 'core/v4/settings/2fa/register',
156 export const getSecurityKeyChallenge = (crossPlatform: boolean) => ({
157 url: 'core/v4/settings/2fa/register',
160 CrossPlatform: +crossPlatform,
164 export const removeSecurityKey = (credentialID: string) => ({
165 url: `core/v4/settings/2fa/${credentialID}/remove`,
169 export const renameSecurityKey = (credentialID: string, data: { Name: string }) => ({
170 url: `core/v4/settings/2fa/${credentialID}/rename`,
175 export const setupTotp = (TOTPSharedSecret: string, TOTPConfirmation: string) => ({
176 url: 'core/v4/settings/2fa/totp',
178 data: { TOTPSharedSecret, TOTPConfirmation },
181 export const disableTotp = () => ({
182 url: 'core/v4/settings/2fa/totp',
186 export const disable2FA = () => ({
187 url: 'core/v4/settings/2fa',
191 export const updateHideDrawer = (HideSidePanel: DRAWER_VISIBILITY) => ({
192 url: 'core/v4/settings/hide-side-panel',
194 data: { HideSidePanel },
197 export const updateTheme = (data: ThemeSetting) => ({
198 url: 'core/v4/settings/theme',
203 export const updateThemeType = (ThemeType: ThemeTypes) => ({
204 url: 'core/v4/settings/themetype',
209 export const updateWeekStart = (WeekStart: SETTINGS_WEEK_START) => ({
210 url: 'core/v4/settings/weekstart',
215 export const updateDateFormat = (DateFormat: SETTINGS_DATE_FORMAT) => ({
216 url: 'core/v4/settings/dateformat',
218 data: { DateFormat },
221 export const updateTimeFormat = (TimeFormat: SETTINGS_TIME_FORMAT) => ({
222 url: 'core/v4/settings/timeformat',
224 data: { TimeFormat },
227 export const updateWelcomeFlags = () => ({
228 url: 'core/v4/settings/welcome',
232 export const updateEarlyAccess = (data: { EarlyAccess: number }) => ({
233 url: 'core/v4/settings/earlyaccess',
238 export const updateFlags = (data: { Welcomed: number }) => ({
239 url: 'core/v4/settings/flags',
244 export const updateTelemetry = (data: { Telemetry: number }) => ({
245 url: 'core/v4/settings/telemetry',
250 export const updateCrashReports = (data: { CrashReports: number }) => ({
251 url: 'core/v4/settings/crashreports',
256 export const getBreaches = () => ({
257 url: 'account/v4/breaches',
261 export const getRecentBreaches = () => ({
262 url: 'account/v4/breaches?Recent=true',
266 export const enableBreachAlert = () => ({
267 url: 'core/v4/settings/breachalerts',
272 export const setProductDisabled = (data: { Product: number; Disabled: 1 | 0 }) => ({
273 url: 'core/v4/settings/product-disabled',
278 export const disableBreachAlert = () => ({
279 url: 'core/v4/settings/breachalerts',
284 export const updateAIAssistant = (AIAssistantFlags: AI_ASSISTANT_ACCESS) => ({
285 url: 'core/v4/settings/ai-assistant-flags',
287 data: { AIAssistantFlags },