@alphapoint/apex-web 5.5.4 → 5.5.5-fe.1
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/README.md +27 -2
- package/lib/App.js +30 -18
- package/lib/components/DepositSidePaneComponents/DepositFormComponent.js +2 -7
- package/lib/components/FusionAuth/ConfirmPendingWithdrawModal.js +60 -0
- package/lib/components/FusionAuth/FusionAuthCallbackComponent.js +66 -0
- package/lib/components/FusionAuth/FusionAuthCallbackContainer.js +24 -0
- package/lib/components/FusionAuth/FusionStepUpModal.js +63 -0
- package/lib/components/FusionAuth/LinkOAuthIdentityModal.css +6 -0
- package/lib/components/FusionAuth/LinkOAuthIdentityModal.js +65 -0
- package/lib/components/FuturesOrderBook/FuturesOrderBookContainer.js +5 -0
- package/lib/components/Login/LoginFormComponent.js +15 -4
- package/lib/components/Login/LoginFormContainer.js +21 -26
- package/lib/components/OrderBookComponents/OrderBookComponent.js +27 -25
- package/lib/components/OrderBookComponents/OrderBookContainer.js +5 -0
- package/lib/components/Retail/RetailSidePanes/FiatDeposit/FiatDepositFormComponent.js +2 -6
- package/lib/components/Retail/RetailSidePanes/FiatWithdraw/FiatWithdrawFormComponent.js +2 -6
- package/lib/components/SendReceiveSidePane/ReceiveAddress/ReceiveAddressComponent.js +2 -6
- package/lib/components/SendReceiveSidePane/SendAddress/SendAddressComponent.js +2 -7
- package/lib/components/Settings/ProfileAndSecurity/ProfileSettingsCard/ProfileForm/ProfileFormComponent.js +3 -1
- package/lib/components/Settings/ProfileAndSecurity/ProfileSettingsCard/ProfileForm/SsoLinkRowComponent.css +10 -0
- package/lib/components/Settings/ProfileAndSecurity/ProfileSettingsCard/ProfileForm/SsoLinkRowComponent.js +77 -0
- package/lib/components/WithdrawSidePaneComponents/WithdrawForm/WithdrawFormComponent.js +3 -8
- package/lib/components/common/APVerticalScroller/APVerticalScroller.js +8 -5
- package/lib/config/configDefault.json +8 -2
- package/lib/helpers/accountProviderHelper.js +28 -0
- package/lib/helpers/accountProviderHelper.test.js +67 -0
- package/lib/helpers/fusionStepUp.js +79 -0
- package/lib/helpers/fusionStepUp.test.js +136 -0
- package/lib/helpers/orderBook/priceGroupingHelper.js +29 -12
- package/lib/helpers/orderBook/priceGroupingHelper.test.js +50 -35
- package/lib/helpers/safeSessionStorage.js +36 -0
- package/lib/redux/actions/authActions.js +581 -48
- package/lib/redux/actions/fusionAuthActions.test.js +717 -0
- package/lib/redux/actions/modalActions.js +3 -0
- package/lib/redux/actions/withdrawActions.js +99 -65
- package/lib/redux/actions/wsConnectionActions.js +96 -1
- package/lib/redux/actions/wsConnectionLifecycle.test.js +207 -0
- package/package.json +4 -4
|
@@ -42,6 +42,9 @@ var MODAL_TYPES = exports.MODAL_TYPES = {
|
|
|
42
42
|
DEPOSIT_STATUS: 'DEPOSIT_STATUS',
|
|
43
43
|
DEPOSIT_REFERENCE_ID: 'DEPOSIT_REFERENCE_ID',
|
|
44
44
|
SEND_REQUEST_2FA: 'SEND_REQUEST_2FA',
|
|
45
|
+
FUSION_STEP_UP: 'FUSION_STEP_UP',
|
|
46
|
+
CONFIRM_PENDING_WITHDRAW: 'CONFIRM_PENDING_WITHDRAW',
|
|
47
|
+
LINK_OAUTH_IDENTITY: 'LINK_OAUTH_IDENTITY',
|
|
45
48
|
SUBMIT_LIMIT_ORDER: 'SUBMIT_LIMIT_ORDER',
|
|
46
49
|
MARGIN_DEPOSIT: 'MARGIN_DEPOSIT',
|
|
47
50
|
MARGIN_WITHDRAW: 'MARGIN_WITHDRAW',
|
|
@@ -3,12 +3,15 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.withdrawTemplatesError = exports.withdrawTemplateError = exports.subscribeToWithdrawalTickets = exports.submittingWithdraw = exports.requestWithdrawTickets = exports.receiveWithdrawWorkflowInfo = exports.receiveWithdrawTickets = exports.receiveWithdrawTicket = exports.receiveWithdrawTemplates = exports.receiveWithdrawTemplate = exports.receiveWithdrawFee = exports.getWithdrawTickets = exports.getWithdrawFee = exports.getAccountVerificationLevelConfig = exports.fetchingWithdrawTemplates = exports.fetchingWithdrawTemplate = exports.fetchProductWithdrawTemplates = exports.fetchProductWithdrawTemplate = exports.createWithdrawTicket = exports.cancelWithdrawTicket = exports.addWithdrawalTicket = exports.SUBMITTING_WITHDRAW = exports.RETAIL_FIAT_CONFIRM_WITHDRAW = exports.REQUEST_WITHDRAW_TICKETS = exports.RECEIVE_WITHDRAW_WORKFLOW_INFO = exports.RECEIVE_WITHDRAW_TICKETS = exports.RECEIVE_WITHDRAW_TICKET = exports.RECEIVE_WITHDRAW_TEMPLATE_ERROR = exports.RECEIVE_WITHDRAW_TEMPLATES_ERROR = exports.RECEIVE_WITHDRAW_TEMPLATES = exports.RECEIVE_WITHDRAW_TEMPLATE = exports.RECEIVE_WITHDRAW_FEE = exports.RECEIVE_VERIFICATION_LEVEL_CONFIGS = exports.FETCH_PRODUCT_WITHDRAW_TEMPLATES = exports.FETCH_PRODUCT_WITHDRAW_TEMPLATE = exports.ADD_WITHDRAWAL_TICKET = void 0;
|
|
6
|
+
exports.withdrawTemplatesError = exports.withdrawTemplateError = exports.subscribeToWithdrawalTickets = exports.submittingWithdraw = exports.submitWithdrawTicket = exports.requestWithdrawTickets = exports.receiveWithdrawWorkflowInfo = exports.receiveWithdrawTickets = exports.receiveWithdrawTicket = exports.receiveWithdrawTemplates = exports.receiveWithdrawTemplate = exports.receiveWithdrawFee = exports.getWithdrawTickets = exports.getWithdrawFee = exports.getAccountVerificationLevelConfig = exports.fetchingWithdrawTemplates = exports.fetchingWithdrawTemplate = exports.fetchProductWithdrawTemplates = exports.fetchProductWithdrawTemplate = exports.createWithdrawTicket = exports.cancelWithdrawTicket = exports.addWithdrawalTicket = exports.SUBMITTING_WITHDRAW = exports.RETAIL_FIAT_CONFIRM_WITHDRAW = exports.REQUEST_WITHDRAW_TICKETS = exports.RECEIVE_WITHDRAW_WORKFLOW_INFO = exports.RECEIVE_WITHDRAW_TICKETS = exports.RECEIVE_WITHDRAW_TICKET = exports.RECEIVE_WITHDRAW_TEMPLATE_ERROR = exports.RECEIVE_WITHDRAW_TEMPLATES_ERROR = exports.RECEIVE_WITHDRAW_TEMPLATES = exports.RECEIVE_WITHDRAW_TEMPLATE = exports.RECEIVE_WITHDRAW_FEE = exports.RECEIVE_VERIFICATION_LEVEL_CONFIGS = exports.FETCH_PRODUCT_WITHDRAW_TEMPLATES = exports.FETCH_PRODUCT_WITHDRAW_TEMPLATE = exports.ADD_WITHDRAWAL_TICKET = void 0;
|
|
7
7
|
var _apiActions = require("./apiActions");
|
|
8
8
|
var _withdrawSubscriptionService = _interopRequireDefault(require("../../services/subscriptions/withdrawSubscriptionService"));
|
|
9
9
|
var _snackbarActions = require("./snackbarActions");
|
|
10
10
|
var _sidePaneActions = require("./sidePaneActions");
|
|
11
11
|
var _errorTextFormatter = require("../../helpers/errorTextFormatter");
|
|
12
|
+
var _modalActions = require("./modalActions");
|
|
13
|
+
var _fusionStepUp = require("../../helpers/fusionStepUp");
|
|
14
|
+
var _config = _interopRequireDefault(require("../../config"));
|
|
12
15
|
var _excluded = ["ProductId", "amount", "iconFileName", "ProductSymbol", "ProductFullName", "AccountProviderId"];
|
|
13
16
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
14
17
|
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); }
|
|
@@ -156,9 +159,9 @@ var createWithdrawTicket = exports.createWithdrawTicket = function createWithdra
|
|
|
156
159
|
info = _objectWithoutProperties(_ref3, _excluded);
|
|
157
160
|
return /*#__PURE__*/function () {
|
|
158
161
|
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(dispatch, getState) {
|
|
159
|
-
var OMSId, AccountId, templateForm, accountProviderId, templateTypeObj, template, kytDetails, travelRuleFields, travelRuleValues, payload
|
|
162
|
+
var OMSId, AccountId, templateForm, accountProviderId, templateTypeObj, template, kytDetails, travelRuleFields, travelRuleValues, payload;
|
|
160
163
|
return _regenerator().w(function (_context3) {
|
|
161
|
-
while (1) switch (_context3.
|
|
164
|
+
while (1) switch (_context3.n) {
|
|
162
165
|
case 0:
|
|
163
166
|
dispatch(submittingWithdraw);
|
|
164
167
|
OMSId = getState().user.userInfo.OMSId;
|
|
@@ -199,34 +202,65 @@ var createWithdrawTicket = exports.createWithdrawTicket = function createWithdra
|
|
|
199
202
|
if (kytDetails) {
|
|
200
203
|
payload.Kytdetails = kytDetails;
|
|
201
204
|
}
|
|
202
|
-
_context3.
|
|
205
|
+
return _context3.a(2, dispatch(submitWithdrawTicket(payload)));
|
|
206
|
+
}
|
|
207
|
+
}, _callee3);
|
|
208
|
+
}));
|
|
209
|
+
return function (_x5, _x6) {
|
|
210
|
+
return _ref4.apply(this, arguments);
|
|
211
|
+
};
|
|
212
|
+
}();
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Submits a built CreateWithdrawTicket payload; split out so the step-up flow can resubmit the
|
|
217
|
+
* stashed payload verbatim (ConfirmPendingWithdrawModal).
|
|
218
|
+
*/
|
|
219
|
+
var submitWithdrawTicket = exports.submitWithdrawTicket = function submitWithdrawTicket(payload) {
|
|
220
|
+
return /*#__PURE__*/function () {
|
|
221
|
+
var _ref5 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(dispatch) {
|
|
222
|
+
var withdrawStatus, workflowDetail, _t2;
|
|
223
|
+
return _regenerator().w(function (_context4) {
|
|
224
|
+
while (1) switch (_context4.p = _context4.n) {
|
|
225
|
+
case 0:
|
|
226
|
+
_context4.n = 1;
|
|
203
227
|
return dispatch((0, _apiActions.callAPI)('CreateWithdrawTicket', payload));
|
|
204
228
|
case 1:
|
|
205
|
-
withdrawStatus =
|
|
229
|
+
withdrawStatus = _context4.v;
|
|
230
|
+
if (!(_config["default"].FusionAuth && _config["default"].FusionAuth.enabled && withdrawStatus && withdrawStatus.Authorized === false)) {
|
|
231
|
+
_context4.n = 2;
|
|
232
|
+
break;
|
|
233
|
+
}
|
|
234
|
+
(0, _fusionStepUp.stashPendingAction)({
|
|
235
|
+
type: _fusionStepUp.PENDING_ACTION_WITHDRAW,
|
|
236
|
+
payload: payload
|
|
237
|
+
});
|
|
238
|
+
return _context4.a(2, dispatch((0, _modalActions.openModal)(_modalActions.MODAL_TYPES.FUSION_STEP_UP)));
|
|
239
|
+
case 2:
|
|
206
240
|
if (!(withdrawStatus.result === false)) {
|
|
207
|
-
|
|
241
|
+
_context4.n = 3;
|
|
208
242
|
break;
|
|
209
243
|
}
|
|
210
|
-
return
|
|
244
|
+
return _context4.a(2, dispatch((0, _snackbarActions.showSnack)({
|
|
211
245
|
id: 'withdrawRejectSnack',
|
|
212
246
|
text: (0, _errorTextFormatter.formatErrorText)(withdrawStatus),
|
|
213
247
|
type: 'warning'
|
|
214
248
|
})));
|
|
215
|
-
case
|
|
216
|
-
|
|
249
|
+
case 3:
|
|
250
|
+
_context4.p = 3;
|
|
217
251
|
workflowDetail = JSON.parse(withdrawStatus.detail);
|
|
218
252
|
if (!(_typeof(workflowDetail) === 'object' && workflowDetail.ReplyObject && workflowDetail.ReplyObject !== '0')) {
|
|
219
|
-
|
|
253
|
+
_context4.n = 4;
|
|
220
254
|
break;
|
|
221
255
|
}
|
|
222
|
-
return
|
|
223
|
-
case 3:
|
|
224
|
-
_context3.n = 5;
|
|
225
|
-
break;
|
|
256
|
+
return _context4.a(2, dispatch(receiveWithdrawWorkflowInfo(workflowDetail)));
|
|
226
257
|
case 4:
|
|
227
|
-
|
|
228
|
-
|
|
258
|
+
_context4.n = 6;
|
|
259
|
+
break;
|
|
229
260
|
case 5:
|
|
261
|
+
_context4.p = 5;
|
|
262
|
+
_t2 = _context4.v;
|
|
263
|
+
case 6:
|
|
230
264
|
dispatch((0, _sidePaneActions.closeWithdrawSidePane)());
|
|
231
265
|
dispatch((0, _snackbarActions.showSnack)({
|
|
232
266
|
id: 'withdrawSuccessSnack',
|
|
@@ -235,21 +269,21 @@ var createWithdrawTicket = exports.createWithdrawTicket = function createWithdra
|
|
|
235
269
|
type: 'success'
|
|
236
270
|
}));
|
|
237
271
|
dispatch(receiveWithdrawTicket(withdrawStatus));
|
|
238
|
-
return
|
|
272
|
+
return _context4.a(2, dispatch(getWithdrawTickets(payload.AccountId, payload.OMSId)));
|
|
239
273
|
}
|
|
240
|
-
},
|
|
274
|
+
}, _callee4, null, [[3, 5]]);
|
|
241
275
|
}));
|
|
242
|
-
return function (
|
|
243
|
-
return
|
|
276
|
+
return function (_x7) {
|
|
277
|
+
return _ref5.apply(this, arguments);
|
|
244
278
|
};
|
|
245
279
|
}();
|
|
246
280
|
};
|
|
247
281
|
var getWithdrawFee = exports.getWithdrawFee = function getWithdrawFee(ProductId, Amount, AccountProviderId) {
|
|
248
282
|
return /*#__PURE__*/function () {
|
|
249
|
-
var
|
|
283
|
+
var _ref6 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(dispatch, getState) {
|
|
250
284
|
var OMSId, AccountId, payload, withdrawFee, _t3;
|
|
251
|
-
return _regenerator().w(function (
|
|
252
|
-
while (1) switch (
|
|
285
|
+
return _regenerator().w(function (_context5) {
|
|
286
|
+
while (1) switch (_context5.p = _context5.n) {
|
|
253
287
|
case 0:
|
|
254
288
|
OMSId = getState().user.userInfo.OMSId;
|
|
255
289
|
AccountId = getState().user.selectedAccountId;
|
|
@@ -260,26 +294,26 @@ var getWithdrawFee = exports.getWithdrawFee = function getWithdrawFee(ProductId,
|
|
|
260
294
|
AccountProviderId: AccountProviderId,
|
|
261
295
|
Amount: Amount
|
|
262
296
|
};
|
|
263
|
-
|
|
297
|
+
_context5.p = 1;
|
|
264
298
|
if (payload.AccountProviderId) {
|
|
265
299
|
payload.AccountProviderId = parseInt(payload.AccountProviderId);
|
|
266
300
|
}
|
|
267
|
-
|
|
301
|
+
_context5.n = 2;
|
|
268
302
|
return dispatch((0, _apiActions.callAPI)('GetWithdrawFee', payload));
|
|
269
303
|
case 2:
|
|
270
|
-
withdrawFee =
|
|
271
|
-
|
|
304
|
+
withdrawFee = _context5.v;
|
|
305
|
+
_context5.n = 4;
|
|
272
306
|
break;
|
|
273
307
|
case 3:
|
|
274
|
-
|
|
275
|
-
_t3 =
|
|
308
|
+
_context5.p = 3;
|
|
309
|
+
_t3 = _context5.v;
|
|
276
310
|
console.error(_t3);
|
|
277
311
|
case 4:
|
|
278
312
|
if (!(withdrawFee && withdrawFee.result === false)) {
|
|
279
|
-
|
|
313
|
+
_context5.n = 5;
|
|
280
314
|
break;
|
|
281
315
|
}
|
|
282
|
-
return
|
|
316
|
+
return _context5.a(2, dispatch((0, _snackbarActions.showSnack)({
|
|
283
317
|
id: 'withdrawRejectSnack',
|
|
284
318
|
text: (0, _errorTextFormatter.formatErrorText)(withdrawFee),
|
|
285
319
|
type: 'warning'
|
|
@@ -287,22 +321,22 @@ var getWithdrawFee = exports.getWithdrawFee = function getWithdrawFee(ProductId,
|
|
|
287
321
|
case 5:
|
|
288
322
|
dispatch(receiveWithdrawFee(withdrawFee));
|
|
289
323
|
case 6:
|
|
290
|
-
return
|
|
324
|
+
return _context5.a(2);
|
|
291
325
|
}
|
|
292
|
-
},
|
|
326
|
+
}, _callee5, null, [[1, 3]]);
|
|
293
327
|
}));
|
|
294
|
-
return function (
|
|
295
|
-
return
|
|
328
|
+
return function (_x8, _x9) {
|
|
329
|
+
return _ref6.apply(this, arguments);
|
|
296
330
|
};
|
|
297
331
|
}();
|
|
298
332
|
};
|
|
299
|
-
var cancelWithdrawTicket = exports.cancelWithdrawTicket = function cancelWithdrawTicket(
|
|
300
|
-
var RequestCode =
|
|
333
|
+
var cancelWithdrawTicket = exports.cancelWithdrawTicket = function cancelWithdrawTicket(_ref7) {
|
|
334
|
+
var RequestCode = _ref7.RequestCode;
|
|
301
335
|
return /*#__PURE__*/function () {
|
|
302
|
-
var
|
|
336
|
+
var _ref8 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(dispatch, getState) {
|
|
303
337
|
var _getState$user$userIn, OMSId, UserId, AccountId, payload, withdrawStatus;
|
|
304
|
-
return _regenerator().w(function (
|
|
305
|
-
while (1) switch (
|
|
338
|
+
return _regenerator().w(function (_context6) {
|
|
339
|
+
while (1) switch (_context6.n) {
|
|
306
340
|
case 0:
|
|
307
341
|
_getState$user$userIn = getState().user.userInfo, OMSId = _getState$user$userIn.OMSId, UserId = _getState$user$userIn.UserId;
|
|
308
342
|
AccountId = getState().user.selectedAccountId;
|
|
@@ -312,15 +346,15 @@ var cancelWithdrawTicket = exports.cancelWithdrawTicket = function cancelWithdra
|
|
|
312
346
|
AccountId: AccountId,
|
|
313
347
|
RequestCode: RequestCode
|
|
314
348
|
};
|
|
315
|
-
|
|
349
|
+
_context6.n = 1;
|
|
316
350
|
return dispatch((0, _apiActions.callAPI)('CancelWithdraw', payload));
|
|
317
351
|
case 1:
|
|
318
|
-
withdrawStatus =
|
|
352
|
+
withdrawStatus = _context6.v;
|
|
319
353
|
if (!(withdrawStatus.result === false)) {
|
|
320
|
-
|
|
354
|
+
_context6.n = 2;
|
|
321
355
|
break;
|
|
322
356
|
}
|
|
323
|
-
return
|
|
357
|
+
return _context6.a(2, dispatch((0, _snackbarActions.showSnack)({
|
|
324
358
|
id: 'cancelWithdrawSnack',
|
|
325
359
|
text: (0, _errorTextFormatter.formatErrorText)(withdrawStatus),
|
|
326
360
|
type: 'warning'
|
|
@@ -334,12 +368,12 @@ var cancelWithdrawTicket = exports.cancelWithdrawTicket = function cancelWithdra
|
|
|
334
368
|
}));
|
|
335
369
|
dispatch(getWithdrawTickets(AccountId, OMSId));
|
|
336
370
|
case 3:
|
|
337
|
-
return
|
|
371
|
+
return _context6.a(2);
|
|
338
372
|
}
|
|
339
|
-
},
|
|
373
|
+
}, _callee6);
|
|
340
374
|
}));
|
|
341
|
-
return function (
|
|
342
|
-
return
|
|
375
|
+
return function (_x0, _x1) {
|
|
376
|
+
return _ref8.apply(this, arguments);
|
|
343
377
|
};
|
|
344
378
|
}();
|
|
345
379
|
};
|
|
@@ -428,30 +462,30 @@ var receiveWithdrawWorkflowInfo = exports.receiveWithdrawWorkflowInfo = function
|
|
|
428
462
|
var getWithdrawTickets = exports.getWithdrawTickets = function getWithdrawTickets(AccountId, OMSId) {
|
|
429
463
|
var StartIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
430
464
|
return /*#__PURE__*/function () {
|
|
431
|
-
var
|
|
465
|
+
var _ref9 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(dispatch) {
|
|
432
466
|
var withdrawTickets;
|
|
433
|
-
return _regenerator().w(function (
|
|
434
|
-
while (1) switch (
|
|
467
|
+
return _regenerator().w(function (_context7) {
|
|
468
|
+
while (1) switch (_context7.n) {
|
|
435
469
|
case 0:
|
|
436
470
|
dispatch(requestWithdrawTickets({
|
|
437
471
|
StartIndex: StartIndex
|
|
438
472
|
}));
|
|
439
|
-
|
|
473
|
+
_context7.n = 1;
|
|
440
474
|
return dispatch((0, _apiActions.callAPI)('GetWithdrawTickets', {
|
|
441
475
|
AccountId: AccountId,
|
|
442
476
|
OMSId: OMSId,
|
|
443
477
|
StartIndex: StartIndex
|
|
444
478
|
}));
|
|
445
479
|
case 1:
|
|
446
|
-
withdrawTickets =
|
|
480
|
+
withdrawTickets = _context7.v;
|
|
447
481
|
dispatch(receiveWithdrawTickets(withdrawTickets));
|
|
448
482
|
case 2:
|
|
449
|
-
return
|
|
483
|
+
return _context7.a(2);
|
|
450
484
|
}
|
|
451
|
-
},
|
|
485
|
+
}, _callee7);
|
|
452
486
|
}));
|
|
453
|
-
return function (
|
|
454
|
-
return
|
|
487
|
+
return function (_x10) {
|
|
488
|
+
return _ref9.apply(this, arguments);
|
|
455
489
|
};
|
|
456
490
|
}();
|
|
457
491
|
};
|
|
@@ -464,13 +498,13 @@ var receiveVerificationLevelConfigs = function receiveVerificationLevelConfigs(p
|
|
|
464
498
|
};
|
|
465
499
|
var getAccountVerificationLevelConfig = exports.getAccountVerificationLevelConfig = function getAccountVerificationLevelConfig() {
|
|
466
500
|
return /*#__PURE__*/function () {
|
|
467
|
-
var
|
|
501
|
+
var _ref0 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(dispatch, getState) {
|
|
468
502
|
var state;
|
|
469
|
-
return _regenerator().w(function (
|
|
470
|
-
while (1) switch (
|
|
503
|
+
return _regenerator().w(function (_context8) {
|
|
504
|
+
while (1) switch (_context8.n) {
|
|
471
505
|
case 0:
|
|
472
506
|
state = getState();
|
|
473
|
-
|
|
507
|
+
_context8.n = 1;
|
|
474
508
|
return dispatch((0, _apiActions.callAPI)('GetVerificationLevelConfig', {
|
|
475
509
|
OMSId: state.user.userInfo.OMSId,
|
|
476
510
|
AccountId: state.user.selectedAccountId
|
|
@@ -478,12 +512,12 @@ var getAccountVerificationLevelConfig = exports.getAccountVerificationLevelConfi
|
|
|
478
512
|
return dispatch(receiveVerificationLevelConfigs(res));
|
|
479
513
|
});
|
|
480
514
|
case 1:
|
|
481
|
-
return
|
|
515
|
+
return _context8.a(2);
|
|
482
516
|
}
|
|
483
|
-
},
|
|
517
|
+
}, _callee8);
|
|
484
518
|
}));
|
|
485
|
-
return function (
|
|
486
|
-
return
|
|
519
|
+
return function (_x11, _x12) {
|
|
520
|
+
return _ref0.apply(this, arguments);
|
|
487
521
|
};
|
|
488
522
|
}();
|
|
489
523
|
};
|
|
@@ -4,9 +4,12 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.pingBackend = exports.connectionOpened = exports.connectionClosedCount = exports.connectionClosed = exports.changeServer = exports.CONNECTION_OPENED = exports.CONNECTION_CLOSED_COUNT = exports.CONNECTION_CLOSED = void 0;
|
|
7
|
+
exports.pingBackend = exports.openAppConnection = exports.connectionOpened = exports.connectionClosedCount = exports.connectionClosed = exports.connectAndAuthenticate = exports.changeServer = exports.CONNECTION_OPENED = exports.CONNECTION_CLOSED_COUNT = exports.CONNECTION_CLOSED = void 0;
|
|
8
8
|
var _get = _interopRequireDefault(require("lodash/get"));
|
|
9
9
|
var _apex = _interopRequireWildcard(require("../../apex"));
|
|
10
|
+
var _wsHelper = require("../../helpers/wsHelper");
|
|
11
|
+
var _appActions = require("./appActions");
|
|
12
|
+
var _lifeCycleActions = require("./lifeCycleActions");
|
|
10
13
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
11
14
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
12
15
|
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 }; })(); }
|
|
@@ -38,6 +41,98 @@ var connectionClosedCount = exports.connectionClosedCount = function connectionC
|
|
|
38
41
|
payload: attemptNumber
|
|
39
42
|
};
|
|
40
43
|
};
|
|
44
|
+
|
|
45
|
+
// WebSocket.CONNECTING / WebSocket.OPEN, spelled out because the socket is an rxjs
|
|
46
|
+
// WebSocketSubject and the constants are not on it.
|
|
47
|
+
var SOCKET_CONNECTING = 0;
|
|
48
|
+
var SOCKET_OPEN = 1;
|
|
49
|
+
|
|
50
|
+
// getGateway() owns the precedence between config.global.gateway and the stored tradingServer,
|
|
51
|
+
// but it returns null for an array-valued config with nothing stored yet - normally the login
|
|
52
|
+
// form is where the user picks one. Routes without that form (the SSO callback) take the first
|
|
53
|
+
// configured gateway instead.
|
|
54
|
+
var resolveGateway = function resolveGateway(override) {
|
|
55
|
+
var resolved = override || (0, _wsHelper.getGateway)();
|
|
56
|
+
if (resolved) return resolved;
|
|
57
|
+
var configured = (0, _wsHelper.getLoginFormGateway)();
|
|
58
|
+
return Array.isArray(configured) ? configured[0] : configured;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
// initApex() replaces apex.connection outright, so opening a second one while the first is
|
|
62
|
+
// still connecting orphans it and leaves a stray gateway socket behind. Everything below opens
|
|
63
|
+
// a connection only when this window has none.
|
|
64
|
+
var hasLiveSocket = function hasLiveSocket() {
|
|
65
|
+
var readyState = (0, _get["default"])(_apex["default"], 'connection.ws.socket.readyState');
|
|
66
|
+
return readyState === SOCKET_CONNECTING || readyState === SOCKET_OPEN;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Opens the application's connection unless one is already open or opening. The app shell calls
|
|
71
|
+
* this on mount; it owns connectionOpened, which is what makes wsConnection.isConnected
|
|
72
|
+
* meaningful and drives the startup sequence in wsConnectionMiddleware.
|
|
73
|
+
*/
|
|
74
|
+
var openAppConnection = exports.openAppConnection = function openAppConnection(gateway) {
|
|
75
|
+
return function (dispatch) {
|
|
76
|
+
if (hasLiveSocket()) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
var resolved = resolveGateway(gateway);
|
|
80
|
+
if (!resolved) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
(0, _apex.setGateway)(resolved);
|
|
84
|
+
localStorage.setItem('tradingServer', resolved);
|
|
85
|
+
(0, _apex.initApex)(function () {
|
|
86
|
+
return dispatch(connectionOpened());
|
|
87
|
+
}, function () {
|
|
88
|
+
return dispatch(connectionClosed());
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Runs `authenticate` on a live APEX connection, opening one first when there is none, and
|
|
95
|
+
* resolves with whatever `authenticate` returned. Rejects when the connection it opened closed
|
|
96
|
+
* without ever opening, so callers can report the failure rather than wait forever.
|
|
97
|
+
*
|
|
98
|
+
* Sole owner of the connect-then-authenticate lifecycle: the login form and the FusionAuth
|
|
99
|
+
* callback both come through here, so gateway precedence and the post-authentication startup
|
|
100
|
+
* dispatches cannot drift apart between them. `gateway` overrides the resolved gateway - the
|
|
101
|
+
* login form submits the server the user picked.
|
|
102
|
+
*
|
|
103
|
+
* An existing socket is reused, including one that is still CONNECTING: WebSocketSubject queues
|
|
104
|
+
* frames until it opens. Reusing one also means the startup dispatches below are skipped - the
|
|
105
|
+
* shell's own connection carries connectionOpened, and wsConnectionMiddleware makes them on
|
|
106
|
+
* CONNECTION_OPENED.
|
|
107
|
+
*/
|
|
108
|
+
var connectAndAuthenticate = exports.connectAndAuthenticate = function connectAndAuthenticate(authenticate, gateway) {
|
|
109
|
+
return function (dispatch) {
|
|
110
|
+
if (hasLiveSocket()) {
|
|
111
|
+
return Promise.resolve(authenticate());
|
|
112
|
+
}
|
|
113
|
+
var resolved = resolveGateway(gateway);
|
|
114
|
+
(0, _apex.setGateway)(resolved);
|
|
115
|
+
localStorage.setItem('tradingServer', resolved);
|
|
116
|
+
return new Promise(function (resolve, reject) {
|
|
117
|
+
return (0, _apex.initApex)(function () {
|
|
118
|
+
return resolve(Promise.resolve(authenticate()).then(function (result) {
|
|
119
|
+
dispatch(connectionClosedCount(0));
|
|
120
|
+
dispatch((0, _appActions.loadStartupData)());
|
|
121
|
+
dispatch((0, _lifeCycleActions.onInit)());
|
|
122
|
+
return result;
|
|
123
|
+
}));
|
|
124
|
+
}, function () {
|
|
125
|
+
dispatch(connectionClosed());
|
|
126
|
+
// A close before the socket ever opened means `authenticate` never ran, so the caller
|
|
127
|
+
// has to hear about it: an unsettled promise latches redux-form's `submitting` and
|
|
128
|
+
// leaves the login button disabled on 'Processing...' with no error and nothing to
|
|
129
|
+
// retry. Once the socket has opened this is a no-op - the promise resolved on that open,
|
|
130
|
+
// and the reconnect ladder in wsConnectionMiddleware owns the drop.
|
|
131
|
+
reject(new Error('The connection to the trading server closed before it opened.'));
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
};
|
|
135
|
+
};
|
|
41
136
|
var pingBackend = exports.pingBackend = function pingBackend() {
|
|
42
137
|
return /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
43
138
|
return _regenerator().w(function (_context) {
|
|
@@ -0,0 +1,207 @@
|
|
|
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
|
+
var _reduxMockStore = _interopRequireDefault(require("redux-mock-store"));
|
|
5
|
+
var _reduxThunk = _interopRequireDefault(require("redux-thunk"));
|
|
6
|
+
var _apex = _interopRequireWildcard(require("../../apex"));
|
|
7
|
+
var _wsConnectionActions = require("./wsConnectionActions");
|
|
8
|
+
var _appActions = require("./appActions");
|
|
9
|
+
var _lifeCycleActions = require("./lifeCycleActions");
|
|
10
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
12
|
+
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 }; })(); }
|
|
13
|
+
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); }
|
|
14
|
+
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); }
|
|
15
|
+
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); }); }; } // Connection bootstrap (DEV-7541): openAppConnection / connectAndAuthenticate.
|
|
16
|
+
//
|
|
17
|
+
// wsConnectionActions.test.js cannot host these - it fails to load on jsdom's read-only
|
|
18
|
+
// window.location, a CRA-era assumption that predates this branch.
|
|
19
|
+
// initApex's callbacks are captured rather than invoked, so each test drives the open/close
|
|
20
|
+
// leg it is about.
|
|
21
|
+
var socketCallbacks;
|
|
22
|
+
jest.mock('../../apex', function () {
|
|
23
|
+
return {
|
|
24
|
+
__esModule: true,
|
|
25
|
+
"default": {
|
|
26
|
+
connection: {}
|
|
27
|
+
},
|
|
28
|
+
setGateway: jest.fn(),
|
|
29
|
+
initApex: jest.fn()
|
|
30
|
+
};
|
|
31
|
+
});
|
|
32
|
+
var SOCKET_CONNECTING = 0;
|
|
33
|
+
var SOCKET_OPEN = 1;
|
|
34
|
+
var SOCKET_CLOSED = 3;
|
|
35
|
+
|
|
36
|
+
/** Puts a socket in `readyState` where hasLiveSocket() looks for one; null for no socket at all. */
|
|
37
|
+
var givenSocket = function givenSocket(readyState) {
|
|
38
|
+
_apex["default"].connection = readyState === null ? {} : {
|
|
39
|
+
ws: {
|
|
40
|
+
socket: {
|
|
41
|
+
readyState: readyState
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
describe('connection bootstrap (DEV-7541)', function () {
|
|
47
|
+
var mockStore = (0, _reduxMockStore["default"])([_reduxThunk["default"]]);
|
|
48
|
+
var store;
|
|
49
|
+
beforeEach(function () {
|
|
50
|
+
jest.clearAllMocks();
|
|
51
|
+
localStorage.clear();
|
|
52
|
+
socketCallbacks = {};
|
|
53
|
+
_apex.initApex.mockImplementation(function (onopen, onclose) {
|
|
54
|
+
socketCallbacks = {
|
|
55
|
+
onopen: onopen,
|
|
56
|
+
onclose: onclose
|
|
57
|
+
};
|
|
58
|
+
});
|
|
59
|
+
store = mockStore({});
|
|
60
|
+
givenSocket(null);
|
|
61
|
+
});
|
|
62
|
+
describe('connectAndAuthenticate()', function () {
|
|
63
|
+
it('settles rather than hanging when the socket closes without ever opening', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
64
|
+
var authenticate, pending;
|
|
65
|
+
return _regenerator().w(function (_context) {
|
|
66
|
+
while (1) switch (_context.n) {
|
|
67
|
+
case 0:
|
|
68
|
+
authenticate = jest.fn();
|
|
69
|
+
pending = store.dispatch((0, _wsConnectionActions.connectAndAuthenticate)(authenticate, 'wss://gateway.test/WSGateway'));
|
|
70
|
+
socketCallbacks.onclose();
|
|
71
|
+
_context.n = 1;
|
|
72
|
+
return expect(pending).rejects.toThrow(/closed before it opened/);
|
|
73
|
+
case 1:
|
|
74
|
+
// the credentials never went anywhere - the caller has to say so, not retry silently
|
|
75
|
+
expect(authenticate).not.toHaveBeenCalled();
|
|
76
|
+
expect(store.getActions()).toContainEqual(expect.objectContaining({
|
|
77
|
+
type: _wsConnectionActions.CONNECTION_CLOSED
|
|
78
|
+
}));
|
|
79
|
+
case 2:
|
|
80
|
+
return _context.a(2);
|
|
81
|
+
}
|
|
82
|
+
}, _callee);
|
|
83
|
+
})));
|
|
84
|
+
it('still reports the close to the reconnect ladder', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
|
|
85
|
+
var pending;
|
|
86
|
+
return _regenerator().w(function (_context2) {
|
|
87
|
+
while (1) switch (_context2.n) {
|
|
88
|
+
case 0:
|
|
89
|
+
pending = store.dispatch((0, _wsConnectionActions.connectAndAuthenticate)(jest.fn(), 'wss://gateway.test/WSGateway'));
|
|
90
|
+
socketCallbacks.onclose();
|
|
91
|
+
_context2.n = 1;
|
|
92
|
+
return expect(pending).rejects.toThrow();
|
|
93
|
+
case 1:
|
|
94
|
+
// wsConnectionMiddleware drives the retry/backoff off CONNECTION_CLOSED, so rejecting
|
|
95
|
+
// must not have replaced that dispatch
|
|
96
|
+
expect(store.getActions().filter(function (a) {
|
|
97
|
+
return a.type === _wsConnectionActions.CONNECTION_CLOSED;
|
|
98
|
+
})).toHaveLength(1);
|
|
99
|
+
case 2:
|
|
100
|
+
return _context2.a(2);
|
|
101
|
+
}
|
|
102
|
+
}, _callee2);
|
|
103
|
+
})));
|
|
104
|
+
it('resolves with the authenticate result and runs the startup dispatches on open', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3() {
|
|
105
|
+
var loginAction, pending;
|
|
106
|
+
return _regenerator().w(function (_context3) {
|
|
107
|
+
while (1) switch (_context3.n) {
|
|
108
|
+
case 0:
|
|
109
|
+
loginAction = {
|
|
110
|
+
type: 'AUTH_SUCCESS'
|
|
111
|
+
};
|
|
112
|
+
pending = store.dispatch((0, _wsConnectionActions.connectAndAuthenticate)(function () {
|
|
113
|
+
return Promise.resolve(loginAction);
|
|
114
|
+
}, 'wss://gateway.test/WSGateway'));
|
|
115
|
+
socketCallbacks.onopen();
|
|
116
|
+
_context3.n = 1;
|
|
117
|
+
return expect(pending).resolves.toBe(loginAction);
|
|
118
|
+
case 1:
|
|
119
|
+
expect(_apex.setGateway).toHaveBeenCalledWith('wss://gateway.test/WSGateway');
|
|
120
|
+
expect(localStorage.getItem('tradingServer')).toBe('wss://gateway.test/WSGateway');
|
|
121
|
+
expect(store.getActions().map(function (a) {
|
|
122
|
+
return a.type;
|
|
123
|
+
})).toEqual(expect.arrayContaining([_appActions.LOAD_STARTUP_DATA, _lifeCycleActions.APP_INIT]));
|
|
124
|
+
case 2:
|
|
125
|
+
return _context3.a(2);
|
|
126
|
+
}
|
|
127
|
+
}, _callee3);
|
|
128
|
+
})));
|
|
129
|
+
it('does not reject a connection that dropped after it had opened', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4() {
|
|
130
|
+
var pending;
|
|
131
|
+
return _regenerator().w(function (_context4) {
|
|
132
|
+
while (1) switch (_context4.n) {
|
|
133
|
+
case 0:
|
|
134
|
+
pending = store.dispatch((0, _wsConnectionActions.connectAndAuthenticate)(function () {
|
|
135
|
+
return Promise.resolve({
|
|
136
|
+
type: 'AUTH_SUCCESS'
|
|
137
|
+
});
|
|
138
|
+
}, 'wss://gateway.test/WSGateway'));
|
|
139
|
+
socketCallbacks.onopen();
|
|
140
|
+
_context4.n = 1;
|
|
141
|
+
return pending;
|
|
142
|
+
case 1:
|
|
143
|
+
// a later drop is the reconnect ladder's business; the promise has already settled
|
|
144
|
+
socketCallbacks.onclose();
|
|
145
|
+
_context4.n = 2;
|
|
146
|
+
return expect(pending).resolves.toEqual({
|
|
147
|
+
type: 'AUTH_SUCCESS'
|
|
148
|
+
});
|
|
149
|
+
case 2:
|
|
150
|
+
return _context4.a(2);
|
|
151
|
+
}
|
|
152
|
+
}, _callee4);
|
|
153
|
+
})));
|
|
154
|
+
it.each([['connecting', SOCKET_CONNECTING], ['open', SOCKET_OPEN]])('reuses a socket that is already %s', /*#__PURE__*/function () {
|
|
155
|
+
var _ref5 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(_label, readyState) {
|
|
156
|
+
var loginAction;
|
|
157
|
+
return _regenerator().w(function (_context5) {
|
|
158
|
+
while (1) switch (_context5.n) {
|
|
159
|
+
case 0:
|
|
160
|
+
givenSocket(readyState);
|
|
161
|
+
loginAction = {
|
|
162
|
+
type: 'AUTH_SUCCESS'
|
|
163
|
+
};
|
|
164
|
+
_context5.n = 1;
|
|
165
|
+
return expect(store.dispatch((0, _wsConnectionActions.connectAndAuthenticate)(function () {
|
|
166
|
+
return Promise.resolve(loginAction);
|
|
167
|
+
}, 'wss://gateway.test/WSGateway'))).resolves.toBe(loginAction);
|
|
168
|
+
case 1:
|
|
169
|
+
expect(_apex.initApex).not.toHaveBeenCalled();
|
|
170
|
+
case 2:
|
|
171
|
+
return _context5.a(2);
|
|
172
|
+
}
|
|
173
|
+
}, _callee5);
|
|
174
|
+
}));
|
|
175
|
+
return function (_x, _x2) {
|
|
176
|
+
return _ref5.apply(this, arguments);
|
|
177
|
+
};
|
|
178
|
+
}());
|
|
179
|
+
it('opens a connection when the previous socket is closed', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6() {
|
|
180
|
+
return _regenerator().w(function (_context6) {
|
|
181
|
+
while (1) switch (_context6.n) {
|
|
182
|
+
case 0:
|
|
183
|
+
givenSocket(SOCKET_CLOSED);
|
|
184
|
+
store.dispatch((0, _wsConnectionActions.connectAndAuthenticate)(jest.fn(), 'wss://gateway.test/WSGateway'));
|
|
185
|
+
expect(_apex.initApex).toHaveBeenCalled();
|
|
186
|
+
case 1:
|
|
187
|
+
return _context6.a(2);
|
|
188
|
+
}
|
|
189
|
+
}, _callee6);
|
|
190
|
+
})));
|
|
191
|
+
});
|
|
192
|
+
describe('openAppConnection()', function () {
|
|
193
|
+
it('opens the app shell connection and owns connectionOpened', function () {
|
|
194
|
+
store.dispatch((0, _wsConnectionActions.openAppConnection)('wss://gateway.test/WSGateway'));
|
|
195
|
+
expect(_apex.initApex).toHaveBeenCalled();
|
|
196
|
+
socketCallbacks.onopen();
|
|
197
|
+
expect(store.getActions()).toContainEqual(expect.objectContaining({
|
|
198
|
+
type: _wsConnectionActions.CONNECTION_OPENED
|
|
199
|
+
}));
|
|
200
|
+
});
|
|
201
|
+
it.each([['connecting', SOCKET_CONNECTING], ['open', SOCKET_OPEN]])('is a no-op when a socket is already %s', function (_label, readyState) {
|
|
202
|
+
givenSocket(readyState);
|
|
203
|
+
store.dispatch((0, _wsConnectionActions.openAppConnection)('wss://gateway.test/WSGateway'));
|
|
204
|
+
expect(_apex.initApex).not.toHaveBeenCalled();
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
});
|