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