@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
@@ -0,0 +1,209 @@
1
+ "use strict";
2
+
3
+ var _orderEntrySelector = require("./orderEntrySelector");
4
+ var _orderEntryFormConstants = require("../../constants/sendOrder/orderEntryFormConstants");
5
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
6
+ 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; }
7
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
8
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
9
+ jest.mock('../../config', function () {
10
+ return {
11
+ Trading: {
12
+ SpotAllowedOrderTypes: [],
13
+ MarginAllowedOrderTypes: []
14
+ },
15
+ OrderCalcBuffer: {
16
+ priceBuffer: 0
17
+ }
18
+ };
19
+ });
20
+ var TWAP = _orderEntryFormConstants.orderTypes.twap.displayName;
21
+ var formName = 'advancedOrderEntry';
22
+ var instrument = {
23
+ InstrumentId: 1,
24
+ Symbol: 'BTCUSD',
25
+ Product1: 1,
26
+ Product2: 2,
27
+ Product1Symbol: 'BTC',
28
+ Product2Symbol: 'USD',
29
+ PriceIncrement: 0.01,
30
+ QuantityIncrement: 0.1,
31
+ MinimumQuantity: 0.1
32
+ };
33
+ var makeState = function makeState(values) {
34
+ return {
35
+ apexCore: {
36
+ instrument: {
37
+ instruments: [instrument],
38
+ selectedInstrumentId: 1
39
+ },
40
+ product: {
41
+ products: [{
42
+ ProductId: 1,
43
+ Product: 'BTC',
44
+ ProductFullName: 'Bitcoin',
45
+ DecimalPlaces: 8
46
+ }, {
47
+ ProductId: 2,
48
+ Product: 'USD',
49
+ ProductFullName: 'US Dollar',
50
+ DecimalPlaces: 2
51
+ }]
52
+ },
53
+ level1: {
54
+ 1: {
55
+ InstrumentId: 1,
56
+ BestBid: 99000,
57
+ BestOffer: 101000
58
+ }
59
+ },
60
+ level2: {
61
+ buy: [{
62
+ Price: 99000,
63
+ Quantity: 10
64
+ }],
65
+ sell: [{
66
+ Price: 101000,
67
+ Quantity: 10
68
+ }]
69
+ }
70
+ },
71
+ form: _defineProperty({}, formName, {
72
+ values: values
73
+ }),
74
+ user: {
75
+ accounts: [{
76
+ AccountId: 1,
77
+ AccountType: 'Standard'
78
+ }],
79
+ selectedAccountId: 1
80
+ },
81
+ futures: {
82
+ instruments: {
83
+ selectedInstrumentId: null
84
+ }
85
+ }
86
+ };
87
+ };
88
+ describe('orderEntrySelector TWAP', function () {
89
+ describe('selectTwapSchedule', function () {
90
+ it('derives the schedule the engine runs from the form and the selected instrument', function () {
91
+ // 1 BTC in 6 slices at a 0.1 increment rounds the slice up to 0.2, which covers 1 BTC in 5 slices.
92
+ var state = makeState({
93
+ orderType: TWAP,
94
+ side: _orderEntryFormConstants.sellValue,
95
+ quantity: '1',
96
+ slices: '6',
97
+ durationMinutes: '60',
98
+ limitPrice: ''
99
+ });
100
+ var schedule = (0, _orderEntrySelector.selectTwapSchedule)(state, {
101
+ formName: formName
102
+ });
103
+ expect(schedule.byValue).toBe(false);
104
+ expect(schedule.sliceSize.toNumber()).toBe(0.2);
105
+ expect(schedule.sliceDecimalPlaces).toBe(1);
106
+ expect(schedule.sliceSymbol).toBe('BTC');
107
+ expect(schedule.requestedSlices).toBe(6);
108
+ expect(schedule.slices).toBe(5);
109
+ expect(schedule.intervalSeconds).toBe(720);
110
+ expect(schedule.sliceValue.toNumber()).toBe(0.2 * 99000);
111
+ expect(schedule.belowMinimumQuantity).toBe(false);
112
+ });
113
+ it('sizes a market-form buy by value, with the slice at the price decimals', function () {
114
+ var state = makeState({
115
+ orderType: TWAP,
116
+ side: _orderEntryFormConstants.buyValue,
117
+ quantity: '',
118
+ value: '1000',
119
+ slices: '3',
120
+ durationMinutes: '30',
121
+ limitPrice: ''
122
+ });
123
+ var schedule = (0, _orderEntrySelector.selectTwapSchedule)(state, {
124
+ formName: formName
125
+ });
126
+ expect(schedule.byValue).toBe(true);
127
+ expect(schedule.sliceSize.toNumber()).toBe(333.34);
128
+ expect(schedule.sliceDecimalPlaces).toBe(2);
129
+ expect(schedule.sliceSymbol).toBe('USD');
130
+ expect(schedule.slices).toBe(3);
131
+ });
132
+ });
133
+ describe('selectOrderPrice', function () {
134
+ it('prices a market-form TWAP at the touch on its side', function () {
135
+ var sell = makeState({
136
+ orderType: TWAP,
137
+ side: _orderEntryFormConstants.sellValue,
138
+ limitPrice: ''
139
+ });
140
+ var buy = makeState({
141
+ orderType: TWAP,
142
+ side: _orderEntryFormConstants.buyValue,
143
+ limitPrice: ''
144
+ });
145
+ expect((0, _orderEntrySelector.selectOrderPrice)(sell, {
146
+ formName: formName
147
+ })).toBe(99000);
148
+ expect((0, _orderEntrySelector.selectOrderPrice)(buy, {
149
+ formName: formName
150
+ })).toBe(101000);
151
+ });
152
+ it('prices a limit-form TWAP at its limit price', function () {
153
+ var state = makeState({
154
+ orderType: TWAP,
155
+ side: _orderEntryFormConstants.sellValue,
156
+ limitPrice: '100000'
157
+ });
158
+ expect((0, _orderEntrySelector.selectOrderPrice)(state, {
159
+ formName: formName
160
+ })).toBe('100000');
161
+ });
162
+ });
163
+ describe('orderTotalSelector', function () {
164
+ it('totals a market-form TWAP like a market order of the same size', function () {
165
+ var twap = makeState({
166
+ orderType: TWAP,
167
+ side: _orderEntryFormConstants.sellValue,
168
+ quantity: '2',
169
+ limitPrice: ''
170
+ });
171
+ var market = makeState({
172
+ orderType: _orderEntryFormConstants.orderTypes.market.displayName,
173
+ side: _orderEntryFormConstants.sellValue,
174
+ quantity: '2'
175
+ });
176
+ expect((0, _orderEntrySelector.orderTotalSelector)(twap, {
177
+ formName: formName
178
+ })).toBe((0, _orderEntrySelector.orderTotalSelector)(market, {
179
+ formName: formName
180
+ }));
181
+ expect((0, _orderEntrySelector.orderTotalSelector)(twap, {
182
+ formName: formName
183
+ })).toBe(2 * 99000);
184
+ });
185
+ it('totals a value-sized market-form buy at its value', function () {
186
+ var state = makeState({
187
+ orderType: TWAP,
188
+ side: _orderEntryFormConstants.buyValue,
189
+ anchoredField: 'value',
190
+ value: '1000',
191
+ limitPrice: ''
192
+ });
193
+ expect((0, _orderEntrySelector.orderTotalSelector)(state, {
194
+ formName: formName
195
+ })).toBe('1000');
196
+ });
197
+ it('totals a limit-form TWAP at limit price times quantity', function () {
198
+ var state = makeState({
199
+ orderType: TWAP,
200
+ side: _orderEntryFormConstants.sellValue,
201
+ quantity: '2',
202
+ limitPrice: '100000'
203
+ });
204
+ expect((0, _orderEntrySelector.orderTotalSelector)(state, {
205
+ formName: formName
206
+ })).toBe(200000);
207
+ });
208
+ });
209
+ });
@@ -2,6 +2,7 @@
2
2
 
