// Metro module 13775 (f13776). import MFAStore from "../stores/MFAStore"; import { Endpoints } from "../Constants"; import { HTTP, rejectWithMigratedError } from "../_bundle/sendRequest"; import Dispatcher from "../Dispatcher"; const r18 = { enable: (a0) => HTTP.post({ url: Endpoints.MFA_TOTP_ENABLE, body: { code: a0.code, secret: a0.secret }, oldFormErrors: true, rejectWithError: rejectWithMigratedError() }).then((result) => Dispatcher.dispatch({ type: "MFA_ENABLE_SUCCESS", token: result.body.token, codes: result.body.backup_codes })), disable: () => { HTTP.post({ url: Endpoints.MFA_TOTP_DISABLE, oldFormErrors: true, rejectWithError: rejectWithMigratedError() }).then((result) => Dispatcher.dispatch({ type: "MFA_DISABLE_SUCCESS", token: result.body.token })); }, enableSMS: () => { Dispatcher.dispatch({ type: "MFA_SMS_TOGGLE" }); return HTTP.post({ url: Endpoints.MFA_SMS_ENABLE, oldFormErrors: true, rejectWithError: rejectWithMigratedError() }).then((result) => { Dispatcher.dispatch({ type: "MFA_SMS_TOGGLE_COMPLETE" }); return result; }, (a0) => { Dispatcher.dispatch({ type: "MFA_SMS_TOGGLE_COMPLETE" }); throw a0; }); }, disableSMS: (a0) => { Dispatcher.dispatch({ type: "MFA_SMS_TOGGLE" }); return HTTP.post({ url: Endpoints.MFA_SMS_DISABLE, body: { password: a0 }, oldFormErrors: true, rejectWithError: rejectWithMigratedError() }).then((result) => { Dispatcher.dispatch({ type: "MFA_SMS_TOGGLE_COMPLETE" }); return result; }, (a0) => { Dispatcher.dispatch({ type: "MFA_SMS_TOGGLE_COMPLETE" }); throw a0; }); }, sendMFABackupCodesVerificationKeyEmail: (a0) => HTTP.post({ url: Endpoints.MFA_SEND_VERIFICATION_KEY, body: { password: a0 }, oldFormErrors: true, rejectWithError: rejectWithMigratedError() }).then((result) => Dispatcher.dispatch({ type: "MFA_SEND_VERIFICATION_KEY", nonces: { viewNonce: result.body.nonce, regenerateNonce: result.body.regenerate_nonce } }), (a0) => { throw a0; }), confirmViewBackupCodes: (a0, a1) => { const key = a0; const nonces = MFAStore.getNonces(); let viewNonce = nonces.viewNonce; const regenerateNonce = nonces.regenerateNonce; if (a1) { viewNonce = regenerateNonce; } return HTTP.post({ url: Endpoints.MFA_CODES_VERIFICATION, body: { key: a0, nonce: viewNonce, regenerate: a1 }, oldFormErrors: true, rejectWithError: rejectWithMigratedError() }).then((result) => Dispatcher.dispatch({ type: "MFA_VIEW_BACKUP_CODES", codes: result.body.backup_codes, key }), (a0) => { throw a0; }); }, clearBackupCodes: () => { Dispatcher.dispatch({ type: "MFA_CLEAR_BACKUP_CODES" }); } }; export default r18;