@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.
- 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 +139 -27
- package/lib/components/2FA/TwoFactorAuthContainer.test.js +627 -0
- package/lib/components/AccountsDropdown/AccountsDropdownComponent.css +6 -0
- package/lib/components/AccountsDropdown/AccountsDropdownComponent.js +6 -2
- package/lib/components/AccountsDropdown/AccountsDropdownComponent.test.js +43 -0
- package/lib/components/AccountsDropdown/AccountsDropdownContainer.js +3 -1
- package/lib/components/BalancesList/BalancesListContainer.js +4 -1
- 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/DigitalAssets/digitalAssetsPriceLabel.test.js +238 -0
- 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/EnableTwoFactorAuthComponent.js +7 -0
- package/lib/components/EnableTwoFactorAuth/EnableTwoFactorAuthComponent.test.js +105 -0
- package/lib/components/EnableTwoFactorAuth/EnableTwoFactorAuthContainerFactory.js +15 -3
- 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/InstrumentPositions/InstrumentPositionsContainer.js +4 -1
- package/lib/components/Login/LoginFormComponent.js +1 -1
- package/lib/components/MarginBalances/MarginDepositWithdraw/MarginDepositModal/MarginDepositFormContainer.js +2 -1
- package/lib/components/NoAccountBanner/NoAccountBanner.css +9 -0
- package/lib/components/NoAccountBanner/NoAccountBanner.js +58 -0
- package/lib/components/NoAccountBanner/index.js +16 -0
- package/lib/components/NoAccountPlaceholder/NoAccountPlaceholder.css +31 -0
- package/lib/components/NoAccountPlaceholder/NoAccountPlaceholder.js +33 -0
- package/lib/components/NoAccountPlaceholder/index.js +9 -0
- 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.js +12 -4
- package/lib/components/Settings/ProfileAndSecurity/TwoFactorAuthSettingsCard/EnableTwoFactorAuth/EnableTwoFactorAuthComponent.test.js +268 -0
- 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/components/common/ErrorBoundary/ErrorBoundary.css +35 -0
- package/lib/components/common/ErrorBoundary/ErrorBoundary.js +87 -0
- 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/errorTextFormatter.js +13 -4
- package/lib/helpers/errorTextFormatter.test.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/twoFactorAuthCancellation.js +38 -0
- package/lib/helpers/webauthnHelper.js +300 -0
- package/lib/helpers/webauthnHelper.test.js +199 -0
- package/lib/hocs/forAccount.js +33 -0
- package/lib/hocs/forAccount.test.js +50 -0
- package/lib/hocs/forVerified.js +16 -2
- package/lib/hocs/withAuthentication.js +3 -1
- package/lib/hocs/withOneSubmission.js +168 -0
- package/lib/index.js +3 -2
- package/lib/layouts/HeaderLayout/HeaderLayout.js +2 -1
- package/lib/layouts/WalletsLayout/WalletsLayoutContainer.js +3 -1
- package/lib/layouts/WalletsLayout/WalletsLayoutContainer.test.js +84 -0
- package/lib/redux/actions/apiActions.js +77 -9
- package/lib/redux/actions/apiActions.test.js +233 -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/interestAccountActions.js +12 -3
- package/lib/redux/actions/interestAccountActions.test.js +73 -0
- 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 +20 -8
- package/lib/redux/actions/orderHistoryActions.test.js +63 -0
- package/lib/redux/actions/userActions.js +379 -179
- package/lib/redux/actions/userActions.test.js +925 -234
- package/lib/redux/actions/withdrawActions.js +62 -29
- package/lib/redux/actions/withdrawActions.test.js +246 -73
- package/lib/redux/actions/withdrawActions.travelRule.test.js +17 -3
- 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/reducers/userReducer.js +10 -0
- package/lib/redux/reducers/userReducer.test.js +29 -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/redux/selectors/recentActivitySelector.js +8 -2
- package/lib/redux/selectors/recentActivitySelector.v2.test.js +33 -0
- package/lib/redux/selectors/userSelectors.js +6 -1
- package/lib/redux/selectors/userSelectors.test.js +28 -0
- package/lib/services/fms/fms.js +2 -0
- package/lib/services/fms/fms.test.js +35 -0
- package/package.json +4 -4
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
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); }
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.withdrawSubmission = exports.startSubmission = exports.promptThenSend = exports.endSubmission = exports["default"] = exports.answerOnce = void 0;
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
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 _t2 in e) "default" !== _t2 && {}.hasOwnProperty.call(e, _t2) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t2)) && (i.get || i.set) ? o(f, _t2, i) : f[_t2] = e[_t2]); return f; })(e, t); }
|
|
10
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
11
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
12
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
13
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
14
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
15
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
16
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
17
|
+
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 }; })(); }
|
|
18
|
+
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
|
|
19
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
20
|
+
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); }); }; }
|
|
21
|
+
// One 2FA answer at a time, whether a code or a passkey: the answered action must not be sent twice. A `submission`
|
|
22
|
+
// is shared by both answers and outlives one showing of the form. `current` is the answer holding it, from a click on
|
|
23
|
+
// Use a passkey (browser prompt included) or a code's submit until the gateway replies; `sending` says the request is
|
|
24
|
+
// on its way. `onChange` tells the form to disable both answers while one holds it.
|
|
25
|
+
var startSubmission = exports.startSubmission = function startSubmission(submission) {
|
|
26
|
+
if (submission.current) return null;
|
|
27
|
+
var owner = {};
|
|
28
|
+
submission.current = owner;
|
|
29
|
+
if (submission.onChange) submission.onChange(true);
|
|
30
|
+
return owner;
|
|
31
|
+
};
|
|
32
|
+
var endSubmission = exports.endSubmission = function endSubmission(submission, owner) {
|
|
33
|
+
if (!owner || submission.current !== owner) return;
|
|
34
|
+
submission.current = null;
|
|
35
|
+
submission.sending = false;
|
|
36
|
+
if (submission.onChange) submission.onChange(false);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/** Runs `answer` only when no other answer holds `submission`, and lets go of it once `answer` settles. */
|
|
40
|
+
var answerOnce = exports.answerOnce = /*#__PURE__*/function () {
|
|
41
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(submission, answer) {
|
|
42
|
+
var owner;
|
|
43
|
+
return _regenerator().w(function (_context) {
|
|
44
|
+
while (1) switch (_context.p = _context.n) {
|
|
45
|
+
case 0:
|
|
46
|
+
owner = startSubmission(submission);
|
|
47
|
+
if (owner) {
|
|
48
|
+
_context.n = 1;
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
return _context.a(2, undefined);
|
|
52
|
+
case 1:
|
|
53
|
+
_context.p = 1;
|
|
54
|
+
_context.n = 2;
|
|
55
|
+
return answer();
|
|
56
|
+
case 2:
|
|
57
|
+
return _context.a(2, _context.v);
|
|
58
|
+
case 3:
|
|
59
|
+
_context.p = 3;
|
|
60
|
+
endSubmission(submission, owner);
|
|
61
|
+
return _context.f(3);
|
|
62
|
+
case 4:
|
|
63
|
+
return _context.a(2);
|
|
64
|
+
}
|
|
65
|
+
}, _callee, null, [[1,, 3, 4]]);
|
|
66
|
+
}));
|
|
67
|
+
return function answerOnce(_x, _x2) {
|
|
68
|
+
return _ref.apply(this, arguments);
|
|
69
|
+
};
|
|
70
|
+
}();
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* A passkey answer: `prompt` asks the browser for it and `send` sends what the browser returned. It holds `submission`
|
|
74
|
+
* across both. Resolves to undefined, with nothing sent, when another answer holds the submission or when the answer
|
|
75
|
+
* was withdrawn while the browser prompt was open.
|
|
76
|
+
*/
|
|
77
|
+
var promptThenSend = exports.promptThenSend = /*#__PURE__*/function () {
|
|
78
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(submission, prompt, send) {
|
|
79
|
+
var owner, attempt, withdrawn, answer, _t;
|
|
80
|
+
return _regenerator().w(function (_context2) {
|
|
81
|
+
while (1) switch (_context2.p = _context2.n) {
|
|
82
|
+
case 0:
|
|
83
|
+
owner = startSubmission(submission);
|
|
84
|
+
if (owner) {
|
|
85
|
+
_context2.n = 1;
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
return _context2.a(2, undefined);
|
|
89
|
+
case 1:
|
|
90
|
+
submission.attempt = (submission.attempt || 0) + 1;
|
|
91
|
+
attempt = submission.attempt;
|
|
92
|
+
withdrawn = function withdrawn() {
|
|
93
|
+
return attempt !== submission.attempt;
|
|
94
|
+
};
|
|
95
|
+
_context2.p = 2;
|
|
96
|
+
_context2.p = 3;
|
|
97
|
+
_context2.n = 4;
|
|
98
|
+
return prompt();
|
|
99
|
+
case 4:
|
|
100
|
+
answer = _context2.v;
|
|
101
|
+
_context2.n = 7;
|
|
102
|
+
break;
|
|
103
|
+
case 5:
|
|
104
|
+
_context2.p = 5;
|
|
105
|
+
_t = _context2.v;
|
|
106
|
+
if (!withdrawn()) {
|
|
107
|
+
_context2.n = 6;
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
return _context2.a(2, undefined);
|
|
111
|
+
case 6:
|
|
112
|
+
throw _t;
|
|
113
|
+
case 7:
|
|
114
|
+
if (!withdrawn()) {
|
|
115
|
+
_context2.n = 8;
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
return _context2.a(2, undefined);
|
|
119
|
+
case 8:
|
|
120
|
+
submission.sending = true;
|
|
121
|
+
_context2.n = 9;
|
|
122
|
+
return send(answer);
|
|
123
|
+
case 9:
|
|
124
|
+
return _context2.a(2, _context2.v);
|
|
125
|
+
case 10:
|
|
126
|
+
_context2.p = 10;
|
|
127
|
+
endSubmission(submission, owner);
|
|
128
|
+
return _context2.f(10);
|
|
129
|
+
case 11:
|
|
130
|
+
return _context2.a(2);
|
|
131
|
+
}
|
|
132
|
+
}, _callee2, null, [[3, 5], [2,, 10, 11]]);
|
|
133
|
+
}));
|
|
134
|
+
return function promptThenSend(_x3, _x4, _x5) {
|
|
135
|
+
return _ref2.apply(this, arguments);
|
|
136
|
+
};
|
|
137
|
+
}();
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* The form was closed. An answer still waiting on the browser prompt is withdrawn, so nothing is sent for it, and it
|
|
141
|
+
* lets go of the submission so the next opening of the form can answer. An answer already on its way keeps the
|
|
142
|
+
* submission until the gateway replies.
|
|
143
|
+
*/
|
|
144
|
+
var withdrawSubmission = exports.withdrawSubmission = function withdrawSubmission(submission) {
|
|
145
|
+
submission.attempt = (submission.attempt || 0) + 1;
|
|
146
|
+
if (!submission.sending) endSubmission(submission, submission.current);
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Wraps a redux-form form so that its onSubmit (through its props) and a passkey answer share one `submission`, and
|
|
151
|
+
* passes `answering` while one of them holds it.
|
|
152
|
+
*/
|
|
153
|
+
var withOneSubmission = function withOneSubmission(Form) {
|
|
154
|
+
var WithOneSubmission = function WithOneSubmission(props) {
|
|
155
|
+
var submission = (0, _react.useRef)({}).current;
|
|
156
|
+
var _useState = (0, _react.useState)(false),
|
|
157
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
158
|
+
answering = _useState2[0],
|
|
159
|
+
setAnswering = _useState2[1];
|
|
160
|
+
submission.onChange = setAnswering;
|
|
161
|
+
return /*#__PURE__*/_react["default"].createElement(Form, _extends({}, props, {
|
|
162
|
+
submission: submission,
|
|
163
|
+
answering: answering
|
|
164
|
+
}));
|
|
165
|
+
};
|
|
166
|
+
return WithOneSubmission;
|
|
167
|
+
};
|
|
168
|
+
var _default = exports["default"] = withOneSubmission;
|
package/lib/index.js
CHANGED
|
@@ -13,6 +13,7 @@ var _routeTemplates = require("./routeTemplates");
|
|
|
13
13
|
var _indexHelper = require("./helpers/indexHelper");
|
|
14
14
|
var numberFormatter = _interopRequireWildcard(require("./helpers/numberFormatter"));
|
|
15
15
|
var _apexWebActions = _interopRequireDefault(require("./helpers/apexWebActions"));
|
|
16
|
+
var _ErrorBoundary = _interopRequireDefault(require("./components/common/ErrorBoundary/ErrorBoundary"));
|
|
16
17
|
var _registerServiceWorker = require("./registerServiceWorker");
|
|
17
18
|
var _config = _interopRequireDefault(require("./config"));
|
|
18
19
|
var _cssVarsPonyfill = _interopRequireDefault(require("css-vars-ponyfill"));
|
|
@@ -40,7 +41,7 @@ window.cssVariables = {};
|
|
|
40
41
|
});
|
|
41
42
|
var container = document.getElementById('root');
|
|
42
43
|
var root = (0, _client.createRoot)(container);
|
|
43
|
-
root.render(/*#__PURE__*/_react["default"].createElement(_reactRedux.Provider, {
|
|
44
|
+
root.render(/*#__PURE__*/_react["default"].createElement(_ErrorBoundary["default"], null, /*#__PURE__*/_react["default"].createElement(_reactRedux.Provider, {
|
|
44
45
|
store: _store["default"]
|
|
45
46
|
}, /*#__PURE__*/_react["default"].createElement(_reduxI18n["default"], {
|
|
46
47
|
translations: window.APEXTranslations || {
|
|
@@ -48,5 +49,5 @@ root.render(/*#__PURE__*/_react["default"].createElement(_reactRedux.Provider, {
|
|
|
48
49
|
}
|
|
49
50
|
}, /*#__PURE__*/_react["default"].createElement(_reactRouterDom.Router, {
|
|
50
51
|
history: _history["default"]
|
|
51
|
-
}, /*#__PURE__*/_react["default"].createElement(_App["default"], null)))));
|
|
52
|
+
}, /*#__PURE__*/_react["default"].createElement(_App["default"], null))))));
|
|
52
53
|
(0, _registerServiceWorker.unregister)();
|
|
@@ -8,8 +8,9 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
8
8
|
var _withAuthentication = _interopRequireDefault(require("../../hocs/withAuthentication"));
|
|
9
9
|
var _forVerified = _interopRequireDefault(require("../../hocs/forVerified"));
|
|
10
10
|
var _PageHeaderComponent = _interopRequireDefault(require("../../components/PageHeader/PageHeaderComponent"));
|
|
11
|
+
var _NoAccountBanner = require("../../components/NoAccountBanner");
|
|
11
12
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
12
13
|
var HeaderLayout = function HeaderLayout(props) {
|
|
13
|
-
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_PageHeaderComponent["default"], null), props.children);
|
|
14
|
+
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_PageHeaderComponent["default"], null), /*#__PURE__*/_react["default"].createElement(_NoAccountBanner.NoAccountBanner, null), props.children);
|
|
14
15
|
};
|
|
15
16
|
var _default = exports["default"] = (0, _withAuthentication["default"])((0, _forVerified["default"])(HeaderLayout));
|
|
@@ -18,7 +18,9 @@ var mapStateToProps = function mapStateToProps(state) {
|
|
|
18
18
|
selectedAccountId = _state$user.selectedAccountId,
|
|
19
19
|
AccountId = _state$user.userInfo.AccountId,
|
|
20
20
|
marginAccount = state.margin.accountInfo;
|
|
21
|
-
|
|
21
|
+
// Both ids are undefined for a user with no accounts, which would otherwise
|
|
22
|
+
// count as the margin account being selected.
|
|
23
|
+
var isMarginSelected = marginAccount.AccountId !== undefined && selectedAccountId === marginAccount.AccountId;
|
|
22
24
|
var spotAccountId = isMarginSelected ? AccountId : selectedAccountId;
|
|
23
25
|
var futuresAccountId = (0, _selectors2.futuresAccountIdSelector)(state);
|
|
24
26
|
return {
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _react = _interopRequireDefault(require("react"));
|
|
4
|
+
var _server = require("react-dom/server");
|
|
5
|
+
var _reactRedux = require("react-redux");
|
|
6
|
+
var _reduxMockStore = _interopRequireDefault(require("redux-mock-store"));
|
|
7
|
+
var _WalletsLayoutContainer = _interopRequireDefault(require("./WalletsLayoutContainer"));
|
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
9
|
+
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); }
|
|
10
|
+
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; }
|
|
11
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
12
|
+
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
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
14
|
+
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); }
|
|
15
|
+
var mockLayoutProps;
|
|
16
|
+
jest.mock('./WalletsLayout', function () {
|
|
17
|
+
return function (props) {
|
|
18
|
+
mockLayoutProps = props;
|
|
19
|
+
return null;
|
|
20
|
+
};
|
|
21
|
+
});
|
|
22
|
+
jest.mock('../../redux/margin/selectors', function () {
|
|
23
|
+
return _objectSpread(_objectSpread({}, jest.requireActual('../../redux/margin/selectors')), {}, {
|
|
24
|
+
isMarginEnabledSelector: function isMarginEnabledSelector() {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
jest.mock('../../redux/futures/selectors/futuresSelectors', function () {
|
|
30
|
+
return _objectSpread(_objectSpread({}, jest.requireActual('../../redux/futures/selectors/futuresSelectors')), {}, {
|
|
31
|
+
isFuturesActiveSelector: function isFuturesActiveSelector() {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
jest.mock('../../redux/futures/selectors', function () {
|
|
37
|
+
return _objectSpread(_objectSpread({}, jest.requireActual('../../redux/futures/selectors')), {}, {
|
|
38
|
+
futuresAccountIdSelector: function futuresAccountIdSelector() {
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
var mockStore = (0, _reduxMockStore["default"])();
|
|
44
|
+
var render = function render(_ref) {
|
|
45
|
+
var selectedAccountId = _ref.selectedAccountId,
|
|
46
|
+
defaultAccountId = _ref.defaultAccountId,
|
|
47
|
+
marginAccount = _ref.marginAccount;
|
|
48
|
+
return (0, _server.renderToStaticMarkup)(/*#__PURE__*/_react["default"].createElement(_reactRedux.Provider, {
|
|
49
|
+
store: mockStore({
|
|
50
|
+
user: {
|
|
51
|
+
selectedAccountId: selectedAccountId,
|
|
52
|
+
userInfo: {
|
|
53
|
+
AccountId: defaultAccountId
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
margin: {
|
|
57
|
+
accountInfo: marginAccount
|
|
58
|
+
}
|
|
59
|
+
})
|
|
60
|
+
}, /*#__PURE__*/_react["default"].createElement(_WalletsLayoutContainer["default"], null)));
|
|
61
|
+
};
|
|
62
|
+
describe('WalletsLayoutContainer', function () {
|
|
63
|
+
it('does not treat a user with no accounts as having the margin account selected', function () {
|
|
64
|
+
render({
|
|
65
|
+
selectedAccountId: undefined,
|
|
66
|
+
defaultAccountId: 19,
|
|
67
|
+
marginAccount: {}
|
|
68
|
+
});
|
|
69
|
+
expect(mockLayoutProps.isMarginSelected).toBe(false);
|
|
70
|
+
expect(mockLayoutProps.spotAccountId).toBeUndefined();
|
|
71
|
+
});
|
|
72
|
+
it('selects the margin view when the margin account is selected', function () {
|
|
73
|
+
render({
|
|
74
|
+
selectedAccountId: 20,
|
|
75
|
+
defaultAccountId: 15,
|
|
76
|
+
marginAccount: {
|
|
77
|
+
AccountId: 20
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
expect(mockLayoutProps.isMarginSelected).toBe(true);
|
|
81
|
+
expect(mockLayoutProps.marginAccountId).toBe(20);
|
|
82
|
+
expect(mockLayoutProps.spotAccountId).toBe(15);
|
|
83
|
+
});
|
|
84
|
+
});
|
|
@@ -3,23 +3,68 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.receiveValidate2FARequiredEndpoints = exports.getApiInfo = exports.callFMSAPI = exports.callAPI = exports.RECEIVE_VALIDATE_2FA_REQUIRED_ENDPOINTS = exports.GET_API_INFO = void 0;
|
|
6
|
+
exports.settleErrorFrame = exports.receiveValidate2FARequiredEndpoints = exports.isErrorFrame = exports.getApiInfo = exports.errorPayload = exports.callFMSAPI = exports.callAPI = exports.RECEIVE_VALIDATE_2FA_REQUIRED_ENDPOINTS = exports.GET_API_INFO = exports.ENDPOINT_NOT_FOUND = void 0;
|
|
7
7
|
var _apex = _interopRequireDefault(require("../../apex"));
|
|
8
8
|
var _fms = require("../../services/fms/fms");
|
|
9
9
|
var _modalActions = require("./modalActions");
|
|
10
|
+
var _twoFactorAuthCancellation = require("../../helpers/twoFactorAuthCancellation");
|
|
10
11
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
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); }
|
|
11
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 }; })(); }
|
|
12
14
|
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
|
|
13
15
|
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
14
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); }); }; }
|
|
17
|
+
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; }
|
|
18
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
19
|
+
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; }
|
|
20
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
21
|
+
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); }
|
|
15
22
|
var GET_API_INFO = exports.GET_API_INFO = 'GET_API_INFO';
|
|
16
23
|
var RECEIVE_VALIDATE_2FA_REQUIRED_ENDPOINTS = exports.RECEIVE_VALIDATE_2FA_REQUIRED_ENDPOINTS = 'RECEIVE_VALIDATE_2FA_REQUIRED_ENDPOINTS';
|
|
24
|
+
var ENDPOINT_NOT_FOUND = exports.ENDPOINT_NOT_FOUND = 'Endpoint Not Found';
|
|
17
25
|
var receiveValidate2FARequiredEndpoints = exports.receiveValidate2FARequiredEndpoints = function receiveValidate2FARequiredEndpoints(payload) {
|
|
18
26
|
return {
|
|
19
27
|
type: RECEIVE_VALIDATE_2FA_REQUIRED_ENDPOINTS,
|
|
20
28
|
payload: payload
|
|
21
29
|
};
|
|
22
30
|
};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* True for the frame the connection rejects with when the gateway answers an
|
|
34
|
+
* RPC with an error (m === 5), e.g. "Endpoint Not Found" for a user whose
|
|
35
|
+
* session carries no permission for that endpoint.
|
|
36
|
+
*/
|
|
37
|
+
var isErrorFrame = exports.isErrorFrame = function isErrorFrame(error) {
|
|
38
|
+
return !!error && error.m === 5;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* The gateway's own error payloads look like { result: false, errormsg, errorcode, detail }
|
|
43
|
+
* and callers already check `result !== false` on them. A refusal is given the same shape for
|
|
44
|
+
* the callers that opt in via settleErrorFrame.
|
|
45
|
+
*/
|
|
46
|
+
var errorPayload = exports.errorPayload = function errorPayload(errormsg, endpoint) {
|
|
47
|
+
return {
|
|
48
|
+
result: false,
|
|
49
|
+
errormsg: errormsg,
|
|
50
|
+
detail: endpoint
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Turns a rejected error frame into the error payload above (plus Authenticated: false for the
|
|
56
|
+
* auth endpoints) and re-throws anything else. Usage: `dispatch(callAPI(...)).catch(settleErrorFrame)`
|
|
57
|
+
* or `apex.connection.Authenticate2FA(payload).catch(settleErrorFrame)`.
|
|
58
|
+
*/
|
|
59
|
+
var settleErrorFrame = exports.settleErrorFrame = function settleErrorFrame(error) {
|
|
60
|
+
if (isErrorFrame(error)) {
|
|
61
|
+
console.error("".concat(error.n, " was refused by the gateway"), error.o);
|
|
62
|
+
return _objectSpread(_objectSpread({}, errorPayload(error.o || ENDPOINT_NOT_FOUND, error.n)), {}, {
|
|
63
|
+
Authenticated: false
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
throw error;
|
|
67
|
+
};
|
|
23
68
|
var getApiInfo = exports.getApiInfo = function getApiInfo() {
|
|
24
69
|
return /*#__PURE__*/function () {
|
|
25
70
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(dispatch, getState) {
|
|
@@ -31,6 +76,9 @@ var getApiInfo = exports.getApiInfo = function getApiInfo() {
|
|
|
31
76
|
_context.n = 1;
|
|
32
77
|
return _apex["default"].connection.RPCPromise('GetValidate2FARequiredEndpoints', {
|
|
33
78
|
OMSId: OMSId
|
|
79
|
+
})["catch"](function (e) {
|
|
80
|
+
console.error('getApiInfo action error', e);
|
|
81
|
+
return;
|
|
34
82
|
});
|
|
35
83
|
case 1:
|
|
36
84
|
data = _context.v;
|
|
@@ -45,9 +93,24 @@ var getApiInfo = exports.getApiInfo = function getApiInfo() {
|
|
|
45
93
|
};
|
|
46
94
|
}();
|
|
47
95
|
};
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* @param {Object} [options]
|
|
99
|
+
* @param {boolean} [options.rejectOnCancel] Reject with TwoFactorAuthCancelledError when the user
|
|
100
|
+
* dismisses the 2FA modal. Off by default: most callers await callAPI with no catch, so for them a
|
|
101
|
+
* dismissed modal leaves the call pending (the behaviour they were written against) instead of
|
|
102
|
+
* surfacing an unhandled rejection. Callers that opt in must handle the cancellation.
|
|
103
|
+
*
|
|
104
|
+
* An error reply from the gateway (m === 5) rejects with the frame. Loaders that store the reply
|
|
105
|
+
* must not catch it (the store stays untouched, which is what they want); callers that report the
|
|
106
|
+
* refusal to the user chain `.catch(settleErrorFrame)` to get an error payload instead.
|
|
107
|
+
*/
|
|
48
108
|
var callAPI = exports.callAPI = function callAPI(endpoint, apiPayload) {
|
|
109
|
+
var _ref2 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
|
|
110
|
+
_ref2$rejectOnCancel = _ref2.rejectOnCancel,
|
|
111
|
+
rejectOnCancel = _ref2$rejectOnCancel === void 0 ? false : _ref2$rejectOnCancel;
|
|
49
112
|
return /*#__PURE__*/function () {
|
|
50
|
-
var
|
|
113
|
+
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(dispatch, getState) {
|
|
51
114
|
var state, validate2FARequiredEndpoints, apiCall, res;
|
|
52
115
|
return _regenerator().w(function (_context3) {
|
|
53
116
|
while (1) switch (_context3.n) {
|
|
@@ -59,7 +122,7 @@ var callAPI = exports.callAPI = function callAPI(endpoint, apiPayload) {
|
|
|
59
122
|
break;
|
|
60
123
|
}
|
|
61
124
|
apiCall = /*#__PURE__*/function () {
|
|
62
|
-
var
|
|
125
|
+
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(data) {
|
|
63
126
|
return _regenerator().w(function (_context2) {
|
|
64
127
|
while (1) switch (_context2.n) {
|
|
65
128
|
case 0:
|
|
@@ -71,15 +134,20 @@ var callAPI = exports.callAPI = function callAPI(endpoint, apiPayload) {
|
|
|
71
134
|
}, _callee2);
|
|
72
135
|
}));
|
|
73
136
|
return function apiCall(_x5) {
|
|
74
|
-
return
|
|
137
|
+
return _ref4.apply(this, arguments);
|
|
75
138
|
};
|
|
76
139
|
}();
|
|
77
|
-
return _context3.a(2, new Promise(function (resolve,
|
|
140
|
+
return _context3.a(2, new Promise(function (resolve, _reject) {
|
|
78
141
|
dispatch((0, _modalActions.openModal)(_modalActions.MODAL_TYPES.REQUIRE_2FA, {
|
|
79
142
|
apiPayload: JSON.stringify(apiPayload),
|
|
80
143
|
apiCall: apiCall,
|
|
81
144
|
resolve: resolve,
|
|
82
|
-
reject: reject
|
|
145
|
+
reject: function reject(error) {
|
|
146
|
+
if (!rejectOnCancel && (0, _twoFactorAuthCancellation.isTwoFactorAuthCancellation)(error)) {
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
_reject(error);
|
|
150
|
+
}
|
|
83
151
|
}));
|
|
84
152
|
}));
|
|
85
153
|
case 1:
|
|
@@ -98,13 +166,13 @@ var callAPI = exports.callAPI = function callAPI(endpoint, apiPayload) {
|
|
|
98
166
|
}, _callee3);
|
|
99
167
|
}));
|
|
100
168
|
return function (_x3, _x4) {
|
|
101
|
-
return
|
|
169
|
+
return _ref3.apply(this, arguments);
|
|
102
170
|
};
|
|
103
171
|
}();
|
|
104
172
|
};
|
|
105
173
|
var callFMSAPI = exports.callFMSAPI = function callFMSAPI(endpoint, apiPayload) {
|
|
106
174
|
return /*#__PURE__*/function () {
|
|
107
|
-
var
|
|
175
|
+
var _ref5 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(_dispatch, getState) {
|
|
108
176
|
var token, gw, res;
|
|
109
177
|
return _regenerator().w(function (_context4) {
|
|
110
178
|
while (1) switch (_context4.n) {
|
|
@@ -120,7 +188,7 @@ var callFMSAPI = exports.callFMSAPI = function callFMSAPI(endpoint, apiPayload)
|
|
|
120
188
|
}, _callee4);
|
|
121
189
|
}));
|
|
122
190
|
return function (_x6, _x7) {
|
|
123
|
-
return
|
|
191
|
+
return _ref5.apply(this, arguments);
|
|
124
192
|
};
|
|
125
193
|
}();
|
|
126
194
|
};
|