3
3
  var _orderEntrySelector = require("./orderEntrySelector");
4
4
  var _orderEntryFormConstants = require("../../constants/sendOrder/orderEntryFormConstants");
5
+ var _placeOrderHelper = require("../../helpers/placeOrderHelper");
5
6
  var _bignumber = require("bignumber.js");
6
7
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
7
8
  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; }
@@ -29,13 +30,51 @@ jest.mock('../../helpers/placeOrderHelper', function () {
29
30
  })
30
31
  };
31
32
  });
33
+ jest.mock('./instrumentPositionSelectors', function () {
34
+ return _objectSpread(_objectSpread({}, jest.requireActual('./instrumentPositionSelectors')), {}, {
35
+ selectedInstrumentSelector: function selectedInstrumentSelector() {
36
+ return {
37
+ InstrumentId: 1
38
+ };
39
+ }
40
+ });
41
+ });
32
42
  describe('orderTotalSelector', function () {
43
+ var selectedInstrumentLevel1 = {
44
+ BestOffer: 11,
45
+ BestBid: 9,
46
+ LastTradedPx: 10
47
+ };
33
48
  var state = {
34
49
  apexCore: {
35
- level1: [],
50
+ level1: {
51
+ 1: selectedInstrumentLevel1,
52
+ 2: {
53
+ BestOffer: 99,
54
+ BestBid: 98,
55
+ LastTradedPx: 98
56
+ }
57
+ },
36
58
  level2: []
37
59
  }
38
60
  };
61
+ it("reads the peg price from the selected instrument's level1, since the Order Entry form has no instrument field", function () {
62
+ var form = {
63
+ orderType: _orderEntryFormConstants.orderTypes.trailingStopMarket.displayName,
64
+ pegPriceType: '1',
65
+ trailingAmount: new _bignumber.BigNumber(2),
66
+ quantity: new _bignumber.BigNumber(2),
67
+ side: '0'
68
+ };
69
+ (0, _orderEntrySelector.orderTotalSelector)(_objectSpread(_objectSpread({}, state), {}, {
70
+ form: {
71
+ orderEntry: {
72
+ values: form
73
+ }
74
+ }
75
+ }), {});
76
+ expect(_placeOrderHelper.getPegPriceByType).toHaveBeenCalledWith(selectedInstrumentLevel1, form);
77
+ });
39
78
  it('should return correct totalAmount if orderType = market', function () {
40
79
  var form = {
41
80
  orderType: _orderEntryFormConstants.orderTypes.market.displayName
@@ -7,6 +7,7 @@ exports.getFMS = getFMS;
7
7
  exports.getFMSGateway = getFMSGateway;
8
8
  var _alphapointApexApi = require("alphapoint-apex-api");
9
9
  var _config = _interopRequireDefault(require("../../config"));
10
+ var _apex = require("../../apex");
10
11
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
11
12
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
12
13
  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; }
@@ -81,5 +82,6 @@ function getFMS(sessionToken, gateway) {
81
82
  }
82
83
  }, options));
83
84
  ws.connection.standardCallback = function () {};
85
+ (0, _apex.routeErrorReplies)(ws.connection);
84
86
  return ws;
85
87
  }
