@alphapoint/apex-web 5.5.6 → 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 (132) 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 +139 -27
  8. package/lib/components/2FA/TwoFactorAuthContainer.test.js +627 -0
  9. package/lib/components/AccountsDropdown/AccountsDropdownComponent.css +6 -0
  10. package/lib/components/AccountsDropdown/AccountsDropdownComponent.js +6 -2
  11. package/lib/components/AccountsDropdown/AccountsDropdownComponent.test.js +43 -0
  12. package/lib/components/AccountsDropdown/AccountsDropdownContainer.js +3 -1
  13. package/lib/components/BalancesList/BalancesListContainer.js +4 -1
  14. package/lib/components/ConfirmBlockTradeModal/ConfirmBlockTradeModalContainer.js +34 -6
  15. package/lib/components/ConfirmBlockTradeModal/ConfirmBlockTradeModalContainer.test.js +298 -0
  16. package/lib/components/ConfirmOrderModal/ConfirmOrderModalComponent.js +26 -4
  17. package/lib/components/ConfirmOrderModal/ConfirmOrderModalContainer.js +4 -1
  18. package/lib/components/DigitalAssets/digitalAssetsPriceLabel.test.js +238 -0
  19. package/lib/components/EnableTwoFactorAuth/Disable2FAForm.js +22 -7
  20. package/lib/components/EnableTwoFactorAuth/Disable2FAModal.js +15 -5
  21. package/lib/components/EnableTwoFactorAuth/Disable2FAModal.test.js +460 -0
  22. package/lib/components/EnableTwoFactorAuth/Disable2FAModalContainer.js +108 -16
  23. package/lib/components/EnableTwoFactorAuth/EnableTwoFactorAuthComponent.js +7 -0
  24. package/lib/components/EnableTwoFactorAuth/EnableTwoFactorAuthComponent.test.js +105 -0
  25. package/lib/components/EnableTwoFactorAuth/EnableTwoFactorAuthContainerFactory.js +15 -3
  26. package/lib/components/FusionAuth/UnlinkOAuthIdentityModal.css +13 -0
  27. package/lib/components/FusionAuth/UnlinkOAuthIdentityModal.js +246 -0
  28. package/lib/components/FusionAuth/UnlinkOAuthIdentityModal.test.js +521 -0
  29. package/lib/components/InstrumentPositions/InstrumentPositionsContainer.js +4 -1
  30. package/lib/components/Login/LoginFormComponent.js +1 -1
  31. package/lib/components/MarginBalances/MarginDepositWithdraw/MarginDepositModal/MarginDepositFormContainer.js +2 -1
  32. package/lib/components/NoAccountBanner/NoAccountBanner.css +9 -0
  33. package/lib/components/NoAccountBanner/NoAccountBanner.js +58 -0
  34. package/lib/components/NoAccountBanner/index.js +16 -0
  35. package/lib/components/NoAccountPlaceholder/NoAccountPlaceholder.css +31 -0
  36. package/lib/components/NoAccountPlaceholder/NoAccountPlaceholder.js +33 -0
  37. package/lib/components/NoAccountPlaceholder/index.js +9 -0
  38. package/lib/components/OrderEntryComponents/advancedForm/AdvancedOrderFormContainer.js +2 -0
  39. package/lib/components/OrderEntryComponents/common/FormAmountFields.js +5 -0
  40. package/lib/components/OrderEntryComponents/common/TwapScheduleFields.js +98 -0
  41. package/lib/components/OrderEntryComponents/defaultForm/OrderEntryAnchoring.js +86 -39
  42. package/lib/components/OrderEntryComponents/defaultForm/OrderEntryAnchoring.test.js +326 -0
  43. package/lib/components/OrderEntryComponents/defaultForm/OrderEntryContainer.js +10 -2
  44. package/lib/components/OrderHistoryComponents/DepositsStatus/DepositsStatusComponent.js +1 -1
  45. package/lib/components/OrderHistoryComponents/DepositsStatus/DepositsStatusComponent.test.js +99 -0
  46. package/lib/components/OrderHistoryComponents/InactiveOrders/InactiveOrdersComponent.js +1 -1
  47. package/lib/components/OrderHistoryComponents/OpenOrders/OpenOrdersComponent.js +1 -1
  48. package/lib/components/OrderHistoryComponents/WithdrawStatus/WithdrawStatusComponent.js +1 -1
  49. package/lib/components/OrderHistoryComponents/WithdrawStatus/WithdrawStatusComponent.test.js +113 -0
  50. package/lib/components/Settings/ProfileAndSecurity/PasskeysSettingsCard/PasskeysSettingsCard.css +108 -0
  51. package/lib/components/Settings/ProfileAndSecurity/PasskeysSettingsCard/PasskeysSettingsCard.test.js +983 -0
  52. package/lib/components/Settings/ProfileAndSecurity/PasskeysSettingsCard/PasskeysSettingsCardComponent.js +500 -0
  53. package/lib/components/Settings/ProfileAndSecurity/PasskeysSettingsCard/index.js +9 -0
  54. package/lib/components/Settings/ProfileAndSecurity/ProfileSettingsCard/ProfileForm/SsoLinkRowComponent.css +4 -0
  55. package/lib/components/Settings/ProfileAndSecurity/ProfileSettingsCard/ProfileForm/SsoLinkRowComponent.js +29 -17
  56. package/lib/components/Settings/ProfileAndSecurity/ProfileSettingsCard/ProfileForm/SsoLinkRowComponent.test.js +135 -0
  57. package/lib/components/Settings/ProfileAndSecurity/TwoFactorAuthSettingsCard/EnableTwoFactorAuth/EnableTwoFactorAuthComponent.js +12 -4
  58. package/lib/components/Settings/ProfileAndSecurity/TwoFactorAuthSettingsCard/EnableTwoFactorAuth/EnableTwoFactorAuthComponent.test.js +268 -0
  59. package/lib/components/TwoFactorAuthForm/TwoFactorAuthForm.test.js +475 -0
  60. package/lib/components/TwoFactorAuthForm/TwoFactorAuthFormComponent.js +26 -5
  61. package/lib/components/TwoFactorAuthForm/TwoFactorAuthFormContainer.js +50 -32
  62. package/lib/components/common/APAutoTabInput/APAutoTabInput.js +5 -2
  63. package/lib/components/common/APSelect/APSelect.js +3 -1
  64. package/lib/components/common/ErrorBoundary/ErrorBoundary.css +35 -0
  65. package/lib/components/common/ErrorBoundary/ErrorBoundary.js +87 -0
  66. package/lib/config/CONFIG.md +4 -0
  67. package/lib/config/configDefault.json +2 -1
  68. package/lib/constants/sendOrder/orderEntryFormConstants.js +23 -4
  69. package/lib/constants/sendOrder/timeInForceConstants.js +3 -1
  70. package/lib/constants/sendOrder/twapRejectReasons.js +26 -0
  71. package/lib/helpers/errorTextFormatter.js +13 -4
  72. package/lib/helpers/errorTextFormatter.test.js +26 -0
  73. package/lib/helpers/orderHistoryHelper.js +13 -1
  74. package/lib/helpers/orderHistoryHelper.test.js +58 -13
  75. package/lib/helpers/passkeyApi.js +228 -0
  76. package/lib/helpers/passkeyApi.test.js +171 -0
  77. package/lib/helpers/placeOrderHelper.js +76 -61
  78. package/lib/helpers/placeOrderHelper.test.js +169 -10
  79. package/lib/helpers/recalculateOrderHelper.js +4 -1
  80. package/lib/helpers/recalculateOrderHelper.test.js +88 -2
  81. package/lib/helpers/twapOrderHelper.js +265 -0
  82. package/lib/helpers/twapOrderHelper.test.js +467 -0
  83. package/lib/helpers/twoFactorAuthCancellation.js +38 -0
  84. package/lib/helpers/webauthnHelper.js +300 -0
  85. package/lib/helpers/webauthnHelper.test.js +199 -0
  86. package/lib/hocs/forAccount.js +33 -0
  87. package/lib/hocs/forAccount.test.js +50 -0
  88. package/lib/hocs/forVerified.js +16 -2
  89. package/lib/hocs/withAuthentication.js +3 -1
  90. package/lib/hocs/withOneSubmission.js +168 -0
  91. package/lib/index.js +3 -2
  92. package/lib/layouts/HeaderLayout/HeaderLayout.js +2 -1
  93. package/lib/layouts/WalletsLayout/WalletsLayoutContainer.js +3 -1
  94. package/lib/layouts/WalletsLayout/WalletsLayoutContainer.test.js +84 -0
  95. package/lib/redux/actions/apiActions.js +77 -9
  96. package/lib/redux/actions/apiActions.test.js +233 -0
  97. package/lib/redux/actions/authActions.js +514 -198
  98. package/lib/redux/actions/authActions.test.js +627 -47
  99. package/lib/redux/actions/depositActions.js +1 -1
  100. package/lib/redux/actions/depositActions.test.js +100 -30
  101. package/lib/redux/actions/fusionAuthActions.test.js +265 -84
  102. package/lib/redux/actions/interestAccountActions.js +12 -3
  103. package/lib/redux/actions/interestAccountActions.test.js +73 -0
  104. package/lib/redux/actions/modalActions.js +1 -0
  105. package/lib/redux/actions/orderEntryActions.blockTrade.test.js +306 -0
  106. package/lib/redux/actions/orderEntryActions.js +74 -22
  107. package/lib/redux/actions/orderEntryActions.test.js +63 -11
  108. package/lib/redux/actions/orderHistoryActions.js +20 -8
  109. package/lib/redux/actions/orderHistoryActions.test.js +63 -0
  110. package/lib/redux/actions/userActions.js +379 -179
  111. package/lib/redux/actions/userActions.test.js +925 -234
  112. package/lib/redux/actions/withdrawActions.js +62 -29
  113. package/lib/redux/actions/withdrawActions.test.js +246 -73
  114. package/lib/redux/actions/withdrawActions.travelRule.test.js +17 -3
  115. package/lib/redux/margin/actions/marginActions.js +6 -3
  116. package/lib/redux/margin/actions/marginActions.test.js +166 -0
  117. package/lib/redux/middlewares/authMiddleware.js +5 -0
  118. package/lib/redux/middlewares/authMiddleware.test.js +88 -29
  119. package/lib/redux/reducers/authReducer.js +1 -0
  120. package/lib/redux/reducers/authReducer.test.js +38 -0
  121. package/lib/redux/reducers/userReducer.js +10 -0
  122. package/lib/redux/reducers/userReducer.test.js +29 -0
  123. package/lib/redux/selectors/orderEntrySelector.js +19 -8
  124. package/lib/redux/selectors/orderEntrySelector.test.js +209 -0
  125. package/lib/redux/selectors/orderTotalSelector.test.js +40 -1
  126. package/lib/redux/selectors/recentActivitySelector.js +8 -2
  127. package/lib/redux/selectors/recentActivitySelector.v2.test.js +33 -0
  128. package/lib/redux/selectors/userSelectors.js +6 -1
  129. package/lib/redux/selectors/userSelectors.test.js +28 -0
  130. package/lib/services/fms/fms.js +2 -0
  131. package/lib/services/fms/fms.test.js +35 -0
  132. package/package.json +4 -4
