@alphapoint/apex-web 5.7.0 → 5.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/lib/apex.integration.test.js +435 -0
  2. package/lib/apex.js +37 -1
  3. package/lib/apex.test.js +138 -0
  4. package/lib/components/2FA/PasskeyOption.js +126 -0
  5. package/lib/components/2FA/TwoFactorAuthComponent.js +24 -5
  6. package/lib/components/2FA/TwoFactorAuthComponent.test.js +94 -0
  7. package/lib/components/2FA/TwoFactorAuthContainer.js +94 -16
  8. package/lib/components/2FA/TwoFactorAuthContainer.test.js +412 -0
  9. package/lib/components/ConfirmBlockTradeModal/ConfirmBlockTradeModalContainer.js +34 -6
  10. package/lib/components/ConfirmBlockTradeModal/ConfirmBlockTradeModalContainer.test.js +298 -0
  11. package/lib/components/ConfirmOrderModal/ConfirmOrderModalComponent.js +26 -4
  12. package/lib/components/ConfirmOrderModal/ConfirmOrderModalContainer.js +4 -1
  13. package/lib/components/EnableTwoFactorAuth/Disable2FAForm.js +22 -7
  14. package/lib/components/EnableTwoFactorAuth/Disable2FAModal.js +15 -5
  15. package/lib/components/EnableTwoFactorAuth/Disable2FAModal.test.js +460 -0
  16. package/lib/components/EnableTwoFactorAuth/Disable2FAModalContainer.js +108 -16
  17. package/lib/components/EnableTwoFactorAuth/EnableTwoFactorAuthContainerFactory.js +3 -2
  18. package/lib/components/FusionAuth/UnlinkOAuthIdentityModal.css +13 -0
  19. package/lib/components/FusionAuth/UnlinkOAuthIdentityModal.js +246 -0
  20. package/lib/components/FusionAuth/UnlinkOAuthIdentityModal.test.js +521 -0
  21. package/lib/components/Login/LoginFormComponent.js +1 -1
  22. package/lib/components/OrderEntryComponents/advancedForm/AdvancedOrderFormContainer.js +2 -0
  23. package/lib/components/OrderEntryComponents/common/FormAmountFields.js +5 -0
  24. package/lib/components/OrderEntryComponents/common/TwapScheduleFields.js +98 -0
  25. package/lib/components/OrderEntryComponents/defaultForm/OrderEntryAnchoring.js +86 -39
  26. package/lib/components/OrderEntryComponents/defaultForm/OrderEntryAnchoring.test.js +326 -0
  27. package/lib/components/OrderEntryComponents/defaultForm/OrderEntryContainer.js +10 -2
  28. package/lib/components/OrderHistoryComponents/DepositsStatus/DepositsStatusComponent.js +1 -1
  29. package/lib/components/OrderHistoryComponents/DepositsStatus/DepositsStatusComponent.test.js +99 -0
  30. package/lib/components/OrderHistoryComponents/InactiveOrders/InactiveOrdersComponent.js +1 -1
  31. package/lib/components/OrderHistoryComponents/OpenOrders/OpenOrdersComponent.js +1 -1
  32. package/lib/components/OrderHistoryComponents/WithdrawStatus/WithdrawStatusComponent.js +1 -1
  33. package/lib/components/OrderHistoryComponents/WithdrawStatus/WithdrawStatusComponent.test.js +113 -0
  34. package/lib/components/Settings/ProfileAndSecurity/PasskeysSettingsCard/PasskeysSettingsCard.css +108 -0
  35. package/lib/components/Settings/ProfileAndSecurity/PasskeysSettingsCard/PasskeysSettingsCard.test.js +983 -0
  36. package/lib/components/Settings/ProfileAndSecurity/PasskeysSettingsCard/PasskeysSettingsCardComponent.js +500 -0
  37. package/lib/components/Settings/ProfileAndSecurity/PasskeysSettingsCard/index.js +9 -0
  38. package/lib/components/Settings/ProfileAndSecurity/ProfileSettingsCard/ProfileForm/SsoLinkRowComponent.css +4 -0
  39. package/lib/components/Settings/ProfileAndSecurity/ProfileSettingsCard/ProfileForm/SsoLinkRowComponent.js +29 -17
  40. package/lib/components/Settings/ProfileAndSecurity/ProfileSettingsCard/ProfileForm/SsoLinkRowComponent.test.js +135 -0
  41. package/lib/components/Settings/ProfileAndSecurity/TwoFactorAuthSettingsCard/EnableTwoFactorAuth/EnableTwoFactorAuthComponent.test.js +23 -1
  42. package/lib/components/TwoFactorAuthForm/TwoFactorAuthForm.test.js +475 -0
  43. package/lib/components/TwoFactorAuthForm/TwoFactorAuthFormComponent.js +26 -5
  44. package/lib/components/TwoFactorAuthForm/TwoFactorAuthFormContainer.js +50 -32
  45. package/lib/components/common/APAutoTabInput/APAutoTabInput.js +5 -2
  46. package/lib/components/common/APSelect/APSelect.js +3 -1
  47. package/lib/config/CONFIG.md +4 -0
  48. package/lib/config/configDefault.json +2 -1
  49. package/lib/constants/sendOrder/orderEntryFormConstants.js +23 -4
  50. package/lib/constants/sendOrder/timeInForceConstants.js +3 -1
  51. package/lib/constants/sendOrder/twapRejectReasons.js +26 -0
  52. package/lib/helpers/orderHistoryHelper.js +13 -1
  53. package/lib/helpers/orderHistoryHelper.test.js +58 -13
  54. package/lib/helpers/passkeyApi.js +228 -0
  55. package/lib/helpers/passkeyApi.test.js +171 -0
  56. package/lib/helpers/placeOrderHelper.js +76 -61
  57. package/lib/helpers/placeOrderHelper.test.js +169 -10
  58. package/lib/helpers/recalculateOrderHelper.js +4 -1
  59. package/lib/helpers/recalculateOrderHelper.test.js +88 -2
  60. package/lib/helpers/twapOrderHelper.js +265 -0
  61. package/lib/helpers/twapOrderHelper.test.js +467 -0
  62. package/lib/helpers/webauthnHelper.js +300 -0
  63. package/lib/helpers/webauthnHelper.test.js +199 -0
  64. package/lib/hocs/withOneSubmission.js +168 -0
  65. package/lib/redux/actions/apiActions.js +52 -1
  66. package/lib/redux/actions/apiActions.test.js +135 -0
  67. package/lib/redux/actions/authActions.js +514 -198
  68. package/lib/redux/actions/authActions.test.js +627 -47
  69. package/lib/redux/actions/depositActions.js +1 -1
  70. package/lib/redux/actions/depositActions.test.js +100 -30
  71. package/lib/redux/actions/fusionAuthActions.test.js +265 -84
  72. package/lib/redux/actions/modalActions.js +1 -0
  73. package/lib/redux/actions/orderEntryActions.blockTrade.test.js +306 -0
  74. package/lib/redux/actions/orderEntryActions.js +74 -22
  75. package/lib/redux/actions/orderEntryActions.test.js +63 -11
  76. package/lib/redux/actions/orderHistoryActions.js +9 -4
  77. package/lib/redux/actions/orderHistoryActions.test.js +63 -0
  78. package/lib/redux/actions/userActions.js +314 -177
  79. package/lib/redux/actions/userActions.test.js +844 -268
  80. package/lib/redux/margin/actions/marginActions.js +6 -3
  81. package/lib/redux/margin/actions/marginActions.test.js +166 -0
  82. package/lib/redux/middlewares/authMiddleware.js +5 -0
  83. package/lib/redux/middlewares/authMiddleware.test.js +88 -29
  84. package/lib/redux/reducers/authReducer.js +1 -0
  85. package/lib/redux/reducers/authReducer.test.js +38 -0
  86. package/lib/redux/selectors/orderEntrySelector.js +19 -8
  87. package/lib/redux/selectors/orderEntrySelector.test.js +209 -0
  88. package/lib/redux/selectors/orderTotalSelector.test.js +40 -1
  89. package/lib/services/fms/fms.js +2 -0
  90. package/lib/services/fms/fms.test.js +35 -0
  91. package/package.json +4 -4