@@ -57,4 +57,39 @@ describe('getFMSGateway', function () {
57
57
  return fms.getFMS('session-token-abc');
58
58
  }).toThrow(/FMS gateway is not provided/);
59
59
  });
60
+ });
61
+ describe('getFMS error-reply routing', function () {
62
+ beforeEach(function () {
63
+ jest.clearAllMocks();
64
+ jest.resetModules();
65
+ localStorageMock.getItem.mockReturnValue(null);
66
+ });
67
+ it('subscribes to the FMS socket so m:5 replies settle pending calls', function () {
68
+ var _require3 = require('alphapoint-apex-api'),
69
+ APEX = _require3.APEX;
70
+ var subscribe = jest.fn();
71
+ APEX.mockImplementationOnce(function APEXWithSocket() {
72
+ this.standardCallback = null;
73
+ this.callbacks = {};
74
+ this.ws = {
75
+ subscribe: subscribe
76
+ };
77
+ });
78
+ var _require4 = require('./fms'),
79
+ getFMS = _require4.getFMS;
80
+ var _getFMS = getFMS('token', 'wss://fms.example/WSFMSGateway'),
81
+ connection = _getFMS.connection;
82
+ var callback = jest.fn();
83
+ connection.callbacks[2] = callback;
84
+ var frame = {
85
+ m: 5,
86
+ i: 2,
87
+ n: 'GetFuturesPositions',
88
+ o: 'Endpoint Not Found'
89
+ };
90
+ subscribe.mock.calls[0][0](frame);
91
+ expect(subscribe).toHaveBeenCalledTimes(1);
92
+ expect(callback).toHaveBeenCalledWith(frame);
93
+ expect(connection.callbacks[2]).toBeUndefined();
94
+ });
60
95
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alphapoint/apex-web",
3
- "version": "5.7.0",
3
+ "version": "5.8.0",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -9,7 +9,7 @@
9
9
  "node": ">=18.0.0"
10
10
  },
11
11
  "dependencies": {
12
- "@alphapoint/apex-chart-react": "^5.7.0",
12
+ "@alphapoint/apex-chart-react": "^5.8.0",
13
13
  "@dnd-kit/core": "^6.1.0",
14
14
  "@dnd-kit/modifiers": "^7.0.0",
15
15
  "@dnd-kit/sortable": "^8.0.0",
@@ -71,7 +71,7 @@
71
71
  "@babel/runtime": "^7.23.4",
72
72
  "babel-jest": "^27.5.1",
73
73
  "cross-env": "^7.0.3",
74
- "eslint-config-apex": "^5.7.0",
74
+ "eslint-config-apex": "^5.8.0",
75
75
  "fs-extra": "^11.1.1",
76
76
  "identity-obj-proxy": "^3.0.0",
77
77
  "jest": "^27.5.1",
@@ -133,5 +133,5 @@
133
133
  "files": [
134
134
  "lib"
135
135
  ],
136
- "gitHead": "9bda12ad92a6d35c088434deb29b112dbce07bde"
136
+ "gitHead": "766058d63ba1a63e754c0dda13e8097c2545d89d"
137
137
  }