@@ -7,6 +7,7 @@ var actions = _interopRequireWildcard(require("./withdrawActions"));
7
7
  var apiActions = _interopRequireWildcard(require("./apiActions"));
8
8
  var snackbarActions = _interopRequireWildcard(require("./snackbarActions"));
9
9
  var _withdrawSubscriptionService = _interopRequireDefault(require("../../services/subscriptions/withdrawSubscriptionService"));
10
+ var _twoFactorAuthCancellation = require("../../helpers/twoFactorAuthCancellation");
10
11
  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 _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
11
12
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
12
13
  function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
@@ -15,14 +16,19 @@ function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.
15
16
  function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
16
17
  jest.mock('./apiActions', function () {
17
18
  var returnValue = {};
19
+ var rejection = null;
18
20
  return {
19
21
  callAPI: jest.fn(function () {
20
22
  return function () {
21
- return Promise.resolve(returnValue);
23
+ return rejection ? Promise.reject(rejection) : Promise.resolve(returnValue);
22
24
  };
23
25
  }),
24
26
  setReturnValue: function setReturnValue(value) {
25
27
  returnValue = value;
28
+ rejection = null;
29
+ },
30
+ setRejection: function setRejection(error) {
31
+ rejection = error;
26
32
  }
27
33
  };
28
34
  });