@@ -4,7 +4,7 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.userInfoFetched = exports.userConfigFetched = exports.updateUserConfig = exports.updateAccount = exports.submitResetPasswordForm = exports.setUserInfo = exports.setUserConfig = exports.setGoogleQrCode = exports.setAccount = exports.sendResetPasswordEmail = exports.selectAccount = exports.resendVerificationEmail = exports.receiveUserPermissions = exports.receiveBaseNotionalProductInfo = exports.receiveAccount = exports.isFuturesAccount = exports.goToResetPasswordFormStep = exports.goToBaseCurrencyFormStep = exports.getUserPermissions = exports.getUserInfo = exports.getUserConfig = exports.getUserAccounts = exports.getGoogleQrCode = exports.getGoogle2FARecoveryCode = exports.enableYubikey2FA = exports.enable2FA = exports.disable2FA = exports.clearGoogleQrCode = exports.accountsLoaded = exports.USER_INFO_FETCHED = exports.USER_CONFIG_FETCHED = exports.UPDATE_ACCOUNT = exports.SET_GOOGLE_QRCODE = exports.SET_ACCOUNT = exports.RECEIVE_USER_PERMISSIONS = exports.RECEIVE_KYC = exports.RECEIVE_BASE_NOTIONAL_PRODUCT_INFO = exports.RECEIVE_ACCOUNT = exports.CLEAR_GOOGLE_QRCODE = exports.ACCOUNTS_LOADED = void 0;
7
+ exports.userInfoFetched = exports.userConfigFetched = exports.updateUserConfig = exports.updateAccount = exports.submitResetPasswordForm = exports.setUserInfo = exports.setUserConfig = exports.setGoogleQrCode = exports.setAccount = exports.sendResetPasswordEmail = exports.selectAccount = exports.resendVerificationEmail = exports.reloadSecondFactorState = exports.receiveUserPermissions = exports.receiveBaseNotionalProductInfo = exports.receiveAccount = exports.isFuturesAccount = exports.goToResetPasswordFormStep = exports.goToBaseCurrencyFormStep = exports.getUserPermissions = exports.getUserInfo = exports.getUserConfig = exports.getUserAccounts = exports.getGoogleQrCode = exports.getGoogle2FARecoveryCode = exports.enableYubikey2FA = exports.enable2FA = exports.disable2FAWithPasskey = exports.disable2FA = exports.clearGoogleQrCode = exports.accountsLoaded = exports.USER_INFO_REFUSED_MESSAGE = exports.USER_INFO_FETCHED = exports.USER_INFO_FAILED_MESSAGE = exports.USER_CONFIG_FETCHED = exports.UPDATE_ACCOUNT = exports.SET_GOOGLE_QRCODE = exports.SET_ACCOUNT = exports.RECEIVE_USER_PERMISSIONS = exports.RECEIVE_KYC = exports.RECEIVE_BASE_NOTIONAL_PRODUCT_INFO = exports.RECEIVE_ACCOUNT = exports.CLEAR_GOOGLE_QRCODE = exports.ACCOUNTS_LOADED = void 0;
8
8
  var _apiActions = require("./apiActions");
9
9
  var _apex = _interopRequireWildcard(require("../../apex"));
10
10
  var _orderHistoryActions = require("./orderHistoryActions");
@@ -34,7 +34,7 @@ var _instrumentActions = require("./instrumentActions");
34
34
  var _instrumentPositionSelectors = require("../selectors/instrumentPositionSelectors");
35
35
  var _selectors2 = require("../futures/selectors");
36
36
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
37
- function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t5 in e) "default" !== _t5 && {}.hasOwnProperty.call(e, _t5) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t5)) && (i.get || i.set) ? o(f, _t5, i) : f[_t5] = e[_t5]); return f; })(e, t); }
37
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t6 in e) "default" !== _t6 && {}.hasOwnProperty.call(e, _t6) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t6)) && (i.get || i.set) ? o(f, _t6, i) : f[_t6] = e[_t6]); return f; })(e, t); }
38
38
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
39
39
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
40
40
  function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
@@ -62,6 +62,11 @@ var SET_GOOGLE_QRCODE = exports.SET_GOOGLE_QRCODE = 'SET_GOOGLE_QRCODE';
62
62
  var CLEAR_GOOGLE_QRCODE = exports.CLEAR_GOOGLE_QRCODE = 'CLEAR_GOOGLE_QRCODE';
63
63
  var RECEIVE_BASE_NOTIONAL_PRODUCT_INFO = exports.RECEIVE_BASE_NOTIONAL_PRODUCT_INFO = 'RECEIVE_BASE_NOTIONAL_PRODUCT_INFO';
64
64
  var ACCOUNTS_LOADED = exports.ACCOUNTS_LOADED = 'ACCOUNTS_LOADED';
