@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.
- package/lib/apex.integration.test.js +435 -0
- package/lib/apex.js +37 -1
- package/lib/apex.test.js +138 -0
- package/lib/components/2FA/PasskeyOption.js +126 -0
- package/lib/components/2FA/TwoFactorAuthComponent.js +24 -5
- package/lib/components/2FA/TwoFactorAuthComponent.test.js +94 -0
- package/lib/components/2FA/TwoFactorAuthContainer.js +94 -16
- package/lib/components/2FA/TwoFactorAuthContainer.test.js +412 -0
- package/lib/components/ConfirmBlockTradeModal/ConfirmBlockTradeModalContainer.js +34 -6
- package/lib/components/ConfirmBlockTradeModal/ConfirmBlockTradeModalContainer.test.js +298 -0
- package/lib/components/ConfirmOrderModal/ConfirmOrderModalComponent.js +26 -4
- package/lib/components/ConfirmOrderModal/ConfirmOrderModalContainer.js +4 -1
- package/lib/components/EnableTwoFactorAuth/Disable2FAForm.js +22 -7
- package/lib/components/EnableTwoFactorAuth/Disable2FAModal.js +15 -5
- package/lib/components/EnableTwoFactorAuth/Disable2FAModal.test.js +460 -0
- package/lib/components/EnableTwoFactorAuth/Disable2FAModalContainer.js +108 -16
- package/lib/components/EnableTwoFactorAuth/EnableTwoFactorAuthContainerFactory.js +3 -2
- package/lib/components/FusionAuth/UnlinkOAuthIdentityModal.css +13 -0
- package/lib/components/FusionAuth/UnlinkOAuthIdentityModal.js +246 -0
- package/lib/components/FusionAuth/UnlinkOAuthIdentityModal.test.js +521 -0
- package/lib/components/Login/LoginFormComponent.js +1 -1
- package/lib/components/OrderEntryComponents/advancedForm/AdvancedOrderFormContainer.js +2 -0
- package/lib/components/OrderEntryComponents/common/FormAmountFields.js +5 -0
- package/lib/components/OrderEntryComponents/common/TwapScheduleFields.js +98 -0
- package/lib/components/OrderEntryComponents/defaultForm/OrderEntryAnchoring.js +86 -39
- package/lib/components/OrderEntryComponents/defaultForm/OrderEntryAnchoring.test.js +326 -0
- package/lib/components/OrderEntryComponents/defaultForm/OrderEntryContainer.js +10 -2
- package/lib/components/OrderHistoryComponents/DepositsStatus/DepositsStatusComponent.js +1 -1
- package/lib/components/OrderHistoryComponents/DepositsStatus/DepositsStatusComponent.test.js +99 -0
- package/lib/components/OrderHistoryComponents/InactiveOrders/InactiveOrdersComponent.js +1 -1
- package/lib/components/OrderHistoryComponents/OpenOrders/OpenOrdersComponent.js +1 -1
- package/lib/components/OrderHistoryComponents/WithdrawStatus/WithdrawStatusComponent.js +1 -1
- package/lib/components/OrderHistoryComponents/WithdrawStatus/WithdrawStatusComponent.test.js +113 -0
- package/lib/components/Settings/ProfileAndSecurity/PasskeysSettingsCard/PasskeysSettingsCard.css +108 -0
- package/lib/components/Settings/ProfileAndSecurity/PasskeysSettingsCard/PasskeysSettingsCard.test.js +983 -0
- package/lib/components/Settings/ProfileAndSecurity/PasskeysSettingsCard/PasskeysSettingsCardComponent.js +500 -0
- package/lib/components/Settings/ProfileAndSecurity/PasskeysSettingsCard/index.js +9 -0
- package/lib/components/Settings/ProfileAndSecurity/ProfileSettingsCard/ProfileForm/SsoLinkRowComponent.css +4 -0
- package/lib/components/Settings/ProfileAndSecurity/ProfileSettingsCard/ProfileForm/SsoLinkRowComponent.js +29 -17
- package/lib/components/Settings/ProfileAndSecurity/ProfileSettingsCard/ProfileForm/SsoLinkRowComponent.test.js +135 -0
- package/lib/components/Settings/ProfileAndSecurity/TwoFactorAuthSettingsCard/EnableTwoFactorAuth/EnableTwoFactorAuthComponent.test.js +23 -1
- package/lib/components/TwoFactorAuthForm/TwoFactorAuthForm.test.js +475 -0
- package/lib/components/TwoFactorAuthForm/TwoFactorAuthFormComponent.js +26 -5
- package/lib/components/TwoFactorAuthForm/TwoFactorAuthFormContainer.js +50 -32
- package/lib/components/common/APAutoTabInput/APAutoTabInput.js +5 -2
- package/lib/components/common/APSelect/APSelect.js +3 -1
- package/lib/config/CONFIG.md +4 -0
- package/lib/config/configDefault.json +2 -1
- package/lib/constants/sendOrder/orderEntryFormConstants.js +23 -4
- package/lib/constants/sendOrder/timeInForceConstants.js +3 -1
- package/lib/constants/sendOrder/twapRejectReasons.js +26 -0
- package/lib/helpers/orderHistoryHelper.js +13 -1
- package/lib/helpers/orderHistoryHelper.test.js +58 -13
- package/lib/helpers/passkeyApi.js +228 -0
- package/lib/helpers/passkeyApi.test.js +171 -0
- package/lib/helpers/placeOrderHelper.js +76 -61
- package/lib/helpers/placeOrderHelper.test.js +169 -10
- package/lib/helpers/recalculateOrderHelper.js +4 -1
- package/lib/helpers/recalculateOrderHelper.test.js +88 -2
- package/lib/helpers/twapOrderHelper.js +265 -0
- package/lib/helpers/twapOrderHelper.test.js +467 -0
- package/lib/helpers/webauthnHelper.js +300 -0
- package/lib/helpers/webauthnHelper.test.js +199 -0
- package/lib/hocs/withOneSubmission.js +168 -0
- package/lib/redux/actions/apiActions.js +52 -1
- package/lib/redux/actions/apiActions.test.js +135 -0
- package/lib/redux/actions/authActions.js +514 -198
- package/lib/redux/actions/authActions.test.js +627 -47
- package/lib/redux/actions/depositActions.js +1 -1
- package/lib/redux/actions/depositActions.test.js +100 -30
- package/lib/redux/actions/fusionAuthActions.test.js +265 -84
- package/lib/redux/actions/modalActions.js +1 -0
- package/lib/redux/actions/orderEntryActions.blockTrade.test.js +306 -0
- package/lib/redux/actions/orderEntryActions.js +74 -22
- package/lib/redux/actions/orderEntryActions.test.js +63 -11
- package/lib/redux/actions/orderHistoryActions.js +9 -4
- package/lib/redux/actions/orderHistoryActions.test.js +63 -0
- package/lib/redux/actions/userActions.js +314 -177
- package/lib/redux/actions/userActions.test.js +844 -268
- package/lib/redux/margin/actions/marginActions.js +6 -3
- package/lib/redux/margin/actions/marginActions.test.js +166 -0
- package/lib/redux/middlewares/authMiddleware.js +5 -0
- package/lib/redux/middlewares/authMiddleware.test.js +88 -29
- package/lib/redux/reducers/authReducer.js +1 -0
- package/lib/redux/reducers/authReducer.test.js +38 -0
- package/lib/redux/selectors/orderEntrySelector.js +19 -8
- package/lib/redux/selectors/orderEntrySelector.test.js +209 -0
- package/lib/redux/selectors/orderTotalSelector.test.js +40 -1
- package/lib/services/fms/fms.js +2 -0
- package/lib/services/fms/fms.test.js +35 -0
- package/package.json +4 -4
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _TwoFactorAuthContainer = require("./TwoFactorAuthContainer");
|
|
4
|
+
var _passkeyApi = require("../../helpers/passkeyApi");
|
|
4
5
|
var _twoFactorAuthCancellation = require("../../helpers/twoFactorAuthCancellation");
|
|
5
6
|
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
7
|
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 }; })(); }
|
|
@@ -12,6 +13,12 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
12
13
|
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; }
|
|
13
14
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
14
15
|
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); }
|
|
16
|
+
jest.mock('../../helpers/passkeyApi', function () {
|
|
17
|
+
return {
|
|
18
|
+
PASSKEY_TFA_TYPE: 'WebAuthn',
|
|
19
|
+
answerWithPasskey: jest.fn()
|
|
20
|
+
};
|
|
21
|
+
});
|
|
15
22
|
describe('TwoFactorAuthContainer', function () {
|
|
16
23
|
var t = function t(key) {
|
|
17
24
|
return key;
|
|
@@ -38,6 +45,28 @@ describe('TwoFactorAuthContainer', function () {
|
|
|
38
45
|
}
|
|
39
46
|
};
|
|
40
47
|
};
|
|
48
|
+
describe('isPasskeyOnly', function () {
|
|
49
|
+
it('offers only the passkey for a passkey user, or when the gateway refuses a code alone', function () {
|
|
50
|
+
expect((0, _TwoFactorAuthContainer.isPasskeyOnly)({
|
|
51
|
+
TFaType: {
|
|
52
|
+
Value: 'WebAuthn'
|
|
53
|
+
}
|
|
54
|
+
})).toBe(true);
|
|
55
|
+
expect((0, _TwoFactorAuthContainer.isPasskeyOnly)({
|
|
56
|
+
TFaType: {
|
|
57
|
+
Value: 'Google'
|
|
58
|
+
},
|
|
59
|
+
authPasskeyOnly: true
|
|
60
|
+
})).toBe(true);
|
|
61
|
+
expect((0, _TwoFactorAuthContainer.isPasskeyOnly)({
|
|
62
|
+
TFaType: {
|
|
63
|
+
Value: 'Google'
|
|
64
|
+
},
|
|
65
|
+
authPasskeyOnly: false
|
|
66
|
+
})).toBe(false);
|
|
67
|
+
expect((0, _TwoFactorAuthContainer.isPasskeyOnly)({})).toBe(false);
|
|
68
|
+
});
|
|
69
|
+
});
|
|
41
70
|
describe('isTwoFactorRefusal', function () {
|
|
42
71
|
it('recognises both refusal shapes the gateway sends', function () {
|
|
43
72
|
expect((0, _TwoFactorAuthContainer.isTwoFactorRefusal)({
|
|
@@ -212,4 +241,387 @@ describe('TwoFactorAuthContainer', function () {
|
|
|
212
241
|
expect(close).toHaveBeenCalled();
|
|
213
242
|
});
|
|
214
243
|
});
|
|
244
|
+
describe('onPasskey', function () {
|
|
245
|
+
it('answers the protected endpoint with a passkey as TfaType WebAuthn', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7() {
|
|
246
|
+
var _submitWith7, props;
|
|
247
|
+
return _regenerator().w(function (_context7) {
|
|
248
|
+
while (1) switch (_context7.n) {
|
|
249
|
+
case 0:
|
|
250
|
+
_passkeyApi.answerWithPasskey.mockResolvedValueOnce('assertion');
|
|
251
|
+
_submitWith7 = submitWith({
|
|
252
|
+
result: true
|
|
253
|
+
}), props = _submitWith7.props;
|
|
254
|
+
_context7.n = 1;
|
|
255
|
+
return (0, _TwoFactorAuthContainer.onPasskey)(props)();
|
|
256
|
+
case 1:
|
|
257
|
+
expect(props.apiCall).toHaveBeenCalledWith({
|
|
258
|
+
TfaType: 'WebAuthn',
|
|
259
|
+
TFaCode: 'assertion',
|
|
260
|
+
Payload: '{}'
|
|
261
|
+
});
|
|
262
|
+
expect(props.close).toHaveBeenCalled();
|
|
263
|
+
case 2:
|
|
264
|
+
return _context7.a(2);
|
|
265
|
+
}
|
|
266
|
+
}, _callee7);
|
|
267
|
+
})));
|
|
268
|
+
it('keeps the modal open with the reason when the passkey prompt fails', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8() {
|
|
269
|
+
var _submitWith8, props;
|
|
270
|
+
return _regenerator().w(function (_context8) {
|
|
271
|
+
while (1) switch (_context8.n) {
|
|
272
|
+
case 0:
|
|
273
|
+
_passkeyApi.answerWithPasskey.mockRejectedValueOnce(Object.assign(new Error('x'), {
|
|
274
|
+
name: 'NotAllowedError'
|
|
275
|
+
}));
|
|
276
|
+
_submitWith8 = submitWith({
|
|
277
|
+
result: true
|
|
278
|
+
}), props = _submitWith8.props;
|
|
279
|
+
_context8.n = 1;
|
|
280
|
+
return expect((0, _TwoFactorAuthContainer.onPasskey)(props)()).rejects.toMatchObject({
|
|
281
|
+
errors: {
|
|
282
|
+
_error: 'The passkey request was canceled or timed out. Try again.'
|
|
283
|
+
}
|
|
284
|
+
});
|
|
285
|
+
case 1:
|
|
286
|
+
expect(props.apiCall).not.toHaveBeenCalled();
|
|
287
|
+
expect(props.close).not.toHaveBeenCalled();
|
|
288
|
+
case 2:
|
|
289
|
+
return _context8.a(2);
|
|
290
|
+
}
|
|
291
|
+
}, _callee8);
|
|
292
|
+
})));
|
|
293
|
+
});
|
|
294
|
+
describe('closing the modal during a passkey answer', function () {
|
|
295
|
+
var deferred = function deferred() {
|
|
296
|
+
var resolve;
|
|
297
|
+
var promise = new Promise(function (r) {
|
|
298
|
+
resolve = r;
|
|
299
|
+
});
|
|
300
|
+
return {
|
|
301
|
+
promise: promise,
|
|
302
|
+
resolve: resolve
|
|
303
|
+
};
|
|
304
|
+
};
|
|
305
|
+
var flush = function flush() {
|
|
306
|
+
return new Promise(function (r) {
|
|
307
|
+
return setTimeout(r, 0);
|
|
308
|
+
});
|
|
309
|
+
};
|
|
310
|
+
it('leaves the caller waiting for the gateway once the answer is on its way, as for a code', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9() {
|
|
311
|
+
var reply, _submitWith9, props, passkey, answering;
|
|
312
|
+
return _regenerator().w(function (_context9) {
|
|
313
|
+
while (1) switch (_context9.n) {
|
|
314
|
+
case 0:
|
|
315
|
+
reply = deferred();
|
|
316
|
+
_passkeyApi.answerWithPasskey.mockResolvedValueOnce('assertion');
|
|
317
|
+
_submitWith9 = submitWith({}, {
|
|
318
|
+
reject: jest.fn(),
|
|
319
|
+
apiCall: jest.fn(function () {
|
|
320
|
+
return reply.promise;
|
|
321
|
+
})
|
|
322
|
+
}), props = _submitWith9.props;
|
|
323
|
+
passkey = {};
|
|
324
|
+
answering = (0, _TwoFactorAuthContainer.onPasskey)(props, passkey)();
|
|
325
|
+
_context9.n = 1;
|
|
326
|
+
return flush();
|
|
327
|
+
case 1:
|
|
328
|
+
expect(props.apiCall).toHaveBeenCalled();
|
|
329
|
+
(0, _TwoFactorAuthContainer.onCancel)(props, passkey)();
|
|
330
|
+
expect(props.reject).not.toHaveBeenCalled();
|
|
331
|
+
expect(props.close).toHaveBeenCalled();
|
|
332
|
+
reply.resolve({
|
|
333
|
+
o: JSON.stringify({
|
|
334
|
+
result: true
|
|
335
|
+
})
|
|
336
|
+
});
|
|
337
|
+
_context9.n = 2;
|
|
338
|
+
return answering;
|
|
339
|
+
case 2:
|
|
340
|
+
expect(props.resolve).toHaveBeenCalledWith({
|
|
341
|
+
result: true
|
|
342
|
+
});
|
|
343
|
+
case 3:
|
|
344
|
+
return _context9.a(2);
|
|
345
|
+
}
|
|
346
|
+
}, _callee9);
|
|
347
|
+
})));
|
|
348
|
+
it('sends nothing when closed while the browser prompt is still open', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0() {
|
|
349
|
+
var prompt, _submitWith0, props, passkey, answering;
|
|
350
|
+
return _regenerator().w(function (_context0) {
|
|
351
|
+
while (1) switch (_context0.n) {
|
|
352
|
+
case 0:
|
|
353
|
+
prompt = deferred();
|
|
354
|
+
_passkeyApi.answerWithPasskey.mockReturnValueOnce(prompt.promise);
|
|
355
|
+
_submitWith0 = submitWith({
|
|
356
|
+
result: true
|
|
357
|
+
}, {
|
|
358
|
+
reject: jest.fn()
|
|
359
|
+
}), props = _submitWith0.props;
|
|
360
|
+
passkey = {};
|
|
361
|
+
answering = (0, _TwoFactorAuthContainer.onPasskey)(props, passkey)();
|
|
362
|
+
(0, _TwoFactorAuthContainer.onCancel)(props, passkey)();
|
|
363
|
+
expect((0, _twoFactorAuthCancellation.isTwoFactorAuthCancellation)(props.reject.mock.calls[0][0])).toBe(true);
|
|
364
|
+
prompt.resolve('assertion');
|
|
365
|
+
_context0.n = 1;
|
|
366
|
+
return answering;
|
|
367
|
+
case 1:
|
|
368
|
+
expect(props.apiCall).not.toHaveBeenCalled();
|
|
369
|
+
expect(props.resolve).not.toHaveBeenCalled();
|
|
370
|
+
case 2:
|
|
371
|
+
return _context0.a(2);
|
|
372
|
+
}
|
|
373
|
+
}, _callee0);
|
|
374
|
+
})));
|
|
375
|
+
});
|
|
376
|
+
describe('one answer at a time, whether a code or a passkey', function () {
|
|
377
|
+
var deferred = function deferred() {
|
|
378
|
+
var resolve;
|
|
379
|
+
var promise = new Promise(function (r) {
|
|
380
|
+
resolve = r;
|
|
381
|
+
});
|
|
382
|
+
return {
|
|
383
|
+
promise: promise,
|
|
384
|
+
resolve: resolve
|
|
385
|
+
};
|
|
386
|
+
};
|
|
387
|
+
var flush = function flush() {
|
|
388
|
+
return new Promise(function (r) {
|
|
389
|
+
return setTimeout(r, 0);
|
|
390
|
+
});
|
|
391
|
+
};
|
|
392
|
+
var ok = {
|
|
393
|
+
o: JSON.stringify({
|
|
394
|
+
result: true
|
|
395
|
+
})
|
|
396
|
+
};
|
|
397
|
+
|
|
398
|
+
// a blocked answer leaves its queued browser reply unused
|
|
399
|
+
beforeEach(function () {
|
|
400
|
+
return _passkeyApi.answerWithPasskey.mockReset();
|
|
401
|
+
});
|
|
402
|
+
|
|
403
|
+
// the form's ownProps and the passkey answer share the submission, as in the container
|
|
404
|
+
var setUp = function setUp() {
|
|
405
|
+
var reply = deferred();
|
|
406
|
+
var submission = {
|
|
407
|
+
onChange: jest.fn()
|
|
408
|
+
};
|
|
409
|
+
var _submitWith1 = submitWith({}, {
|
|
410
|
+
apiCall: jest.fn(function () {
|
|
411
|
+
return reply.promise;
|
|
412
|
+
}),
|
|
413
|
+
submission: submission
|
|
414
|
+
}),
|
|
415
|
+
props = _submitWith1.props;
|
|
416
|
+
return {
|
|
417
|
+
reply: reply,
|
|
418
|
+
submission: submission,
|
|
419
|
+
props: props,
|
|
420
|
+
code: function code() {
|
|
421
|
+
return (0, _TwoFactorAuthContainer.onSubmit)({
|
|
422
|
+
code: '000000'
|
|
423
|
+
}, jest.fn(), props);
|
|
424
|
+
}
|
|
425
|
+
};
|
|
426
|
+
};
|
|
427
|
+
it('sends nothing for a passkey used while a code is being verified', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1() {
|
|
428
|
+
var _setUp, reply, submission, props, code, coding;
|
|
429
|
+
return _regenerator().w(function (_context1) {
|
|
430
|
+
while (1) switch (_context1.n) {
|
|
431
|
+
case 0:
|
|
432
|
+
_setUp = setUp(), reply = _setUp.reply, submission = _setUp.submission, props = _setUp.props, code = _setUp.code;
|
|
433
|
+
_passkeyApi.answerWithPasskey.mockResolvedValueOnce('assertion');
|
|
434
|
+
coding = code();
|
|
435
|
+
_context1.n = 1;
|
|
436
|
+
return (0, _TwoFactorAuthContainer.onPasskey)(props, submission)();
|
|
437
|
+
case 1:
|
|
438
|
+
reply.resolve(ok);
|
|
439
|
+
_context1.n = 2;
|
|
440
|
+
return coding;
|
|
441
|
+
case 2:
|
|
442
|
+
expect(props.apiCall).toHaveBeenCalledTimes(1);
|
|
443
|
+
expect(props.apiCall).toHaveBeenCalledWith({
|
|
444
|
+
TfaType: 'Google',
|
|
445
|
+
TFaCode: '000000',
|
|
446
|
+
Payload: '{}'
|
|
447
|
+
});
|
|
448
|
+
expect(props.resolve).toHaveBeenCalledTimes(1);
|
|
449
|
+
case 3:
|
|
450
|
+
return _context1.a(2);
|
|
451
|
+
}
|
|
452
|
+
}, _callee1);
|
|
453
|
+
})));
|
|
454
|
+
it('sends nothing for a code submitted while a passkey answer is on its way', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10() {
|
|
455
|
+
var _setUp2, reply, submission, props, code, answering;
|
|
456
|
+
return _regenerator().w(function (_context10) {
|
|
457
|
+
while (1) switch (_context10.n) {
|
|
458
|
+
case 0:
|
|
459
|
+
_setUp2 = setUp(), reply = _setUp2.reply, submission = _setUp2.submission, props = _setUp2.props, code = _setUp2.code;
|
|
460
|
+
_passkeyApi.answerWithPasskey.mockResolvedValueOnce('assertion');
|
|
461
|
+
answering = (0, _TwoFactorAuthContainer.onPasskey)(props, submission)();
|
|
462
|
+
_context10.n = 1;
|
|
463
|
+
return flush();
|
|
464
|
+
case 1:
|
|
465
|
+
_context10.n = 2;
|
|
466
|
+
return code();
|
|
467
|
+
case 2:
|
|
468
|
+
reply.resolve(ok);
|
|
469
|
+
_context10.n = 3;
|
|
470
|
+
return answering;
|
|
471
|
+
case 3:
|
|
472
|
+
expect(props.apiCall).toHaveBeenCalledTimes(1);
|
|
473
|
+
expect(props.apiCall).toHaveBeenCalledWith({
|
|
474
|
+
TfaType: 'WebAuthn',
|
|
475
|
+
TFaCode: 'assertion',
|
|
476
|
+
Payload: '{}'
|
|
477
|
+
});
|
|
478
|
+
expect(props.resolve).toHaveBeenCalledTimes(1);
|
|
479
|
+
case 4:
|
|
480
|
+
return _context10.a(2);
|
|
481
|
+
}
|
|
482
|
+
}, _callee10);
|
|
483
|
+
})));
|
|
484
|
+
it('sends nothing for a code submitted while the browser prompt is open', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11() {
|
|
485
|
+
var _setUp3, reply, submission, props, code, prompt, answering;
|
|
486
|
+
return _regenerator().w(function (_context11) {
|
|
487
|
+
while (1) switch (_context11.n) {
|
|
488
|
+
case 0:
|
|
489
|
+
_setUp3 = setUp(), reply = _setUp3.reply, submission = _setUp3.submission, props = _setUp3.props, code = _setUp3.code;
|
|
490
|
+
prompt = deferred();
|
|
491
|
+
_passkeyApi.answerWithPasskey.mockReturnValueOnce(prompt.promise);
|
|
492
|
+
answering = (0, _TwoFactorAuthContainer.onPasskey)(props, submission)();
|
|
493
|
+
_context11.n = 1;
|
|
494
|
+
return code();
|
|
495
|
+
case 1:
|
|
496
|
+
expect(props.apiCall).not.toHaveBeenCalled();
|
|
497
|
+
prompt.resolve('assertion');
|
|
498
|
+
_context11.n = 2;
|
|
499
|
+
return flush();
|
|
500
|
+
case 2:
|
|
501
|
+
reply.resolve(ok);
|
|
502
|
+
_context11.n = 3;
|
|
503
|
+
return answering;
|
|
504
|
+
case 3:
|
|
505
|
+
expect(props.apiCall).toHaveBeenCalledTimes(1);
|
|
506
|
+
expect(props.apiCall).toHaveBeenCalledWith({
|
|
507
|
+
TfaType: 'WebAuthn',
|
|
508
|
+
TFaCode: 'assertion',
|
|
509
|
+
Payload: '{}'
|
|
510
|
+
});
|
|
511
|
+
case 4:
|
|
512
|
+
return _context11.a(2);
|
|
513
|
+
}
|
|
514
|
+
}, _callee11);
|
|
515
|
+
})));
|
|
516
|
+
it('disables both answers while one holds the submission, and enables them on the reply', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12() {
|
|
517
|
+
var _setUp4, reply, submission, code, coding;
|
|
518
|
+
return _regenerator().w(function (_context12) {
|
|
519
|
+
while (1) switch (_context12.n) {
|
|
520
|
+
case 0:
|
|
521
|
+
_setUp4 = setUp(), reply = _setUp4.reply, submission = _setUp4.submission, code = _setUp4.code;
|
|
522
|
+
coding = code();
|
|
523
|
+
expect(submission.onChange).toHaveBeenLastCalledWith(true);
|
|
524
|
+
reply.resolve(ok);
|
|
525
|
+
_context12.n = 1;
|
|
526
|
+
return coding;
|
|
527
|
+
case 1:
|
|
528
|
+
expect(submission.onChange).toHaveBeenLastCalledWith(false);
|
|
529
|
+
expect(submission.current).toBeFalsy();
|
|
530
|
+
case 2:
|
|
531
|
+
return _context12.a(2);
|
|
532
|
+
}
|
|
533
|
+
}, _callee12);
|
|
534
|
+
})));
|
|
535
|
+
it('lets the user try again with either answer after a refused one', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13() {
|
|
536
|
+
var submission, apiCall, _submitWith10, props;
|
|
537
|
+
return _regenerator().w(function (_context13) {
|
|
538
|
+
while (1) switch (_context13.n) {
|
|
539
|
+
case 0:
|
|
540
|
+
submission = {};
|
|
541
|
+
apiCall = jest.fn().mockResolvedValueOnce({
|
|
542
|
+
o: JSON.stringify({
|
|
543
|
+
TFaAuthenticated: false,
|
|
544
|
+
errMsg: 'Invalid code'
|
|
545
|
+
})
|
|
546
|
+
}).mockResolvedValueOnce(ok);
|
|
547
|
+
_submitWith10 = submitWith({}, {
|
|
548
|
+
apiCall: apiCall,
|
|
549
|
+
submission: submission
|
|
550
|
+
}), props = _submitWith10.props;
|
|
551
|
+
_passkeyApi.answerWithPasskey.mockResolvedValueOnce('assertion');
|
|
552
|
+
_context13.n = 1;
|
|
553
|
+
return expect((0, _TwoFactorAuthContainer.onSubmit)({
|
|
554
|
+
code: '000000'
|
|
555
|
+
}, jest.fn(), props)).rejects.toMatchObject({
|
|
556
|
+
errors: {
|
|
557
|
+
_error: 'Invalid code'
|
|
558
|
+
}
|
|
559
|
+
});
|
|
560
|
+
case 1:
|
|
561
|
+
_context13.n = 2;
|
|
562
|
+
return (0, _TwoFactorAuthContainer.onPasskey)(props, submission)();
|
|
563
|
+
case 2:
|
|
564
|
+
expect(apiCall).toHaveBeenCalledTimes(2);
|
|
565
|
+
expect(props.resolve).toHaveBeenCalledWith({
|
|
566
|
+
result: true
|
|
567
|
+
});
|
|
568
|
+
case 3:
|
|
569
|
+
return _context13.a(2);
|
|
570
|
+
}
|
|
571
|
+
}, _callee13);
|
|
572
|
+
})));
|
|
573
|
+
it('lets go when the passkey prompt fails, so a code can still be sent', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee14() {
|
|
574
|
+
var _setUp5, reply, submission, props, code, coding;
|
|
575
|
+
return _regenerator().w(function (_context14) {
|
|
576
|
+
while (1) switch (_context14.n) {
|
|
577
|
+
case 0:
|
|
578
|
+
_setUp5 = setUp(), reply = _setUp5.reply, submission = _setUp5.submission, props = _setUp5.props, code = _setUp5.code;
|
|
579
|
+
_passkeyApi.answerWithPasskey.mockRejectedValueOnce(Object.assign(new Error('x'), {
|
|
580
|
+
name: 'NotAllowedError'
|
|
581
|
+
}));
|
|
582
|
+
_context14.n = 1;
|
|
583
|
+
return expect((0, _TwoFactorAuthContainer.onPasskey)(props, submission)()).rejects.toBeDefined();
|
|
584
|
+
case 1:
|
|
585
|
+
coding = code();
|
|
586
|
+
reply.resolve(ok);
|
|
587
|
+
_context14.n = 2;
|
|
588
|
+
return coding;
|
|
589
|
+
case 2:
|
|
590
|
+
expect(props.apiCall).toHaveBeenCalledTimes(1);
|
|
591
|
+
case 3:
|
|
592
|
+
return _context14.a(2);
|
|
593
|
+
}
|
|
594
|
+
}, _callee14);
|
|
595
|
+
})));
|
|
596
|
+
it('lets go when the modal is closed while the browser prompt is open, so the next opening can answer', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15() {
|
|
597
|
+
var _setUp6, reply, submission, props, code, prompt, stale, coding;
|
|
598
|
+
return _regenerator().w(function (_context15) {
|
|
599
|
+
while (1) switch (_context15.n) {
|
|
600
|
+
case 0:
|
|
601
|
+
_setUp6 = setUp(), reply = _setUp6.reply, submission = _setUp6.submission, props = _setUp6.props, code = _setUp6.code;
|
|
602
|
+
prompt = deferred();
|
|
603
|
+
_passkeyApi.answerWithPasskey.mockReturnValueOnce(prompt.promise);
|
|
604
|
+
stale = (0, _TwoFactorAuthContainer.onPasskey)(props, submission)();
|
|
605
|
+
(0, _TwoFactorAuthContainer.onCancel)(props, submission)();
|
|
606
|
+
coding = code();
|
|
607
|
+
prompt.resolve('assertion');
|
|
608
|
+
_context15.n = 1;
|
|
609
|
+
return stale;
|
|
610
|
+
case 1:
|
|
611
|
+
reply.resolve(ok);
|
|
612
|
+
_context15.n = 2;
|
|
613
|
+
return coding;
|
|
614
|
+
case 2:
|
|
615
|
+
expect(props.apiCall).toHaveBeenCalledTimes(1);
|
|
616
|
+
expect(props.apiCall).toHaveBeenCalledWith({
|
|
617
|
+
TfaType: 'Google',
|
|
618
|
+
TFaCode: '000000',
|
|
619
|
+
Payload: '{}'
|
|
620
|
+
});
|
|
621
|
+
case 3:
|
|
622
|
+
return _context15.a(2);
|
|
623
|
+
}
|
|
624
|
+
}, _callee15);
|
|
625
|
+
})));
|
|
626
|
+
});
|
|
215
627
|
});
|
|
@@ -13,7 +13,9 @@ var _orderEntrySelector = require("../../redux/selectors/orderEntrySelector");
|
|
|
13
13
|
var _snackbarActions = require("../../redux/actions/snackbarActions");
|
|
14
14
|
var _orderFormTypes = require("../../constants/sendOrder/orderFormTypes");
|
|
15
15
|
var _instrumentPositionSelectors = require("../../redux/selectors/instrumentPositionSelectors");
|
|
16
|
+
var _errorTextFormatter = require("../../helpers/errorTextFormatter");
|
|
16
17
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
18
|
+
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); }
|
|
17
19
|
var mapStateToProps = function mapStateToProps(state) {
|
|
18
20
|
var form = state.form,
|
|
19
21
|
product = state.apexCore.product;
|
|
@@ -34,6 +36,16 @@ var mapStateToProps = function mapStateToProps(state) {
|
|
|
34
36
|
orderTotal: orderTotal
|
|
35
37
|
};
|
|
36
38
|
};
|
|
39
|
+
|
|
40
|
+
// t('Your block trade was not reported. Please try again.')
|
|
41
|
+
var GENERIC_FAILURE_TEXT = 'Your block trade was not reported. Please try again.';
|
|
42
|
+
var showBlockTradeFailure = function showBlockTradeFailure(dispatch, text) {
|
|
43
|
+
return dispatch((0, _snackbarActions.showSnack)({
|
|
44
|
+
id: 'confirmBlockTradeFail',
|
|
45
|
+
text: text || GENERIC_FAILURE_TEXT,
|
|
46
|
+
type: 'warning'
|
|
47
|
+
}));
|
|
48
|
+
};
|
|
37
49
|
var mapDispatchToProps = function mapDispatchToProps(dispatch, _ref) {
|
|
38
50
|
var useNewForm = _ref.useNewForm;
|
|
39
51
|
return {
|
|
@@ -41,16 +53,32 @@ var mapDispatchToProps = function mapDispatchToProps(dispatch, _ref) {
|
|
|
41
53
|
return dispatch((0, _orderEntryActions.placeOrder)(_orderFormTypes.orderFormTypes.block, form, {
|
|
42
54
|
useNewForm: useNewForm
|
|
43
55
|
})).then(function (result) {
|
|
56
|
+
// placeOrder already surfaced the failure, so leave the form filled in for a retry.
|
|
57
|
+
if (result === _orderEntryActions.ORDER_SUBMIT_FAILED) return;
|
|
58
|
+
|
|
59
|
+
// SubmitBlockTrade always replies with an object, so anything else means the call
|
|
60
|
+
// settled without a reply and the trade cannot be taken as reported.
|
|
61
|
+
if (!result || _typeof(result) !== 'object') {
|
|
62
|
+
showBlockTradeFailure(dispatch);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
44
65
|
if (result.status === 'Accepted') {
|
|
45
66
|
dispatch((0, _orderEntryActions.clearOrderForm)('reportBlockTrade'));
|
|
46
67
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
68
|
+
|
|
69
|
+
// The gateway rejects a bad request with { result: false, errormsg, errorcode, detail },
|
|
70
|
+
// and an order leg the OMS refuses with { status: 'Rejected', errormsg }.
|
|
71
|
+
if (result.status === 'Rejected' || result.result === false) {
|
|
72
|
+
// Most rejections carry no `detail`, and showSnack drops a snack with empty text, so
|
|
73
|
+
// fall back to the errorcode/errormsg pair, as sendOrder does. Without an errormsg,
|
|
74
|
+
// formatErrorText gives only a bare code or its own generic text, so use ours.
|
|
75
|
+
showBlockTradeFailure(dispatch, result.detail || (result.errormsg ? (0, _errorTextFormatter.formatErrorText)(result) : ''));
|
|
53
76
|
}
|
|
77
|
+
})["catch"](function (e) {
|
|
78
|
+
// Safety net for anything thrown outside the guarded RPC call, so the user is never
|
|
79
|
+
// left without a signal that the block trade went unreported.
|
|
80
|
+
console.error('confirmReport action error', e);
|
|
81
|
+
showBlockTradeFailure(dispatch);
|
|
54
82
|
});
|
|
55
83
|
}
|
|
56
84
|
};
|