@@ -338,6 +344,8 @@ describe('withdrawActions', function () {
338
344
  }),
339
345
  TemplateType: 'Standard',
340
346
  AccountProviderId: 1
347
+ }, {
348
+ rejectOnCancel: true
341
349
  });
342
350
  });
343
351
  it('should show a snackbar with error message if request fails', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9() {
@@ -359,9 +367,127 @@ describe('withdrawActions', function () {
359
367
  }
360
368
  }, _callee9);
361
369
  })));
362
- it('should dispatch RECEIVE_WITHDRAW_WORKFLOW_INFO action if withdraw workflow data comes back in the response', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0() {
363
- return _regenerator().w(function (_context0) {
364
- while (1) switch (_context0.n) {
370
+ it.each([['a 2FA refusal without result', {
371
+ Authenticated: false,
372
+ errormsg: 'two-factor authentication is not enabled'
373
+ }], ['an empty object', {}], ['a null reply', null]])('shows a rejection and adds no ticket when the response is %s', /*#__PURE__*/function () {
374
+ var _ref0 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(_label, reply) {
375
+ return _regenerator().w(function (_context0) {
376
+ while (1) switch (_context0.n) {
377
+ case 0:
378
+ apiActions.setReturnValue(reply);
379
+ _context0.n = 1;
380
+ return store.dispatch(actions.createWithdrawTicket({
381
+ ProductId: 1,
382
+ Amount: 100
383
+ }));
384
+ case 1:
385
+ expect(snackbarActions.showSnack).toHaveBeenCalledWith(expect.objectContaining({
386
+ id: 'withdrawRejectSnack',
387
+ type: 'warning'
388
+ }));
389
+ expect(snackbarActions.showSnack).not.toHaveBeenCalledWith(expect.objectContaining({
390
+ id: 'withdrawSuccessSnack'
391
+ }));
392
+ expect(store.getActions()).not.toContainEqual(expect.objectContaining({
393
+ type: actions.RECEIVE_WITHDRAW_TICKET
394
+ }));
395
+ expect(apiActions.callAPI).not.toHaveBeenCalledWith('GetWithdrawTickets', expect.any(Object));
396
+ case 2:
397
+ return _context0.a(2);
398
+ }
399
+ }, _callee0);
400
+ }));
401
+ return function (_x, _x2) {
402
+ return _ref0.apply(this, arguments);
403
+ };
404
+ }());
405
+ it('shows the success confirmation and no rejection for a confirmed success', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1() {
406
+ return _regenerator().w(function (_context1) {
407
+ while (1) switch (_context1.n) {
408
+ case 0:
409
+ apiActions.setReturnValue({
410
+ result: true,
411
+ detail: '123456789'
412
+ });
413
+ _context1.n = 1;
414
+ return store.dispatch(actions.createWithdrawTicket({
415
+ ProductId: 1,
416
+ Amount: 100
417
+ }));
418
+ case 1:
419
+ expect(snackbarActions.showSnack).toHaveBeenCalledWith(expect.objectContaining({
420
+ id: 'withdrawSuccessSnack',
421
+ type: 'success'
422
+ }));
423
+ expect(snackbarActions.showSnack).not.toHaveBeenCalledWith(expect.objectContaining({
424
+ id: 'withdrawRejectSnack'
425
+ }));
426
+ case 2:
427
+ return _context1.a(2);
428
+ }
429
+ }, _callee1);
430
+ })));
431
+ it('shows nothing and adds no ticket when the user dismisses the 2FA modal', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10() {
432
+ return _regenerator().w(function (_context10) {
433
+ while (1) switch (_context10.n) {
434
+ case 0:
435
+ apiActions.setRejection(new _twoFactorAuthCancellation.TwoFactorAuthCancelledError());
436
+ _context10.n = 1;
437
+ return store.dispatch(actions.createWithdrawTicket({
438
+ ProductId: 1,
439
+ Amount: 100
440
+ }));
441
+ case 1:
442
+ expect(snackbarActions.showSnack).not.toHaveBeenCalled();
443
+ expect(store.getActions()).not.toContainEqual(expect.objectContaining({
444
+ type: actions.RECEIVE_WITHDRAW_TICKET
445
+ }));
446
+ case 2:
447
+ return _context10.a(2);
448
+ }
449
+ }, _callee10);
450
+ })));
451
+ it('rethrows errors that are not a 2FA dismissal', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11() {
452
+ return _regenerator().w(function (_context11) {
453
+ while (1) switch (_context11.n) {
454
+ case 0:
455
+ apiActions.setRejection(new Error('socket closed'));
456
+ _context11.n = 1;
457
+ return expect(store.dispatch(actions.createWithdrawTicket({
458
+ ProductId: 1,
459
+ Amount: 100
460
+ }))).rejects.toThrow('socket closed');
461
+ case 1:
462
+ return _context11.a(2);
463
+ }
464
+ }, _callee11);
465
+ })));
466
+ it('shows the backend message for a 2FA refusal', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12() {
467
+ return _regenerator().w(function (_context12) {
468
+ while (1) switch (_context12.n) {
469
+ case 0:
470
+ apiActions.setReturnValue({
471
+ Authenticated: false,
472
+ errormsg: 'two-factor authentication is not enabled'
473
+ });
474
+ _context12.n = 1;
475
+ return store.dispatch(actions.createWithdrawTicket({
476
+ ProductId: 1,
477
+ Amount: 100
478
+ }));
479
+ case 1:
480
+ expect(snackbarActions.showSnack).toHaveBeenCalledWith(expect.objectContaining({
481
+ text: 'two-factor authentication is not enabled'
482
+ }));
483
+ case 2:
484
+ return _context12.a(2);
485
+ }
486
+ }, _callee12);
487
+ })));
488
+ it('should dispatch RECEIVE_WITHDRAW_WORKFLOW_INFO action if withdraw workflow data comes back in the response', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13() {
489
+ return _regenerator().w(function (_context13) {
490
+ while (1) switch (_context13.n) {
365
491
  case 0:
366
492
  apiActions.setReturnValue({
367
493
  result: true,
@@ -370,7 +496,7 @@ describe('withdrawActions', function () {
370
496
  URL: 'http://localhost'
371
497
  })
372
498
  });
373
- _context0.n = 1;
499
+ _context13.n = 1;
374
500
  return store.dispatch(actions.createWithdrawTicket({
375
501
  ProductId: 1,
376
502
  Amount: 100
@@ -384,13 +510,13 @@ describe('withdrawActions', function () {
384
510
  }
385
511
  });
386
512
  case 2:
387
- return _context0.a(2);
513
+ return _context13.a(2);
388
514
  }
389
- }, _callee0);
515
+ }, _callee13);
390
516
  })));