65
+
66
+ // t('This account cannot use the trading site. Please log in with a trading account.')
67
+ var USER_INFO_REFUSED_MESSAGE = exports.USER_INFO_REFUSED_MESSAGE = 'This account cannot use the trading site. Please log in with a trading account.';
68
+ // t('Could not load your account. Please log in again.')
69
+ var USER_INFO_FAILED_MESSAGE = exports.USER_INFO_FAILED_MESSAGE = 'Could not load your account. Please log in again.';
65
70
  var userInfoFetched = exports.userInfoFetched = function userInfoFetched(payload) {
66
71
  return {
67
72
  type: USER_INFO_FETCHED,
@@ -122,7 +127,7 @@ var setUserInfo = exports.setUserInfo = function setUserInfo(payload) {
122
127
  var getUserInfo = exports.getUserInfo = function getUserInfo(UserId) {
123
128
  return /*#__PURE__*/function () {
124
129
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(dispatch, getState) {
125
- var userInfo, OMSsInfo, currentOMSInfo, BaseNotionalProductSymbol, BaseNotionalProductId;
130
+ var userInfo, errormsg, OMSsInfo, currentOMSInfo, BaseNotionalProductSymbol, BaseNotionalProductId;
126
131
  return _regenerator().w(function (_context2) {
127
132
  while (1) switch (_context2.n) {
128
133
  case 0:
@@ -130,6 +135,9 @@ var getUserInfo = exports.getUserInfo = function getUserInfo(UserId) {
130
135
  return dispatch((0, _apiActions.callAPI)('GetUserInfo', {
131
136
  UserId: UserId
132
137
  }))["catch"](function (e) {
138
+ if ((0, _apiActions.isErrorFrame)(e)) {
139
+ return (0, _apiActions.settleErrorFrame)(e);
140
+ }
133
141
  console.error('getUserInfo action error', e);
134
142
  return;
135
143
  });
@@ -142,20 +150,38 @@ var getUserInfo = exports.getUserInfo = function getUserInfo(UserId) {
142
150
  dispatch(accountsLoaded());
143
151
  return _context2.a(2);
144
152
  case 2:
145
- _context2.n = 3;
153
+ if (!(userInfo.result === false)) {
154
+ _context2.n = 3;
155
+ break;
156
+ }
157
+ console.error('GetUserInfo was refused, ending the session', userInfo);
158
+ errormsg = userInfo.errormsg === _apiActions.ENDPOINT_NOT_FOUND ? USER_INFO_REFUSED_MESSAGE : USER_INFO_FAILED_MESSAGE;
159
+ dispatch(accountsLoaded());
160
+ // logout first: the root reducer resets all state on AUTH_NONE, so the message must come after.
161
+ dispatch((0, _authActions.logout)());
162
+ dispatch((0, _authActions.authError)({
163
+ Authenticated: false,
164
+ errormsg: errormsg
165
+ }));
166
+ return _context2.a(2);
167
+ case 3:
168
+ _context2.n = 4;
146
169
  return dispatch((0, _apiActions.callAPI)('GetOMSs', {
147
170
  OperatorId: userInfo.OperatorId
148
171
  }))["catch"](function (e) {
149
172
  console.error('GetOMS action error', e);
150
173
  return;
151
174
  });
152
- case 3:
175
+ case 4:
153
176
  OMSsInfo = _context2.v;
154
177
  // A failed GetOMSs must not abort the bootstrap. Everything downstream reads
155
178
  // currentOMSInfo optionally, and getUserAccounts still needs to run.
156
179
  currentOMSInfo = Array.isArray(OMSsInfo) ? OMSsInfo.find(function (OMSInfo) {
157
180
  return (OMSInfo.Id || OMSInfo.OMSId) === userInfo.OMSId;
158
- }) : undefined;
181
+ }) : undefined; // Set before userInfoFetched: the exchange route guard reads both flags.
182
+ if (currentOMSInfo !== null && currentOMSInfo !== void 0 && currentOMSInfo.SystemMarginEnabled) {
183
+ dispatch((0, _actions.initMarginTrading)(currentOMSInfo.SystemMarginEnabled));
184
+ }
159
185
  dispatch(userInfoFetched(userInfo));
160
186
  dispatch(getUserPermissions(userInfo.UserId));
161
187
  dispatch(getUserConfig(userInfo.UserId, userInfo.UserName));
@@ -185,10 +211,9 @@ var getUserInfo = exports.getUserInfo = function getUserInfo(UserId) {
185
211
  BaseNotionalProductId: BaseNotionalProductId
186
212
  }));
187
213
  }
188
- if (currentOMSInfo !== null && currentOMSInfo !== void 0 && currentOMSInfo.SystemMarginEnabled) {
189
- dispatch((0, _actions.initMarginTrading)(currentOMSInfo.SystemMarginEnabled));
190
- }
191
- if (userInfo.MarginBorrowerEnabled) {
214
+
215
+ // The gateway refuses margin requests while system margin is disabled.
216
+ if (userInfo.MarginBorrowerEnabled && currentOMSInfo !== null && currentOMSInfo !== void 0 && currentOMSInfo.SystemMarginEnabled) {
192
217
  dispatch((0, _actions.getMarginInstruments)(userInfo.OMSId));
193
218
  }
194
219
  if (currentOMSInfo !== null && currentOMSInfo !== void 0 && currentOMSInfo.SystemFuturesEnabled) {
@@ -217,13 +242,16 @@ var userConfigFetched = exports.userConfigFetched = function userConfigFetched(p
217
242
  payload: payload
218
243
  };
219
244
  };
245
+
246
+ /** A reply that comes after the session it was asked in has ended is dropped: the config is then the next user's. */
220
247
  var getUserConfig = exports.getUserConfig = function getUserConfig(UserId, UserName) {
221
248
  return /*#__PURE__*/function () {
222
249
  var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(dispatch) {
223
- var userConfig;
250
+ var stillCurrent, userConfig;
224
251
  return _regenerator().w(function (_context3) {
225
252
  while (1) switch (_context3.n) {
226
253
  case 0:
254
+ stillCurrent = (0, _authActions.sessionCheck)();
227
255
  _context3.n = 1;
228
256
  return dispatch((0, _apiActions.callAPI)('GetUserConfig', {
229
257
  UserId: UserId,
@@ -234,6 +262,12 @@ var getUserConfig = exports.getUserConfig = function getUserConfig(UserId, UserN
234
262
  });
235
263
  case 1:
236
264
  userConfig = _context3.v;
265
+ if (stillCurrent()) {
266
+ _context3.n = 2;
267
+ break;
268
+ }
269
+ return _context3.a(2, undefined);
270
+ case 2:
237
271
  dispatch(userConfigFetched(userConfig));
238
272
  return _context3.a(2, userConfig);
239
273
  }
@@ -245,6 +279,55 @@ var getUserConfig = exports.getUserConfig = function getUserConfig(UserId, UserN
245
279
  }();
246
280
  };
247
281
 
282
+ /**
283
+ * Re-reads Use2FA and the 2FA type after a passkey change: the gateway sets the type to passkey and turns 2FA on with a
284
+ * user's first passkey, and undoes both with the last. Only these two reads, not the whole getUserInfo bootstrap.
285
+ * Nothing is written, and the config is not asked for, once the session the reload started in has ended: the replies
286
+ * describe the user who left, and the state is the next user's.
287
+ */
288
+ var reloadSecondFactorState = exports.reloadSecondFactorState = function reloadSecondFactorState() {
289
+ return /*#__PURE__*/function () {
290
+ var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(dispatch, getState) {
291
+ var stillCurrent, userInfo, fresh;
292
+ return _regenerator().w(function (_context4) {
293
+ while (1) switch (_context4.n) {
294
+ case 0:
295
+ stillCurrent = (0, _authActions.sessionCheck)();
296
+ userInfo = getState().user.userInfo;
297
+ if (!(!userInfo || !userInfo.UserId)) {
298
+ _context4.n = 1;
299
+ break;
300
+ }
301
+ return _context4.a(2);
302
+ case 1:
303
+ _context4.n = 2;
304
+ return dispatch((0, _apiActions.callAPI)('GetUserInfo', {
305
+ UserId: userInfo.UserId
306
+ }))["catch"](function (e) {
307
+ console.error('reloadSecondFactorState: GetUserInfo failed', e);
308
+ });
309
+ case 2:
310
+ fresh = _context4.v;
311
+ if (stillCurrent()) {
312
+ _context4.n = 3;
313
+ break;
314
+ }
315
+ return _context4.a(2);
316
+ case 3:
317
+ if (fresh && fresh.result !== false) dispatch(userInfoFetched(fresh));
318
+ _context4.n = 4;
319
+ return dispatch(getUserConfig(userInfo.UserId, userInfo.UserName));
320
+ case 4:
321
+ return _context4.a(2);
322
+ }
323
+ }, _callee4);
324
+ }));
325
+ return function (_x5, _x6) {
326
+ return _ref4.apply(this, arguments);
327
+ };
328
+ }();
329
+ };
330
+
248
331
  /**
249
332
  * Merge `config` arg with existing user config
250
333
  */
@@ -267,20 +350,20 @@ var updateUserConfig = exports.updateUserConfig = function updateUserConfig(conf
267
350
  var setUserConfig = exports.setUserConfig = function setUserConfig(UserId, UserName, Config) {
268
351
  var getUserConfigAfterSetUserConfig = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
269
352
  return /*#__PURE__*/function () {
270
- var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(dispatch, getState) {
353
+ var _ref5 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(dispatch, getState) {
271
354
  var _getState, _getState$user, _getState$user2, userInfo, userConfig;
272
- return _regenerator().w(function (_context4) {
273
- while (1) switch (_context4.n) {
355
+ return _regenerator().w(function (_context5) {
356
+ while (1) switch (_context5.n) {
274
357
  case 0:
275
358
  _getState = getState(), _getState$user = _getState.user, _getState$user2 = _getState$user === void 0 ? {} : _getState$user, userInfo = _getState$user2.userInfo;
276
- _context4.n = 1;
359
+ _context5.n = 1;
277
360
  return dispatch((0, _apiActions.callAPI)('SetUserConfig', {
278
361
  UserId: UserId || userInfo.UserId,
279
362
  UserName: UserName || userInfo.UserName,
280
363
  Config: Config
281
364
  }));
282
365
  case 1:
283
- userConfig = _context4.v;
366
+ userConfig = _context5.v;
284
367
  if (userConfig.result !== false) {
285
368
  if (getUserConfigAfterSetUserConfig) dispatch(getUserConfig(UserId, UserName));
286
369
  } else {
@@ -290,39 +373,39 @@ var setUserConfig = exports.setUserConfig = function setUserConfig(UserId, UserN
290
373
  type: 'warning'
291
374
  }));
292
375
  }
293
- return _context4.a(2, userConfig);
376
+ return _context5.a(2, userConfig);
294
377
  }
295
- }, _callee4);
378
+ }, _callee5);
296
379
  }));
297
- return function (_x5, _x6) {
298
- return _ref4.apply(this, arguments);
380
+ return function (_x7, _x8) {
381
+ return _ref5.apply(this, arguments);
299
382
  };
300
383
  }();
301
384
  };
302
385
  var getUserPermissions = exports.getUserPermissions = function getUserPermissions(UserId) {
303
386
  return /*#__PURE__*/function () {
304
- var _ref5 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(dispatch) {
387
+ var _ref6 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(dispatch) {
305
388
  var permissions, requestPermissions, rolePermissions, roles, permissionRoles, updatedPermissions;
306
- return _regenerator().w(function (_context5) {
307
- while (1) switch (_context5.n) {
389
+ return _regenerator().w(function (_context6) {
390
+ while (1) switch (_context6.n) {
308
391
  case 0:
309
- _context5.n = 1;
392
+ _context6.n = 1;
310
393
  return dispatch((0, _apiActions.callAPI)('GetUserPermissions', {
311
394
  UserId: UserId
312
395
  }));
313
396
  case 1:
314
- requestPermissions = _context5.v;
397
+ requestPermissions = _context6.v;
315
398
  rolePermissions = new Set(_toConsumableArray(requestPermissions));
316
399
  if (!(rolePermissions.has(_userPermissionsContants.userPermissions.operator) || rolePermissions.has(_userPermissionsContants.userPermissions.superUser))) {
317
- _context5.n = 3;
400
+ _context6.n = 3;
318
401
  break;
319
402
  }
320
- _context5.n = 2;
403
+ _context6.n = 2;
321
404
  return dispatch((0, _apiActions.callAPI)('GetUserRoles', {
322
405
  UserId: UserId
323
406
  }));
324
407
  case 2:
325
- roles = _context5.v;
408
+ roles = _context6.v;
326
409
  permissionRoles = roles.flatMap(function (role) {
327
410
  return role.Permissions.map(function (permission) {
328
411
  return permission;
@@ -330,19 +413,19 @@ var getUserPermissions = exports.getUserPermissions = function getUserPermission
330
413
  });
331
414
  updatedPermissions = new Set([].concat(_toConsumableArray(rolePermissions), _toConsumableArray(permissionRoles)));
332
415
  permissions = _toConsumableArray(new Set(updatedPermissions));
333
- _context5.n = 4;
416
+ _context6.n = 4;
334
417
  break;
335
418
  case 3:
336
419
  permissions = requestPermissions;
337
420
  case 4:
338
421
  dispatch(receiveUserPermissions(permissions));
339
422
  case 5:
340
- return _context5.a(2);
423
+ return _context6.a(2);
341
424
  }
342
- }, _callee5);
425
+ }, _callee6);
343
426
  }));
344
- return function (_x7) {
345
- return _ref5.apply(this, arguments);
427
+ return function (_x9) {
428
+ return _ref6.apply(this, arguments);
346
429
  };
347
430
  }();
348
431
  };
@@ -354,95 +437,95 @@ var receiveUserPermissions = exports.receiveUserPermissions = function receiveUs
354
437
  };
355
438
  var getUserAccounts = exports.getUserAccounts = function getUserAccounts(OMSId) {
356
439
  return /*#__PURE__*/function () {
357
- var _ref6 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(dispatch) {
440
+ var _ref7 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(dispatch) {
358
441
  var accountInfoArray, userAccountIds, _iterator, _step, accountId, accountInfo, _t, _t2;
359
- return _regenerator().w(function (_context6) {
360
- while (1) switch (_context6.p = _context6.n) {
442
+ return _regenerator().w(function (_context7) {
443
+ while (1) switch (_context7.p = _context7.n) {
361
444
  case 0:
362
445
  accountInfoArray = [];
363
- _context6.p = 1;
364
- _context6.n = 2;
446
+ _context7.p = 1;
447
+ _context7.n = 2;
365
448
  return dispatch((0, _apiActions.callAPI)('GetUserAccounts', {
366
449
  OMSId: OMSId
367
450
  }));
368
451
  case 2:
369
- userAccountIds = _context6.v;
452
+ userAccountIds = _context7.v;
370
453
  if (Array.isArray(userAccountIds)) {
371
- _context6.n = 3;
454
+ _context7.n = 3;
372
455
  break;
373
456
  }
374
457
  console.error('GetUserAccounts did not return an array', userAccountIds);
375
- return _context6.a(2, accountInfoArray);
458
+ return _context7.a(2, accountInfoArray);
376
459
  case 3:
377
460
  _iterator = _createForOfIteratorHelper(userAccountIds);
378
- _context6.p = 4;
461
+ _context7.p = 4;
379
462
  _iterator.s();
380
463
  case 5:
381
464
  if ((_step = _iterator.n()).done) {
382
- _context6.n = 8;
465
+ _context7.n = 8;
383
466
  break;
384
467
  }
385
468
  accountId = _step.value;
386
- _context6.n = 6;
469
+ _context7.n = 6;
387
470
  return dispatch((0, _apiActions.callAPI)('GetAccountInfo', {
388
471
  AccountId: accountId,
389
472
  OMSId: OMSId
390
473
  }));
391
474
  case 6:
392
- accountInfo = _context6.v;
475
+ accountInfo = _context7.v;
393
476
  // subscribe to events of every user's account
394
477
  _apex["default"].connection.subscribeAccountEvents(accountId, OMSId);
395
478
  accountInfoArray.push(accountInfo);
396
479
  case 7:
397
- _context6.n = 5;
480
+ _context7.n = 5;
398
481
  break;
399
482
  case 8:
400
- _context6.n = 10;
483
+ _context7.n = 10;
401
484
  break;
402
485
  case 9:
403
- _context6.p = 9;
404
- _t = _context6.v;
486
+ _context7.p = 9;
487
+ _t = _context7.v;
405
488
  _iterator.e(_t);
406
489
  case 10:
407
- _context6.p = 10;
490
+ _context7.p = 10;
408
491
  _iterator.f();
409
- return _context6.f(10);
492
+ return _context7.f(10);
410
493
  case 11:
411
494
  if (accountInfoArray.length > 0) {
412
495
  dispatch(receiveAccount(accountInfoArray));
413
496
  dispatch((0, _kycActions.subscribeToVerificationLevelUpdateEvents)(accountInfoArray[0]));
414
497
  }
415
- return _context6.a(2, accountInfoArray);
498
+ return _context7.a(2, accountInfoArray);
416
499
  case 12:
417
- _context6.p = 12;
418
- _t2 = _context6.v;
500
+ _context7.p = 12;
501
+ _t2 = _context7.v;
419
502
  // Resolve rather than reject. The caller chains off this promise, and a
420
503
  // rejection there would surface as an unhandled rejection while leaving
421
504
  // the UI with no way to know the fetch had finished.
422
505
  console.error('getUserAccounts action error', _t2);
423
- return _context6.a(2, accountInfoArray);
506
+ return _context7.a(2, accountInfoArray);
424
507
  case 13:
425
- _context6.p = 13;
508
+ _context7.p = 13;
426
509
  // Dispatched after receiveAccount so the UI never sees "loaded" with an
427
510
  // empty accounts array for a user who actually has accounts.
428
511
  dispatch(accountsLoaded());
429
- return _context6.f(13);
512
+ return _context7.f(13);
430
513
  case 14:
431
- return _context6.a(2);
514
+ return _context7.a(2);
432
515
  }
433
- }, _callee6, null, [[4, 9, 10, 11], [1, 12, 13, 14]]);
516
+ }, _callee7, null, [[4, 9, 10, 11], [1, 12, 13, 14]]);
434
517
  }));
435
- return function (_x8) {
436
- return _ref6.apply(this, arguments);
518
+ return function (_x0) {
519
+ return _ref7.apply(this, arguments);
437
520
  };
438
521
  }();
439
522
  };
440
523
  var updateAccount = exports.updateAccount = function updateAccount(loyaltyProduct) {
441
524
  return /*#__PURE__*/function () {
442
- var _ref7 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(dispatch, getState) {
525
+ var _ref8 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(dispatch, getState) {
443
526
  var _getState$user3, selectedAccountId, accounts, OMSId, currentAccount, payload, Amount, ProductId, response, text;
444
- return _regenerator().w(function (_context7) {
445
- while (1) switch (_context7.n) {
527
+ return _regenerator().w(function (_context8) {
528
+ while (1) switch (_context8.n) {
446
529
  case 0:
447
530
  _getState$user3 = getState().user, selectedAccountId = _getState$user3.selectedAccountId, accounts = _getState$user3.accounts, OMSId = _getState$user3.userInfo.OMSId;
448
531
  currentAccount = accounts.find(function (account) {
@@ -461,10 +544,10 @@ var updateAccount = exports.updateAccount = function updateAccount(loyaltyProduc
461
544
  payload.LoyaltyEnabled = true;
462
545
  }
463
546
  }
464
- _context7.n = 1;
547
+ _context8.n = 1;
465
548
  return dispatch((0, _apiActions.callAPI)('UpdateAccount', payload));
466
549
  case 1:
467
- response = _context7.v;
550
+ response = _context8.v;
468
551
  if (response.result) {
469
552
  text = loyaltyProduct ? 'Fee token successfully set' : 'Fee token successfully unset';
470
553
  dispatch((0, _snackbarActions.showSnack)({
@@ -482,32 +565,32 @@ var updateAccount = exports.updateAccount = function updateAccount(loyaltyProduc
482
565
  }));
483
566
  }
484
567
  case 2:
485
- return _context7.a(2);
568
+ return _context8.a(2);
486
569
  }
487
- }, _callee7);
570
+ }, _callee8);
488
571
  }));
489
- return function (_x9, _x0) {
490
- return _ref7.apply(this, arguments);
572
+ return function (_x1, _x10) {
573
+ return _ref8.apply(this, arguments);
491
574
  };
492
575
  }();
493
576
  };
494
577
  var selectAccount = exports.selectAccount = function selectAccount(accountId, OMSId) {
495
578
  return /*#__PURE__*/function () {
496
- var _ref8 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(dispatch, getState) {
579
+ var _ref9 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(dispatch, getState) {
497
580
  var accounts, account, selectedInstrumentId, _selectedInstrumentId;
498
- return _regenerator().w(function (_context8) {
499
- while (1) switch (_context8.n) {
581
+ return _regenerator().w(function (_context9) {
582
+ while (1) switch (_context9.n) {
500
583
  case 0:
501
584
  accounts = getState().user.accounts;
502
585
  account = (accounts || []).find(function (a) {
503
586
  return a.AccountId === accountId;
504
587
  });
505
588
  if (!(!accounts.length || !account)) {
506
- _context8.n = 1;
589
+ _context9.n = 1;
507
590
  break;
508
591
  }
509
592
  console.error("No account found with ID ".concat(accountId));
510
- return _context8.a(2);
593
+ return _context9.a(2);
511
594
  case 1:
512
595
  dispatch(setAccount(accountId));
513
596
 
@@ -562,12 +645,12 @@ var selectAccount = exports.selectAccount = function selectAccount(accountId, OM
562
645
  dispatch((0, _actions2.subscribeFuturesOrderHistory)(accountId));
563
646
  }
564
647
  case 2:
565
- return _context8.a(2);
648
+ return _context9.a(2);
566
649
  }
567
- }, _callee8);
650
+ }, _callee9);
568
651
  }));
569
- return function (_x1, _x10) {
570
- return _ref8.apply(this, arguments);
652
+ return function (_x11, _x12) {
653
+ return _ref9.apply(this, arguments);
571
654
  };
572
655
  }();
573
656
  };
@@ -595,17 +678,17 @@ var goToBaseCurrencyFormStep = exports.goToBaseCurrencyFormStep = function goToB
595
678
  };
596
679
  var sendResetPasswordEmail = exports.sendResetPasswordEmail = function sendResetPasswordEmail(UserName) {
597
680
  return /*#__PURE__*/function () {
598
- var _ref9 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(dispatch) {
681
+ var _ref0 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(dispatch) {
599
682
  var response, snackbarPayload;
600
- return _regenerator().w(function (_context9) {
601
- while (1) switch (_context9.n) {
683
+ return _regenerator().w(function (_context0) {
684
+ while (1) switch (_context0.n) {
602
685
  case 0:
603
- _context9.n = 1;
686
+ _context0.n = 1;
604
687
  return dispatch((0, _apiActions.callAPI)('ResetPassword', {
605
688
  UserName: UserName
606
689
  }));
607
690
  case 1:
608
- response = _context9.v;
691
+ response = _context0.v;
609
692
  snackbarPayload = response.result ? {
610
693
  id: 'sendResetPasswordEmailSuccess',
611
694
  // t('Check Your Email For Reset Password Link');
@@ -621,12 +704,12 @@ var sendResetPasswordEmail = exports.sendResetPasswordEmail = function sendReset
621
704
  return dispatch((0, _authActions.logout)());
622
705
  }, _config["default"].Snackbar.timeout);
623
706
  case 2:
624
- return _context9.a(2);
707
+ return _context0.a(2);
625
708
  }
626
- }, _callee9);
709
+ }, _callee0);
627
710
  }));
628
- return function (_x11) {
629
- return _ref9.apply(this, arguments);
711
+ return function (_x13) {
712
+ return _ref0.apply(this, arguments);
630
713
  };
631
714
  }();
632
715
  };
@@ -650,17 +733,17 @@ var clearGoogleQrCode = exports.clearGoogleQrCode = function clearGoogleQrCode()
650
733
  };
651
734
  var getGoogleQrCode = exports.getGoogleQrCode = function getGoogleQrCode() {
652
735
  return /*#__PURE__*/function () {
653
- var _ref0 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(dispatch) {
736
+ var _ref1 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1(dispatch) {
654
737
  var qrCode;
655
- return _regenerator().w(function (_context0) {
656
- while (1) switch (_context0.n) {
738
+ return _regenerator().w(function (_context1) {
739
+ while (1) switch (_context1.n) {
657
740
  case 0:
658
- _context0.n = 1;
741
+ _context1.n = 1;
659
742
  return _apex["default"].connection.EnableGoogle2FA();
660
743
  case 1:
661
- qrCode = _context0.v;
744
+ qrCode = _context1.v;
662
745
  if (!(qrCode && qrCode.result === false)) {
663
- _context0.n = 2;
746
+ _context1.n = 2;
664
747
  break;
665
748
  }
666
749
  dispatch((0, _snackbarActions.showSnack)({
@@ -669,62 +752,68 @@ var getGoogleQrCode = exports.getGoogleQrCode = function getGoogleQrCode() {
669
752
  text: qrCode.errormsg ? (0, _errorTextFormatter.formatErrorText)(qrCode) : 'Two-factor authentication could not be enabled.',
670
753
  type: 'warning'
671
754
  }));
672
- return _context0.a(2, false);
755
+ return _context1.a(2, false);
673
756
  case 2:
674
757
  dispatch(setGoogleQrCode(qrCode));
675
- return _context0.a(2, true);
758
+ return _context1.a(2, true);
676
759
  }
677
- }, _callee0);
760
+ }, _callee1);
678
761
  }));
679
- return function (_x12) {
680
- return _ref0.apply(this, arguments);
762
+ return function (_x14) {
763
+ return _ref1.apply(this, arguments);
681
764
  };
682
765
  }();
683
766
  };
767
+
768
+ // The gateway turns 2FA off together with its 2FA type and every passkey, so the config and passkey-only state go too.
769
+ // Nothing is written when the session that turned it off has since ended: the state is the next user's. A passkey
770
+ // status still on its way was read while 2FA was on, so the claim keeps it from writing over this.
771
+ var twoFactorDisabled = function twoFactorDisabled(dispatch, getState, stillCurrent) {
772
+ if (!stillCurrent()) return;
773
+ var userInfo = getState().user.userInfo;
774
+ dispatch(userInfoFetched(_objectSpread(_objectSpread({}, userInfo), {}, {
775
+ Use2FA: false
776
+ })));
777
+ (0, _authActions.claimPasskeyOnly)();
778
+ dispatch((0, _authActions.setPasskeyOnly)(false));
779
+ if (userInfo && userInfo.UserId) dispatch(getUserConfig(userInfo.UserId, userInfo.UserName));
780
+ dispatch((0, _modalActions.closeModal)(_modalActions.MODAL_TYPES.DISABLE_2FA));
781
+ dispatch((0, _snackbarActions.showSnack)({
782
+ id: 'DISABLE_2FA_SUCCESS',
783
+ // t('Two Factor Authenticated is disabled')
784
+ text: 'Two-Factor Authenticated is disabled',
785
+ type: 'success'
786
+ }));
787
+ };
684
788
  var disable2FA = exports.disable2FA = function disable2FA(code) {
685
789
  return /*#__PURE__*/function () {
686
- var _ref1 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1(dispatch, getState) {
687
- var userInfo, auth, _t3;
688
- return _regenerator().w(function (_context1) {
689
- while (1) switch (_context1.p = _context1.n) {
790
+ var _ref10 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10(dispatch, getState) {
791
+ var stillCurrent, auth, _t3;
792
+ return _regenerator().w(function (_context10) {
793
+ while (1) switch (_context10.p = _context10.n) {
690
794
  case 0:
691
- userInfo = getState().user.userInfo;
692
- _context1.p = 1;
693
- _context1.n = 2;
795
+ stillCurrent = (0, _authActions.sessionCheck)();
796
+ _context10.p = 1;
797
+ _context10.n = 2;
694
798
  return _apex["default"].connection.Disable2FA();
695
799
  case 2:
696
- _context1.n = 3;
800
+ _context10.n = 3;
697
801
  return dispatch((0, _apiActions.callAPI)('Authenticate2FA', {
698
802
  Code: code
699
803
  }))["catch"](function (e) {
700
804
  return console.log(e);
701
805
  });
702
806
  case 3:
703
- auth = _context1.v;
704
- _context1.n = 5;
807
+ auth = _context10.v;
808
+ _context10.n = 5;
705
809
  break;
706
810
  case 4:
707
- _context1.p = 4;
708
- _t3 = _context1.v;
811
+ _context10.p = 4;
812
+ _t3 = _context10.v;
709
813
  console.error(_t3);
710
- dispatch((0, _snackbarActions.showSnack)({
711
- id: 'DISABLE_2FA_ERROR',
712
- // t('Code Rejected')
713
- text: 'Code Rejected',
714
- type: 'warning'
715
- }));
716
814
  case 5:
717
- if (auth.Authenticated) {
718
- dispatch(userInfoFetched(_objectSpread(_objectSpread({}, userInfo), {}, {
719
- Use2FA: false
720
- })));
721
- dispatch((0, _modalActions.closeModal)(_modalActions.MODAL_TYPES.DISABLE_2FA));
722
- dispatch((0, _snackbarActions.showSnack)({
723
- id: 'DISABLE_2FA_SUCCESS',
724
- // t('Two Factor Authenticated is disabled')
725
- text: 'Two-Factor Authenticated is disabled',
726
- type: 'success'
727
- }));
815
+ if (auth && auth.Authenticated) {
816
+ twoFactorDisabled(dispatch, getState, stillCurrent);
728
817
  } else {
729
818
  dispatch((0, _snackbarActions.showSnack)({
730
819
  id: 'DISABLE_2FA_ERROR',
@@ -734,29 +823,77 @@ var disable2FA = exports.disable2FA = function disable2FA(code) {
734
823
  }));
735
824
  }
736
825
  case 6:
737
- return _context1.a(2);
826
+ return _context10.a(2);
738
827
  }
739
- }, _callee1, null, [[1, 4]]);
828
+ }, _callee10, null, [[1, 4]]);
740
829
  }));
741
- return function (_x13, _x14) {
742
- return _ref1.apply(this, arguments);
830
+ return function (_x15, _x16) {
831
+ return _ref10.apply(this, arguments);
832
+ };
833
+ }();
834
+ };
835
+
836
+ /**
837
+ * Turns 2FA off with a passkey answer instead of a code: Authenticate2FA takes it as Assertion, for any 2FA type and
838
+ * for a user who must answer with a passkey. Resolves to null once 2FA is off, otherwise to the reason (an i18n key).
839
+ */
840
+ var disable2FAWithPasskey = exports.disable2FAWithPasskey = function disable2FAWithPasskey(assertion) {
841
+ return /*#__PURE__*/function () {
842
+ var _ref11 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11(dispatch, getState) {
843
+ var stillCurrent, auth, reason, _t4;
844
+ return _regenerator().w(function (_context11) {
845
+ while (1) switch (_context11.p = _context11.n) {
846
+ case 0:
847
+ stillCurrent = (0, _authActions.sessionCheck)();
848
+ _context11.p = 1;
849
+ _context11.n = 2;
850
+ return _apex["default"].connection.Disable2FA();
851
+ case 2:
852
+ _context11.n = 3;
853
+ return dispatch((0, _apiActions.callAPI)('Authenticate2FA', {
854
+ Code: '',
855
+ Assertion: assertion
856
+ }));
857
+ case 3:
858
+ auth = _context11.v;
859
+ _context11.n = 5;
860
+ break;
861
+ case 4:
862
+ _context11.p = 4;
863
+ _t4 = _context11.v;
864
+ console.error(_t4);
865
+ case 5:
866
+ if (!(auth && auth.Authenticated)) {
867
+ _context11.n = 6;
868
+ break;
869
+ }
870
+ twoFactorDisabled(dispatch, getState, stillCurrent);
871
+ return _context11.a(2, null);
872
+ case 6:
873
+ reason = auth && typeof auth.errormsg === 'string' ? auth.errormsg.trim() : ''; // t('The passkey was not accepted. Try again.')
874
+ return _context11.a(2, reason || 'The passkey was not accepted. Try again.');
875
+ }
876
+ }, _callee11, null, [[1, 4]]);
877
+ }));
878
+ return function (_x17, _x18) {
879
+ return _ref11.apply(this, arguments);
743
880
  };
744
881
  }();
745
882
  };
746
883
  var enable2FA = exports.enable2FA = function enable2FA(code) {
747
884
  return /*#__PURE__*/function () {
748
- var _ref10 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10(dispatch, getState) {
885
+ var _ref12 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12(dispatch, getState) {
749
886
  var userInfo, auth;
750
- return _regenerator().w(function (_context10) {
751
- while (1) switch (_context10.n) {
887
+ return _regenerator().w(function (_context12) {
888
+ while (1) switch (_context12.n) {
752
889
  case 0:
753
890
  userInfo = getState().user.userInfo;
754
- _context10.n = 1;
891
+ _context12.n = 1;
755
892
  return _apex["default"].connection.Authenticate2FA({
756
893
  Code: code
757
894
  });
758
895
  case 1:
759
- auth = _context10.v;
896
+ auth = _context12.v;
760
897
  if (auth.Authenticated) {
761
898
  dispatch((0, _authActions.authSuccess)(auth));
762
899
  dispatch(userInfoFetched(_objectSpread(_objectSpread({}, userInfo), {}, {
@@ -779,29 +916,29 @@ var enable2FA = exports.enable2FA = function enable2FA(code) {
779
916
  }));
780
917
  }
781
918
  case 2:
782
- return _context10.a(2);
919
+ return _context12.a(2);
783
920
  }
784
- }, _callee10);
921
+ }, _callee12);
785
922
  }));
786
- return function (_x15, _x16) {
787
- return _ref10.apply(this, arguments);
923
+ return function (_x19, _x20) {
924
+ return _ref12.apply(this, arguments);
788
925
  };
789
926
  }();
790
927
  };
791
928
  var enableYubikey2FA = exports.enableYubikey2FA = function enableYubikey2FA(otp) {
792
929
  return /*#__PURE__*/function () {
793
- var _ref11 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11(dispatch, getState) {
930
+ var _ref13 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13(dispatch, getState) {
794
931
  var userInfo, auth;
795
- return _regenerator().w(function (_context11) {
796
- while (1) switch (_context11.n) {
932
+ return _regenerator().w(function (_context13) {
933
+ while (1) switch (_context13.n) {
797
934
  case 0:
798
935
  userInfo = getState().user.userInfo;
799
- _context11.n = 1;
936
+ _context13.n = 1;
800
937
  return dispatch((0, _apiActions.callAPI)('EnableYubico2FA', {
801
938
  otp: otp
802
939
  }));
803
940
  case 1:
804
- auth = _context11.v;
941
+ auth = _context13.v;
805
942
  if (auth.Enabled2FA) {
806
943
  dispatch(userInfoFetched(_objectSpread(_objectSpread({}, userInfo), {}, {
807
944
  Use2FA: true
@@ -823,28 +960,28 @@ var enableYubikey2FA = exports.enableYubikey2FA = function enableYubikey2FA(otp)
823
960
  }));
824
961
  }
825
962
  case 2:
826
- return _context11.a(2);
963
+ return _context13.a(2);
827
964
  }
828
- }, _callee11);
965
+ }, _callee13);
829
966
  }));
830
- return function (_x17, _x18) {
831
- return _ref11.apply(this, arguments);
967
+ return function (_x21, _x22) {
968
+ return _ref13.apply(this, arguments);
832
969
  };
833
970
  }();
834
971
  };
835
972
  var getGoogle2FARecoveryCode = exports.getGoogle2FARecoveryCode = function getGoogle2FARecoveryCode(code) {
836
973
  return /*#__PURE__*/function () {
837
- var _ref12 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12(dispatch) {
974
+ var _ref14 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee14(dispatch) {
838
975
  var response, recoveryCode;
839
- return _regenerator().w(function (_context12) {
840
- while (1) switch (_context12.n) {
976
+ return _regenerator().w(function (_context14) {
977
+ while (1) switch (_context14.n) {
841
978
  case 0:
842
- _context12.n = 1;
979
+ _context14.n = 1;
843
980
  return _apex["default"].connection.RPCPromise('GetGoogle2FARecoveryKey', {
844
981
  Code: code
845
982
  });
846
983
  case 1:
847
- response = _context12.v;
984
+ response = _context14.v;
848
985
  recoveryCode = JSON.parse(response.o);
849
986
  if (recoveryCode.Authenticated) {
850
987
  dispatch((0, _reduxForm.change)('google2FARecoveryKeyModal', 'recoveryKey', recoveryCode.RecoveryKey));
@@ -856,49 +993,49 @@ var getGoogle2FARecoveryCode = exports.getGoogle2FARecoveryCode = function getGo
856
993
  }));
857
994
  }
858
995
  case 2:
859
- return _context12.a(2);
996
+ return _context14.a(2);
860
997
  }
861
- }, _callee12);
998
+ }, _callee14);
862
999
  }));
863
- return function (_x19) {
864
- return _ref12.apply(this, arguments);
1000
+ return function (_x23) {
1001
+ return _ref14.apply(this, arguments);
865
1002
  };
866
1003
  }();
867
1004
  };
868
1005
  var resendVerificationEmail = exports.resendVerificationEmail = function resendVerificationEmail(payload) {
869
1006
  return /*#__PURE__*/function () {
870
- var _ref13 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13(dispatch) {
871
- var Apex, response, snackbarPayload, _t4;
872
- return _regenerator().w(function (_context13) {
873
- while (1) switch (_context13.p = _context13.n) {
1007
+ var _ref15 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15(dispatch) {
1008
+ var Apex, response, snackbarPayload, _t5;
1009
+ return _regenerator().w(function (_context15) {
1010
+ while (1) switch (_context15.p = _context15.n) {
874
1011
  case 0:
875
- _context13.p = 0;
1012
+ _context15.p = 0;
876
1013
  Apex = (0, _apex.getApex)();
877
- _context13.n = 2;
1014
+ _context15.n = 2;
878
1015
  break;
879
1016
  case 1:
880
- _context13.p = 1;
881
- _t4 = _context13.v;
882
- return _context13.a(2, dispatch((0, _snackbarActions.showSnack)({
1017
+ _context15.p = 1;
1018
+ _t5 = _context15.v;
1019
+ return _context15.a(2, dispatch((0, _snackbarActions.showSnack)({
883
1020
  id: 'apexError',
884
- text: _t4.message,
1021
+ text: _t5.message,
885
1022
  type: 'warning'
886
1023
  })));
887
1024
  case 2:
888
1025
  if (Apex.connection.ResendVerificationEmail) {
889
- _context13.n = 3;
1026
+ _context15.n = 3;
890
1027
  break;
891
1028
  }
892
- return _context13.a(2, dispatch((0, _snackbarActions.showSnack)({
1029
+ return _context15.a(2, dispatch((0, _snackbarActions.showSnack)({
893
1030
  id: 'resendVerificationEmailError',
894
1031
  text: 'Feature Not Available.',
895
1032
  type: 'warning'
896
1033
  })));
897
1034
  case 3:
898
- _context13.n = 4;
1035
+ _context15.n = 4;
899
1036
  return Apex.connection.ResendVerificationEmail(payload);
900
1037
  case 4:
901
- response = _context13.v;
1038
+ response = _context15.v;
902
1039
  snackbarPayload = response.result ? {
903
1040
  id: 'resendVerificationEmailSuccess',
904
1041
  // t('Check Your Email For An Account Verification Email');
@@ -911,12 +1048,12 @@ var resendVerificationEmail = exports.resendVerificationEmail = function resendV
911
1048
  };
912
1049
  dispatch((0, _snackbarActions.showSnack)(snackbarPayload));
913
1050
  case 5:
914
- return _context13.a(2);
1051
+ return _context15.a(2);
915
1052
  }
916
- }, _callee13, null, [[0, 1]]);
1053
+ }, _callee15, null, [[0, 1]]);
917
1054
  }));
918
- return function (_x20) {
919
- return _ref13.apply(this, arguments);
1055
+ return function (_x24) {
1056
+ return _ref15.apply(this, arguments);
920
1057
  };
921
1058
  }();
922
1059
  };