1 import type { DENSITY } from '@proton/shared/lib/constants';
2 import type { NewsletterSubscriptionUpdateData } from '@proton/shared/lib/helpers/newsletter';
7 SETTINGS_LOG_AUTH_STATE,
10 } from '@proton/shared/lib/interfaces';
11 import type { ThemeSetting, ThemeTypes } from '@proton/shared/lib/themes/themes';
13 import type { RegistrationOptions } from '../../lib/webauthn/interface';
15 export const TOTP_WRONG_ERROR = 12060;
17 export const getSettings = () => ({
18 url: 'core/v4/settings',
22 export const updateUsername = (data: { Username: string }) => ({
23 url: 'core/v4/settings/username',
28 export const updatePassword = (data: { PersistPasswordScope: boolean }) => ({
29 url: 'core/v4/settings/password',
34 export const upgradePassword = () => ({
35 url: 'core/v4/settings/password/upgrade',
39 export const updateLocale = (Locale: string) => ({
40 url: 'core/v4/settings/locale',
45 export const getNews = () => ({
46 url: 'core/v4/settings/news',
50 export const patchNews = (data: NewsletterSubscriptionUpdateData) => ({
51 url: 'core/v4/settings/news',
56 export const getNewsExternal = () => ({
57 url: 'core/v4/settings/news/external',
61 export const patchNewsExternal = (data: NewsletterSubscriptionUpdateData) => ({
62 url: 'core/v4/settings/news/external',
67 export const updateInvoiceText = (InvoiceText: string) => ({
68 url: 'core/v4/settings/invoicetext',
70 data: { InvoiceText },
73 export const updateLogAuth = (LogAuth: SETTINGS_LOG_AUTH_STATE) => ({
74 url: 'core/v4/settings/logauth',
79 export const enableHighSecurity = () => ({
80 url: 'core/v4/settings/highsecurity',
85 export const disableHighSecurity = () => ({
86 url: 'core/v4/settings/highsecurity',
91 export const updateDensity = (Density: DENSITY) => ({
92 url: 'core/v4/settings/density',
97 export const updateEmail = (data: { Email: string; PersistPasswordScope?: boolean }) => ({
98 url: 'core/v4/settings/email',
103 export const updateNotifyEmail = (Notify: number) => ({
104 url: 'core/v4/settings/email/notify',
109 export const updateResetEmail = (data: { Reset: number; PersistPasswordScope?: boolean }) => ({
110 url: 'core/v4/settings/email/reset',
115 export const verifyEmail = (Token: string) => ({
116 url: 'core/v4/settings/email/verify',
121 export const updatePhone = (data: { Phone: string; PersistPasswordScope?: boolean }) => ({
122 url: 'core/v4/settings/phone',
127 export const updateNotifyPhone = (Notify: string) => ({
128 url: 'core/v4/settings/phone/notify',
133 export const updateResetPhone = (data: { Reset: number; PersistPasswordScope?: boolean }) => ({
134 url: 'core/v4/settings/phone/reset',
139 export const verifyPhone = (Token: string) => ({
140 url: 'core/v4/settings/phone/verify',
145 export const registerSecurityKey = (data: {
146 RegistrationOptions: RegistrationOptions;
148 AttestationObject: string;
149 Transports: string[];
152 url: 'core/v4/settings/2fa/register',
157 export const getSecurityKeyChallenge = (crossPlatform: boolean) => ({
158 url: 'core/v4/settings/2fa/register',
161 CrossPlatform: +crossPlatform,
165 export const removeSecurityKey = (credentialID: string, data: { PersistPasswordScope?: boolean } = {}) => ({
166 url: `core/v4/settings/2fa/${credentialID}/remove`,
171 export const renameSecurityKey = (credentialID: string, data: { Name: string }) => ({
172 url: `core/v4/settings/2fa/${credentialID}/rename`,
177 export const setupTotp = (TOTPSharedSecret: string, TOTPConfirmation: string) => ({
178 url: 'core/v4/settings/2fa/totp',
180 data: { TOTPSharedSecret, TOTPConfirmation },
183 export const disableTotp = () => ({
184 url: 'core/v4/settings/2fa/totp',
188 export const disable2FA = (data?: { PersistPasswordScope?: boolean }) => ({
189 url: 'core/v4/settings/2fa',
194 export const updateHideDrawer = (HideSidePanel: DRAWER_VISIBILITY) => ({
195 url: 'core/v4/settings/hide-side-panel',
197 data: { HideSidePanel },
200 export const updateTheme = (data: ThemeSetting) => ({
201 url: 'core/v4/settings/theme',
206 export const updateThemeType = (ThemeType: ThemeTypes) => ({
207 url: 'core/v4/settings/themetype',
212 export const updateWeekStart = (WeekStart: SETTINGS_WEEK_START) => ({
213 url: 'core/v4/settings/weekstart',
218 export const updateDateFormat = (DateFormat: SETTINGS_DATE_FORMAT) => ({
219 url: 'core/v4/settings/dateformat',
221 data: { DateFormat },
224 export const updateTimeFormat = (TimeFormat: SETTINGS_TIME_FORMAT) => ({
225 url: 'core/v4/settings/timeformat',
227 data: { TimeFormat },
230 export const updateWelcomeFlags = () => ({
231 url: 'core/v4/settings/welcome',
235 export const updateEarlyAccess = (data: { EarlyAccess: number }) => ({
236 url: 'core/v4/settings/earlyaccess',
241 export const updateFlags = (data: { Welcomed: number }) => ({
242 url: 'core/v4/settings/flags',
247 export const updateTelemetry = (data: { Telemetry: number }) => ({
248 url: 'core/v4/settings/telemetry',
253 export const updateCrashReports = (data: { CrashReports: number }) => ({
254 url: 'core/v4/settings/crashreports',
259 export const getBreaches = () => ({
260 url: 'account/v4/breaches',
264 export const getRecentBreaches = () => ({
265 url: 'account/v4/breaches?Recent=true',
269 export const enableBreachAlert = () => ({
270 url: 'core/v4/settings/breachalerts',
275 export const setProductDisabled = (data: { Product: number; Disabled: 1 | 0 }) => ({
276 url: 'core/v4/settings/product-disabled',
281 export const disableBreachAlert = () => ({
282 url: 'core/v4/settings/breachalerts',
287 export const updateAIAssistant = (AIAssistantFlags: AI_ASSISTANT_ACCESS) => ({
288 url: 'core/v4/settings/ai-assistant-flags',
290 data: { AIAssistantFlags },