391
- it('should dispatch CLOSE_SIDE_PANE action when request returns response with null values', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1() {
392
- return _regenerator().w(function (_context1) {
393
- while (1) switch (_context1.n) {
517
+ it('should dispatch CLOSE_SIDE_PANE action when request returns response with null values', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee14() {
518
+ return _regenerator().w(function (_context14) {
519
+ while (1) switch (_context14.n) {
394
520
  case 0:
395
521
  apiActions.setReturnValue({
396
522
  result: true,
@@ -399,7 +525,7 @@ describe('withdrawActions', function () {
399
525
  URL: null
400
526
  })
401
527
  });
402
- _context1.n = 1;
528
+ _context14.n = 1;
403
529
  return store.dispatch(actions.createWithdrawTicket({
404
530
  ProductId: 1,
405
531
  Amount: 100
@@ -410,13 +536,13 @@ describe('withdrawActions', function () {
410
536
  payload: 'Withdraws'
411
537
  });
412
538
  case 2:
413
- return _context1.a(2);
539
+ return _context14.a(2);
414
540
  }
415
- }, _callee1);
541
+ }, _callee14);
416
542
  })));
417
- it('should dispatch CLOSE_SIDE_PANE action when request returns response with ReplyObject === 0', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10() {
418
- return _regenerator().w(function (_context10) {
419
- while (1) switch (_context10.n) {
543
+ it('should dispatch CLOSE_SIDE_PANE action when request returns response with ReplyObject === 0', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15() {
544
+ return _regenerator().w(function (_context15) {
545
+ while (1) switch (_context15.n) {
420
546
  case 0:
421
547
  apiActions.setReturnValue({
422
548
  result: true,
@@ -425,7 +551,7 @@ describe('withdrawActions', function () {
425
551
  URL: null
426
552
  })
427
553
  });
428
- _context10.n = 1;
554
+ _context15.n = 1;
429
555
  return store.dispatch(actions.createWithdrawTicket({
430
556
  ProductId: 1,
431
557
  Amount: 100
@@ -436,19 +562,19 @@ describe('withdrawActions', function () {
436
562
  payload: 'Withdraws'
437
563
  });
438
564
  case 2:
439
- return _context10.a(2);
565
+ return _context15.a(2);
440
566
  }
441
- }, _callee10);
567
+ }, _callee15);
442
568
  })));
443
- it('should dispatch CLOSE_SIDE_PANE action when request returns standard response', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11() {
444
- return _regenerator().w(function (_context11) {
445
- while (1) switch (_context11.n) {
569
+ it('should dispatch CLOSE_SIDE_PANE action when request returns standard response', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee16() {
570
+ return _regenerator().w(function (_context16) {
571
+ while (1) switch (_context16.n) {
446
572
  case 0:
447
573
  apiActions.setReturnValue({
448
574
  result: true,
449
575
  detail: '123456789'
450
576
  });
451
- _context11.n = 1;
577
+ _context16.n = 1;
452
578
  return store.dispatch(actions.createWithdrawTicket({
453
579
  ProductId: 1,
454
580
  Amount: 100
@@ -459,19 +585,19 @@ describe('withdrawActions', function () {
459
585
  payload: 'Withdraws'
460
586
  });
461
587
  case 2:
462
- return _context11.a(2);
588
+ return _context16.a(2);
463
589
  }
464
- }, _callee11);
590
+ }, _callee16);
465
591
  })));
466
- it('should dispatch RECEIVE_WITHDRAW_TICKET action with expected params when successful', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12() {
467
- return _regenerator().w(function (_context12) {
468
- while (1) switch (_context12.n) {
592
+ it('should dispatch RECEIVE_WITHDRAW_TICKET action with expected params when successful', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee17() {
593
+ return _regenerator().w(function (_context17) {
594
+ while (1) switch (_context17.n) {
469
595
  case 0:
470
596
  apiActions.setReturnValue({
471
597
  result: true,
472
598
  detail: '123456789'
473
599
  });
474
- _context12.n = 1;
600
+ _context17.n = 1;
475
601
  return store.dispatch(actions.createWithdrawTicket({
476
602
  ProductId: 1,
477
603
  Amount: 100
@@ -485,19 +611,19 @@ describe('withdrawActions', function () {
485
611
  }
486
612
  });
487
613
  case 2:
488
- return _context12.a(2);
614
+ return _context17.a(2);
489
615
  }
490
- }, _callee12);
616
+ }, _callee17);
491
617
  })));
492
- it('should call GetWithdrawTickets via callAPI with expected params if successful', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13() {
493
- return _regenerator().w(function (_context13) {
494
- while (1) switch (_context13.n) {
618
+ it('should call GetWithdrawTickets via callAPI with expected params if successful', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee18() {
619
+ return _regenerator().w(function (_context18) {
620
+ while (1) switch (_context18.n) {
495
621
  case 0:
496
622
  apiActions.setReturnValue({
497
623
  result: true,
498
624
  detail: '123456789'
499
625
  });
500
- _context13.n = 1;
626
+ _context18.n = 1;
501
627
  return store.dispatch(actions.createWithdrawTicket({
502
628
  ProductId: 1,
503
629
  Amount: 100
@@ -509,20 +635,20 @@ describe('withdrawActions', function () {
509
635
  StartIndex: 0
510
636
  });
511
637
  case 2:
512
- return _context13.a(2);
638
+ return _context18.a(2);
513
639
  }
514
- }, _callee13);
640
+ }, _callee18);
515
641
  })));
516
642
  });
517
643
  describe('cancelWithdrawTicket', function () {
518
- it('should dispatch expected actions if response result is true', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee14() {
519
- return _regenerator().w(function (_context14) {
520
- while (1) switch (_context14.n) {
644
+ it('should dispatch expected actions if response result is true', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee19() {
645
+ return _regenerator().w(function (_context19) {
646
+ while (1) switch (_context19.n) {
521
647
  case 0:
522
648
  apiActions.setReturnValue({
523
649
  result: true
524
650
  });
525
- _context14.n = 1;
651
+ _context19.n = 1;
526
652
  return store.dispatch(actions.cancelWithdrawTicket({
527
653
  RequestCode: 1
528
654
  }));
@@ -532,43 +658,90 @@ describe('withdrawActions', function () {
532
658
  UserId: 1,
533
659
  AccountId: 1,
534
660
  RequestCode: 1
661
+ }, {
662
+ rejectOnCancel: true
535
663
  });
536
664
  expect(snackbarActions.showSnack).toHaveBeenCalled();
537
665
  expect(apiActions.callAPI).toHaveBeenCalledWith('GetWithdrawTickets', expect.any(Object));
538
666
  case 2:
539
- return _context14.a(2);
667
+ return _context19.a(2);
540
668
  }
541
- }, _callee14);
669
+ }, _callee19);
542
670
  })));
543
- it('should dispatch expected actions if response result is false', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15() {
544
- return _regenerator().w(function (_context15) {
545
- while (1) switch (_context15.n) {
671
+ it('should dispatch expected actions if response result is false', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee20() {
672
+ return _regenerator().w(function (_context20) {
673
+ while (1) switch (_context20.n) {
546
674
  case 0:
547
675
  apiActions.setReturnValue({
548
676
  result: false
549
677
  });
550
- _context15.n = 1;
678
+ _context20.n = 1;
551
679
  return store.dispatch(actions.cancelWithdrawTicket({
552
680
  RequestCode: 1
553
681
  }));
554
682
  case 1:
555
683
  expect(snackbarActions.showSnack).toHaveBeenCalled();
556
684
  case 2:
557
- return _context15.a(2);
685
+ return _context20.a(2);
558
686
  }
559
- }, _callee15);
687
+ }, _callee20);
688
+ })));
689
+ it.each([['a 2FA refusal without result', {
690
+ Authenticated: false,
691
+ errormsg: 'two-factor authentication is not enabled'
692
+ }], ['an empty object', {}], ['a null reply', null]])('shows a rejection and does not refetch when the response is %s', /*#__PURE__*/function () {
693
+ var _ref21 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee21(_label, reply) {
694
+ return _regenerator().w(function (_context21) {
695
+ while (1) switch (_context21.n) {
696
+ case 0:
697
+ apiActions.setReturnValue(reply);
698
+ _context21.n = 1;
699
+ return store.dispatch(actions.cancelWithdrawTicket({
700
+ RequestCode: 1
701
+ }));
702
+ case 1:
703
+ expect(snackbarActions.showSnack).toHaveBeenCalledWith(expect.objectContaining({
704
+ id: 'cancelWithdrawSnack',
705
+ type: 'warning'
706
+ }));
707
+ expect(apiActions.callAPI).not.toHaveBeenCalledWith('GetWithdrawTickets', expect.any(Object));
708
+ case 2:
709
+ return _context21.a(2);
710
+ }
711
+ }, _callee21);
712
+ }));
713
+ return function (_x3, _x4) {
714
+ return _ref21.apply(this, arguments);
715
+ };
716
+ }());
717
+ it('shows nothing when the user dismisses the 2FA modal', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee22() {
718
+ return _regenerator().w(function (_context22) {
719
+ while (1) switch (_context22.n) {
720
+ case 0:
721
+ apiActions.setRejection(new _twoFactorAuthCancellation.TwoFactorAuthCancelledError());
722
+ _context22.n = 1;
723
+ return store.dispatch(actions.cancelWithdrawTicket({
724
+ RequestCode: 1
725
+ }));
726
+ case 1:
727
+ expect(snackbarActions.showSnack).not.toHaveBeenCalled();
728
+ expect(apiActions.callAPI).not.toHaveBeenCalledWith('GetWithdrawTickets', expect.any(Object));
729
+ case 2:
730
+ return _context22.a(2);
731
+ }
732
+ }, _callee22);
560
733
  })));
561
734
  });
562
735
  describe('getWithdrawFee', function () {
563
- it('should dispatch expected actions if response result is true', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee16() {
564
- return _regenerator().w(function (_context16) {
565
- while (1) switch (_context16.n) {
736
+ it('should dispatch expected actions if response result is true', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee23() {
737
+ return _regenerator().w(function (_context23) {
738
+ while (1) switch (_context23.n) {
566
739
  case 0:
567
740
  apiActions.setReturnValue({
568
741
  result: true,
569
742
  FeeAmount: 2
570
743
  });
571
- _context16.n = 1;
744
+ _context23.n = 1;
572
745
  return store.dispatch(actions.getWithdrawFee(1, 2));
573
746
  case 1:
574
747
  expect(apiActions.callAPI).toHaveBeenCalledWith('GetWithdrawFee', expect.any(Object));
@@ -580,45 +753,45 @@ describe('withdrawActions', function () {
580
753
  }
581
754
  });
582
755
  case 2:
583
- return _context16.a(2);
756
+ return _context23.a(2);
584
757
  }
585
- }, _callee16);
758
+ }, _callee23);
586
759
  })));
587
- it('should dispatch expected actions if response result is false', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee17() {
588
- return _regenerator().w(function (_context17) {
589
- while (1) switch (_context17.n) {
760
+ it('should dispatch expected actions if response result is false', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee24() {
761
+ return _regenerator().w(function (_context24) {
762
+ while (1) switch (_context24.n) {
590
763
  case 0:
591
764
  apiActions.setReturnValue({
592
765
  result: false
593
766
  });
594
- _context17.n = 1;
767
+ _context24.n = 1;
595
768
  return store.dispatch(actions.getWithdrawFee(1, 2));
596
769
  case 1:
597
770
  expect(snackbarActions.showSnack).toHaveBeenCalled();
598
771
  case 2:
599
- return _context17.a(2);
772
+ return _context24.a(2);
600
773
  }
601
- }, _callee17);
774
+ }, _callee24);
602
775
  })));
603
776
  });
604
777
  describe('subscribeToWithdrawalTickets', function () {
605
- it('should call subscribeToWithdrawalTickets', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee18() {
606
- return _regenerator().w(function (_context18) {
607
- while (1) switch (_context18.n) {
778
+ it('should call subscribeToWithdrawalTickets', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee25() {
779
+ return _regenerator().w(function (_context25) {
780
+ while (1) switch (_context25.n) {
608
781
  case 0:
609
- _context18.n = 1;
782
+ _context25.n = 1;
610
783
  return store.dispatch(actions.subscribeToWithdrawalTickets());
611
784
  case 1:
612
785
  expect(_withdrawSubscriptionService["default"].subscribe).toHaveBeenCalled();
613
786
  case 2:
614
- return _context18.a(2);
787
+ return _context25.a(2);
615
788
  }
616
- }, _callee18);
789
+ }, _callee25);
617
790
  })));
618
- it("should dispatch ".concat(actions.ADD_WITHDRAWAL_TICKET, " action with update when subscribed"), /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee19() {
791
+ it("should dispatch ".concat(actions.ADD_WITHDRAWAL_TICKET, " action with update when subscribed"), /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee26() {
619
792
  var updates, expectedActions;
620
- return _regenerator().w(function (_context19) {
621
- while (1) switch (_context19.n) {
793
+ return _regenerator().w(function (_context26) {
794
+ while (1) switch (_context26.n) {
622
795
  case 0:
623
796
  updates = [];
624
797
  expectedActions = [{
@@ -626,14 +799,14 @@ describe('withdrawActions', function () {
626
799
  payload: updates
627
800
  }];
628
801
  _withdrawSubscriptionService["default"].setUpdateData(updates);
629
- _context19.n = 1;
802
+ _context26.n = 1;
630
803
  return store.dispatch(actions.subscribeToWithdrawalTickets());
631
804
  case 1:
632
805
  expect(store.getActions()).toEqual(expectedActions);
633
806
  case 2:
634
- return _context19.a(2);
807
+ return _context26.a(2);
635
808
  }
636
- }, _callee19);
809
+ }, _callee26);
637
810
  })));
638
811
  });
639
812
  });
@@ -136,6 +136,8 @@ describe('withdrawActions - Travel Rule Fields', function () {
136
136
  TemplateType: 'ToExternalBitcoinAddress',
137
137
  AccountProviderId: 34,
138
138
  Kytdetails: '{"TravelRuleCounterpartyFirstName":"John","TravelRuleCounterpartyLastName":"Doe","TravelRuleCounterpartyDob":"01/15/1990"}'
139
+ }, {
140
+ rejectOnCancel: true
139
141
  });
140
142
  expect(_sidePaneActions.closeWithdrawSidePane).toHaveBeenCalled();
141
143
  expect(_snackbarActions.showSnack).toHaveBeenCalledWith({
@@ -179,6 +181,8 @@ describe('withdrawActions - Travel Rule Fields', function () {
179
181
  TemplateType: 'ToExternalBitcoinAddress',
180
182
  AccountProviderId: 34,
181
183
  Kytdetails: '{"TravelRuleCounterpartyLastName":"Doe","TravelRuleCounterpartyDob":"01/15/1990"}'
184
+ }, {
185
+ rejectOnCancel: true
182
186
  });
183
187
  case 2:
184
188
  return _context2.a(2);
@@ -214,7 +218,9 @@ describe('withdrawActions - Travel Rule Fields', function () {
214
218
  TemplateType: 'ToExternalBitcoinAddress',
215
219
  AccountProviderId: 34
216
220
  };
217
- expect(_apiActions.callAPI).toHaveBeenCalledWith('CreateWithdrawTicket', expectedCall);
221
+ expect(_apiActions.callAPI).toHaveBeenCalledWith('CreateWithdrawTicket', expectedCall, {
222
+ rejectOnCancel: true
223
+ });
218
224
 
219
225
  // Should not include Kytdetails
220
226
  actualCall = _apiActions.callAPI.mock.calls[0][1];
@@ -258,7 +264,9 @@ describe('withdrawActions - Travel Rule Fields', function () {
258
264
  TemplateType: 'ToExternalBitcoinAddress',
259
265
  AccountProviderId: 34
260
266
  };
261
- expect(_apiActions.callAPI).toHaveBeenCalledWith('CreateWithdrawTicket', expectedCall);
267
+ expect(_apiActions.callAPI).toHaveBeenCalledWith('CreateWithdrawTicket', expectedCall, {
268
+ rejectOnCancel: true
269
+ });
262
270
 
263
271
  // Should not include Kytdetails
264
272
  actualCall = _apiActions.callAPI.mock.calls[0][1];
@@ -297,6 +305,8 @@ describe('withdrawActions - Travel Rule Fields', function () {
297
305
  TemplateType: 'ToExternalBitcoinAddress',
298
306
  AccountProviderId: 34,
299
307
  Kytdetails: '{"TravelRuleCounterpartyDob":"01/15/1990"}'
308
+ }, {
309
+ rejectOnCancel: true
300
310
  });
301
311
  case 2:
302
312
  return _context5.a(2);
@@ -318,7 +328,9 @@ describe('withdrawActions - Travel Rule Fields', function () {
318
328
  case 1:
319
329
  expect(_apiActions.callAPI).toHaveBeenCalledWith('CreateWithdrawTicket', expect.objectContaining({
320
330
  Kytdetails: '{"TravelRuleCounterpartyFirstName":"John","TravelRuleCounterpartyLastName":"Doe","TravelRuleCounterpartyDob":"01/15/1990"}'
321
- }));
331
+ }), {
332
+ rejectOnCancel: true
333
+ });
322
334
  expect(_snackbarActions.showSnack).toHaveBeenCalledWith({
323
335
  id: 'withdrawRejectSnack',
324
336
  text: 'Travel Rule validation failed',
@@ -372,6 +384,8 @@ describe('withdrawActions - Travel Rule Fields', function () {
372
384
  TemplateType: 'ToExternalBitcoinAddress',
373
385
  AccountProviderId: 34,
374
386
  Kytdetails: '{"TravelRuleCounterpartyFirstName":"John","TravelRuleCounterpartyLastName":"Doe","TravelRuleCounterpartyDob":"01/15/1990"}'
387
+ }, {
388
+ rejectOnCancel: true
375
389
  });
376
390
  case 2:
377
391
  return _context7.a(2);
@@ -109,7 +109,8 @@ var getMarginInstruments = exports.getMarginInstruments = function getMarginInst
109
109
  }));
110
110
  case 1:
111
111
  instruments = _context2.v;
112
- dispatch(receiveMarginInstruments(instruments));
112
+ // An error reply is not a list. Selectors call .find on this value.
113
+ dispatch(receiveMarginInstruments(Array.isArray(instruments) ? instruments : []));
113
114
  _context2.n = 3;
114
115
  break;
115
116
  case 2:
@@ -162,9 +163,10 @@ var getAccountMarginBalances = exports.getAccountMarginBalances = function getAc
162
163
  _context3.n = 3;
163
164
  break;
164
165
  }
166
+ // An error reply is not a list. A selector calls .map on this value.
165
167
  dispatch({
166
168
  type: _actionTypes.RECEIVE_MARGIN_BALANCES,
167
- payload: responseObj
169
+ payload: Array.isArray(responseObj) ? responseObj : []
168
170
  });
169
171
  return _context3.a(2, true);
170
172
  case 3:
@@ -428,9 +430,10 @@ var getMarginProductsConfig = exports.getMarginProductsConfig = function getMarg
428
430
  }));
429
431
  case 2:
430
432
  res = _context7.v;
433
+ // An error reply is not a list.
431
434
  dispatch({
432
435
  type: _actionTypes.RECEIVE_MARGIN_PRODUCT_CONFIGS,
433
- payload: res
436
+ payload: Array.isArray(res) ? res : []
434
437
  });
435
438
  _context7.n = 4;
436
439
  break;