@alphapoint/apex-web 5.7.0 → 5.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/apex.integration.test.js +435 -0
- package/lib/apex.js +37 -1
- package/lib/apex.test.js +138 -0
- package/lib/components/2FA/PasskeyOption.js +126 -0
- package/lib/components/2FA/TwoFactorAuthComponent.js +24 -5
- package/lib/components/2FA/TwoFactorAuthComponent.test.js +94 -0
- package/lib/components/2FA/TwoFactorAuthContainer.js +94 -16
- package/lib/components/2FA/TwoFactorAuthContainer.test.js +412 -0
- package/lib/components/ConfirmBlockTradeModal/ConfirmBlockTradeModalContainer.js +34 -6
- package/lib/components/ConfirmBlockTradeModal/ConfirmBlockTradeModalContainer.test.js +298 -0
- package/lib/components/ConfirmOrderModal/ConfirmOrderModalComponent.js +26 -4
- package/lib/components/ConfirmOrderModal/ConfirmOrderModalContainer.js +4 -1
- package/lib/components/EnableTwoFactorAuth/Disable2FAForm.js +22 -7
- package/lib/components/EnableTwoFactorAuth/Disable2FAModal.js +15 -5
- package/lib/components/EnableTwoFactorAuth/Disable2FAModal.test.js +460 -0
- package/lib/components/EnableTwoFactorAuth/Disable2FAModalContainer.js +108 -16
- package/lib/components/EnableTwoFactorAuth/EnableTwoFactorAuthContainerFactory.js +3 -2
- package/lib/components/FusionAuth/UnlinkOAuthIdentityModal.css +13 -0
- package/lib/components/FusionAuth/UnlinkOAuthIdentityModal.js +246 -0
- package/lib/components/FusionAuth/UnlinkOAuthIdentityModal.test.js +521 -0
- package/lib/components/Login/LoginFormComponent.js +1 -1
- package/lib/components/OrderEntryComponents/advancedForm/AdvancedOrderFormContainer.js +2 -0
- package/lib/components/OrderEntryComponents/common/FormAmountFields.js +5 -0
- package/lib/components/OrderEntryComponents/common/TwapScheduleFields.js +98 -0
- package/lib/components/OrderEntryComponents/defaultForm/OrderEntryAnchoring.js +86 -39
- package/lib/components/OrderEntryComponents/defaultForm/OrderEntryAnchoring.test.js +326 -0
- package/lib/components/OrderEntryComponents/defaultForm/OrderEntryContainer.js +10 -2
- package/lib/components/OrderHistoryComponents/DepositsStatus/DepositsStatusComponent.js +1 -1
- package/lib/components/OrderHistoryComponents/DepositsStatus/DepositsStatusComponent.test.js +99 -0
- package/lib/components/OrderHistoryComponents/InactiveOrders/InactiveOrdersComponent.js +1 -1
- package/lib/components/OrderHistoryComponents/OpenOrders/OpenOrdersComponent.js +1 -1
- package/lib/components/OrderHistoryComponents/WithdrawStatus/WithdrawStatusComponent.js +1 -1
- package/lib/components/OrderHistoryComponents/WithdrawStatus/WithdrawStatusComponent.test.js +113 -0
- package/lib/components/Settings/ProfileAndSecurity/PasskeysSettingsCard/PasskeysSettingsCard.css +108 -0
- package/lib/components/Settings/ProfileAndSecurity/PasskeysSettingsCard/PasskeysSettingsCard.test.js +983 -0
- package/lib/components/Settings/ProfileAndSecurity/PasskeysSettingsCard/PasskeysSettingsCardComponent.js +500 -0
- package/lib/components/Settings/ProfileAndSecurity/PasskeysSettingsCard/index.js +9 -0
- package/lib/components/Settings/ProfileAndSecurity/ProfileSettingsCard/ProfileForm/SsoLinkRowComponent.css +4 -0
- package/lib/components/Settings/ProfileAndSecurity/ProfileSettingsCard/ProfileForm/SsoLinkRowComponent.js +29 -17
- package/lib/components/Settings/ProfileAndSecurity/ProfileSettingsCard/ProfileForm/SsoLinkRowComponent.test.js +135 -0
- package/lib/components/Settings/ProfileAndSecurity/TwoFactorAuthSettingsCard/EnableTwoFactorAuth/EnableTwoFactorAuthComponent.test.js +23 -1
- package/lib/components/TwoFactorAuthForm/TwoFactorAuthForm.test.js +475 -0
- package/lib/components/TwoFactorAuthForm/TwoFactorAuthFormComponent.js +26 -5
- package/lib/components/TwoFactorAuthForm/TwoFactorAuthFormContainer.js +50 -32
- package/lib/components/common/APAutoTabInput/APAutoTabInput.js +5 -2
- package/lib/components/common/APSelect/APSelect.js +3 -1
- package/lib/config/CONFIG.md +4 -0
- package/lib/config/configDefault.json +2 -1
- package/lib/constants/sendOrder/orderEntryFormConstants.js +23 -4
- package/lib/constants/sendOrder/timeInForceConstants.js +3 -1
- package/lib/constants/sendOrder/twapRejectReasons.js +26 -0
- package/lib/helpers/orderHistoryHelper.js +13 -1
- package/lib/helpers/orderHistoryHelper.test.js +58 -13
- package/lib/helpers/passkeyApi.js +228 -0
- package/lib/helpers/passkeyApi.test.js +171 -0
- package/lib/helpers/placeOrderHelper.js +76 -61
- package/lib/helpers/placeOrderHelper.test.js +169 -10
- package/lib/helpers/recalculateOrderHelper.js +4 -1
- package/lib/helpers/recalculateOrderHelper.test.js +88 -2
- package/lib/helpers/twapOrderHelper.js +265 -0
- package/lib/helpers/twapOrderHelper.test.js +467 -0
- package/lib/helpers/webauthnHelper.js +300 -0
- package/lib/helpers/webauthnHelper.test.js +199 -0
- package/lib/hocs/withOneSubmission.js +168 -0
- package/lib/redux/actions/apiActions.js +52 -1
- package/lib/redux/actions/apiActions.test.js +135 -0
- package/lib/redux/actions/authActions.js +514 -198
- package/lib/redux/actions/authActions.test.js +627 -47
- package/lib/redux/actions/depositActions.js +1 -1
- package/lib/redux/actions/depositActions.test.js +100 -30
- package/lib/redux/actions/fusionAuthActions.test.js +265 -84
- package/lib/redux/actions/modalActions.js +1 -0
- package/lib/redux/actions/orderEntryActions.blockTrade.test.js +306 -0
- package/lib/redux/actions/orderEntryActions.js +74 -22
- package/lib/redux/actions/orderEntryActions.test.js +63 -11
- package/lib/redux/actions/orderHistoryActions.js +9 -4
- package/lib/redux/actions/orderHistoryActions.test.js +63 -0
- package/lib/redux/actions/userActions.js +314 -177
- package/lib/redux/actions/userActions.test.js +844 -268
- package/lib/redux/margin/actions/marginActions.js +6 -3
- package/lib/redux/margin/actions/marginActions.test.js +166 -0
- package/lib/redux/middlewares/authMiddleware.js +5 -0
- package/lib/redux/middlewares/authMiddleware.test.js +88 -29
- package/lib/redux/reducers/authReducer.js +1 -0
- package/lib/redux/reducers/authReducer.test.js +38 -0
- package/lib/redux/selectors/orderEntrySelector.js +19 -8
- package/lib/redux/selectors/orderEntrySelector.test.js +209 -0
- package/lib/redux/selectors/orderTotalSelector.test.js +40 -1
- package/lib/services/fms/fms.js +2 -0
- package/lib/services/fms/fms.test.js +35 -0
- package/package.json +4 -4
|
@@ -4,9 +4,16 @@ var _reduxMockStore = _interopRequireDefault(require("redux-mock-store"));
|
|
|
4
4
|
var _reduxThunk = _interopRequireDefault(require("redux-thunk"));
|
|
5
5
|
var actions = _interopRequireWildcard(require("./authActions"));
|
|
6
6
|
var _apex = _interopRequireDefault(require("../../apex"));
|
|
7
|
+
var _webauthnHelper = require("../../helpers/webauthnHelper");
|
|
7
8
|
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); }
|
|
8
9
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
9
10
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
11
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
12
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
13
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
14
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
15
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
16
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
10
17
|
function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
|
|
11
18
|
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
|
|
12
19
|
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
@@ -57,6 +64,13 @@ jest.mock('../../apex', function () {
|
|
|
57
64
|
}
|
|
58
65
|
};
|
|
59
66
|
});
|
|
67
|
+
jest.mock('../../helpers/webauthnHelper', function () {
|
|
68
|
+
return _objectSpread(_objectSpread({}, jest.requireActual('../../helpers/webauthnHelper')), {}, {
|
|
69
|
+
getPasskeyAssertion: jest.fn(function () {
|
|
70
|
+
return Promise.resolve('assertion');
|
|
71
|
+
})
|
|
72
|
+
});
|
|
73
|
+
});
|
|
60
74
|
jest.mock('../../config', function () {
|
|
61
75
|
// authActions.js transitively imports userActions -> transferActions ->
|
|
62
76
|
// futures actions -> FuturesTickersSubscriptionService -> store.js, which
|
|
@@ -120,7 +134,8 @@ describe('auth actions', function () {
|
|
|
120
134
|
type: actions.AUTH_2FA_REQUIRED,
|
|
121
135
|
payload: {
|
|
122
136
|
userId: 1,
|
|
123
|
-
is2FARequired: true
|
|
137
|
+
is2FARequired: true,
|
|
138
|
+
passkeyOnly: false
|
|
124
139
|
}
|
|
125
140
|
});
|
|
126
141
|
});
|
|
@@ -167,7 +182,8 @@ describe('auth actions', function () {
|
|
|
167
182
|
userId: null,
|
|
168
183
|
token: null,
|
|
169
184
|
pending: false,
|
|
170
|
-
wasAuthenticatedBefore: false
|
|
185
|
+
wasAuthenticatedBefore: false,
|
|
186
|
+
passkeyOnly: false
|
|
171
187
|
}
|
|
172
188
|
});
|
|
173
189
|
case 2:
|
|
@@ -197,7 +213,8 @@ describe('auth actions', function () {
|
|
|
197
213
|
userId: null,
|
|
198
214
|
token: null,
|
|
199
215
|
pending: false,
|
|
200
|
-
wasAuthenticatedBefore: true
|
|
216
|
+
wasAuthenticatedBefore: true,
|
|
217
|
+
passkeyOnly: false
|
|
201
218
|
}
|
|
202
219
|
});
|
|
203
220
|
case 2:
|
|
@@ -262,6 +279,527 @@ describe('auth actions', function () {
|
|
|
262
279
|
});
|
|
263
280
|
});
|
|
264
281
|
});
|
|
282
|
+
describe('sendTwoFactorPasskey', function () {
|
|
283
|
+
it('answers the sign-in challenge with a passkey', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4() {
|
|
284
|
+
var store, result;
|
|
285
|
+
return _regenerator().w(function (_context4) {
|
|
286
|
+
while (1) switch (_context4.n) {
|
|
287
|
+
case 0:
|
|
288
|
+
_apex["default"].connection.RPCPromise.mockImplementation(function (endpoint) {
|
|
289
|
+
return Promise.resolve({
|
|
290
|
+
o: JSON.stringify(endpoint === 'GetPasskeyAssertionOptions' ? {
|
|
291
|
+
result: true,
|
|
292
|
+
AssertionOptions: 'options'
|
|
293
|
+
} : {})
|
|
294
|
+
});
|
|
295
|
+
});
|
|
296
|
+
_apex["default"].connection.Authenticate2FA.mockImplementationOnce(function () {
|
|
297
|
+
return Promise.resolve({
|
|
298
|
+
Authenticated: true,
|
|
299
|
+
UserId: 1,
|
|
300
|
+
SessionToken: 'token'
|
|
301
|
+
});
|
|
302
|
+
});
|
|
303
|
+
store = (0, _reduxMockStore["default"])([_reduxThunk["default"]])({});
|
|
304
|
+
_context4.n = 1;
|
|
305
|
+
return store.dispatch(actions.sendTwoFactorPasskey());
|
|
306
|
+
case 1:
|
|
307
|
+
result = _context4.v;
|
|
308
|
+
expect(_apex["default"].connection.Authenticate2FA).toHaveBeenCalledWith({
|
|
309
|
+
Code: '',
|
|
310
|
+
Assertion: 'assertion'
|
|
311
|
+
});
|
|
312
|
+
expect(result.type).toBe(actions.AUTH_SUCCESS);
|
|
313
|
+
case 2:
|
|
314
|
+
return _context4.a(2);
|
|
315
|
+
}
|
|
316
|
+
}, _callee4);
|
|
317
|
+
})));
|
|
318
|
+
it('reports a user without a passkey as an auth error', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5() {
|
|
319
|
+
var store, result;
|
|
320
|
+
return _regenerator().w(function (_context5) {
|
|
321
|
+
while (1) switch (_context5.n) {
|
|
322
|
+
case 0:
|
|
323
|
+
_apex["default"].connection.RPCPromise.mockImplementation(function () {
|
|
324
|
+
return Promise.resolve({
|
|
325
|
+
o: JSON.stringify({
|
|
326
|
+
result: false,
|
|
327
|
+
errormsg: 'No passkey is available for this account'
|
|
328
|
+
})
|
|
329
|
+
});
|
|
330
|
+
});
|
|
331
|
+
store = (0, _reduxMockStore["default"])([_reduxThunk["default"]])({});
|
|
332
|
+
_context5.n = 1;
|
|
333
|
+
return store.dispatch(actions.sendTwoFactorPasskey());
|
|
334
|
+
case 1:
|
|
335
|
+
result = _context5.v;
|
|
336
|
+
expect(result).toEqual(actions.authError({
|
|
337
|
+
Authenticated: false,
|
|
338
|
+
errormsg: 'No passkey is available for this account'
|
|
339
|
+
}));
|
|
340
|
+
expect(_apex["default"].connection.Authenticate2FA).not.toHaveBeenCalled();
|
|
341
|
+
case 2:
|
|
342
|
+
return _context5.a(2);
|
|
343
|
+
}
|
|
344
|
+
}, _callee5);
|
|
345
|
+
})));
|
|
346
|
+
it("explains a failed browser prompt in the app's words, not the browser's", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6() {
|
|
347
|
+
var store, result;
|
|
348
|
+
return _regenerator().w(function (_context6) {
|
|
349
|
+
while (1) switch (_context6.n) {
|
|
350
|
+
case 0:
|
|
351
|
+
_apex["default"].connection.RPCPromise.mockImplementation(function () {
|
|
352
|
+
return Promise.resolve({
|
|
353
|
+
o: JSON.stringify({
|
|
354
|
+
result: true,
|
|
355
|
+
AssertionOptions: 'options'
|
|
356
|
+
})
|
|
357
|
+
});
|
|
358
|
+
});
|
|
359
|
+
_webauthnHelper.getPasskeyAssertion.mockRejectedValueOnce(Object.assign(new Error('The operation either timed out or was not allowed. See: https://www.w3.org/TR/webauthn-2/#sctn-privacy-considerations-client.'), {
|
|
360
|
+
name: 'NotAllowedError'
|
|
361
|
+
}));
|
|
362
|
+
store = (0, _reduxMockStore["default"])([_reduxThunk["default"]])({});
|
|
363
|
+
_context6.n = 1;
|
|
364
|
+
return store.dispatch(actions.sendTwoFactorPasskey());
|
|
365
|
+
case 1:
|
|
366
|
+
result = _context6.v;
|
|
367
|
+
expect(result.type).toBe(actions.AUTH_ERROR);
|
|
368
|
+
expect(result.payload.errorMsg).toBe('The passkey request was canceled or timed out. Try again.');
|
|
369
|
+
expect(_apex["default"].connection.Authenticate2FA).not.toHaveBeenCalled();
|
|
370
|
+
case 2:
|
|
371
|
+
return _context6.a(2);
|
|
372
|
+
}
|
|
373
|
+
}, _callee6);
|
|
374
|
+
})));
|
|
375
|
+
describe('after the connection was lost on the 2FA screen', function () {
|
|
376
|
+
var creds = {
|
|
377
|
+
email: 'myEmail@example.com',
|
|
378
|
+
requires2FA: true
|
|
379
|
+
};
|
|
380
|
+
var challenge = function challenge() {
|
|
381
|
+
return _apex["default"].connection.RPCPromise.mockImplementation(function () {
|
|
382
|
+
return Promise.resolve({
|
|
383
|
+
o: JSON.stringify({
|
|
384
|
+
result: true,
|
|
385
|
+
AssertionOptions: 'options'
|
|
386
|
+
})
|
|
387
|
+
});
|
|
388
|
+
});
|
|
389
|
+
};
|
|
390
|
+
beforeEach(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7() {
|
|
391
|
+
return _regenerator().w(function (_context7) {
|
|
392
|
+
while (1) switch (_context7.n) {
|
|
393
|
+
case 0:
|
|
394
|
+
challenge();
|
|
395
|
+
_context7.n = 1;
|
|
396
|
+
return actions.login(creds)(jest.fn());
|
|
397
|
+
case 1:
|
|
398
|
+
jest.clearAllMocks();
|
|
399
|
+
case 2:
|
|
400
|
+
return _context7.a(2);
|
|
401
|
+
}
|
|
402
|
+
}, _callee7);
|
|
403
|
+
})));
|
|
404
|
+
|
|
405
|
+
// authSuccess forgets the stored credentials, so none leak into the suites below.
|
|
406
|
+
afterEach(function () {
|
|
407
|
+
return actions.authSuccess({});
|
|
408
|
+
});
|
|
409
|
+
it('signs in again before asking for the challenge, which belongs to the pre-2FA session', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8() {
|
|
410
|
+
var store, result, challengeCall;
|
|
411
|
+
return _regenerator().w(function (_context8) {
|
|
412
|
+
while (1) switch (_context8.n) {
|
|
413
|
+
case 0:
|
|
414
|
+
actions.mark2FAReconnection();
|
|
415
|
+
_apex["default"].connection.Authenticate2FA.mockImplementationOnce(function () {
|
|
416
|
+
return Promise.resolve({
|
|
417
|
+
Authenticated: true,
|
|
418
|
+
UserId: 1,
|
|
419
|
+
SessionToken: 'token'
|
|
420
|
+
});
|
|
421
|
+
});
|
|
422
|
+
store = (0, _reduxMockStore["default"])([_reduxThunk["default"]])({});
|
|
423
|
+
_context8.n = 1;
|
|
424
|
+
return store.dispatch(actions.sendTwoFactorPasskey());
|
|
425
|
+
case 1:
|
|
426
|
+
result = _context8.v;
|
|
427
|
+
expect(_apex["default"].connection.WebAuthenticateUser).toHaveBeenCalledWith(creds);
|
|
428
|
+
challengeCall = _apex["default"].connection.RPCPromise.mock.calls.findIndex(function (_ref9) {
|
|
429
|
+
var _ref0 = _slicedToArray(_ref9, 1),
|
|
430
|
+
endpoint = _ref0[0];
|
|
431
|
+
return endpoint === 'GetPasskeyAssertionOptions';
|
|
432
|
+
});
|
|
433
|
+
expect(_apex["default"].connection.WebAuthenticateUser.mock.invocationCallOrder[0]).toBeLessThan(_apex["default"].connection.RPCPromise.mock.invocationCallOrder[challengeCall]);
|
|
434
|
+
expect(result.type).toBe(actions.AUTH_SUCCESS);
|
|
435
|
+
case 2:
|
|
436
|
+
return _context8.a(2);
|
|
437
|
+
}
|
|
438
|
+
}, _callee8);
|
|
439
|
+
})));
|
|
440
|
+
it('asks to sign in again when that fails, without opening the passkey prompt', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9() {
|
|
441
|
+
var store, result;
|
|
442
|
+
return _regenerator().w(function (_context9) {
|
|
443
|
+
while (1) switch (_context9.n) {
|
|
444
|
+
case 0:
|
|
445
|
+
actions.mark2FAReconnection();
|
|
446
|
+
_apex["default"].connection.WebAuthenticateUser.mockImplementationOnce(function () {
|
|
447
|
+
return Promise.resolve({
|
|
448
|
+
Authenticated: false
|
|
449
|
+
});
|
|
450
|
+
});
|
|
451
|
+
store = (0, _reduxMockStore["default"])([_reduxThunk["default"]])({});
|
|
452
|
+
_context9.n = 1;
|
|
453
|
+
return store.dispatch(actions.sendTwoFactorPasskey());
|
|
454
|
+
case 1:
|
|
455
|
+
result = _context9.v;
|
|
456
|
+
expect(result.payload.errorMsg).toBe('Session expired. Please try logging in again.');
|
|
457
|
+
expect(_webauthnHelper.getPasskeyAssertion).not.toHaveBeenCalled();
|
|
458
|
+
expect(_apex["default"].connection.Authenticate2FA).not.toHaveBeenCalled();
|
|
459
|
+
case 2:
|
|
460
|
+
return _context9.a(2);
|
|
461
|
+
}
|
|
462
|
+
}, _callee9);
|
|
463
|
+
})));
|
|
464
|
+
it('signs in again on "Endpoint Not Found" and asks for the passkey once more', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0() {
|
|
465
|
+
var store, result;
|
|
466
|
+
return _regenerator().w(function (_context0) {
|
|
467
|
+
while (1) switch (_context0.n) {
|
|
468
|
+
case 0:
|
|
469
|
+
_apex["default"].connection.Authenticate2FA.mockImplementationOnce(function () {
|
|
470
|
+
return Promise.reject({
|
|
471
|
+
m: 5,
|
|
472
|
+
i: 8,
|
|
473
|
+
n: 'Authenticate2FA',
|
|
474
|
+
o: 'Endpoint Not Found'
|
|
475
|
+
});
|
|
476
|
+
});
|
|
477
|
+
store = (0, _reduxMockStore["default"])([_reduxThunk["default"]])({});
|
|
478
|
+
_context0.n = 1;
|
|
479
|
+
return store.dispatch(actions.sendTwoFactorPasskey());
|
|
480
|
+
case 1:
|
|
481
|
+
result = _context0.v;
|
|
482
|
+
expect(_apex["default"].connection.WebAuthenticateUser).toHaveBeenCalledWith(creds);
|
|
483
|
+
expect(result.type).toBe(actions.AUTH_ERROR);
|
|
484
|
+
expect(result.payload.errorMsg).toBe('Your sign-in was interrupted. Use your passkey again.');
|
|
485
|
+
case 2:
|
|
486
|
+
return _context0.a(2);
|
|
487
|
+
}
|
|
488
|
+
}, _callee0);
|
|
489
|
+
})));
|
|
490
|
+
});
|
|
491
|
+
});
|
|
492
|
+
describe('promptForRequiredPasskey', function () {
|
|
493
|
+
var statusReply = function statusReply(status) {
|
|
494
|
+
return _apex["default"].connection.RPCPromise.mockImplementation(function () {
|
|
495
|
+
return Promise.resolve({
|
|
496
|
+
o: JSON.stringify(status)
|
|
497
|
+
});
|
|
498
|
+
});
|
|
499
|
+
};
|
|
500
|
+
beforeEach(function () {
|
|
501
|
+
return sessionStorage.clear();
|
|
502
|
+
});
|
|
503
|
+
it('asks a user who must have a passkey and has none to add one', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1() {
|
|
504
|
+
var store;
|
|
505
|
+
return _regenerator().w(function (_context1) {
|
|
506
|
+
while (1) switch (_context1.n) {
|
|
507
|
+
case 0:
|
|
508
|
+
statusReply({
|
|
509
|
+
Enabled: true,
|
|
510
|
+
Passkeys: 0,
|
|
511
|
+
PasskeyRequired: true
|
|
512
|
+
});
|
|
513
|
+
store = (0, _reduxMockStore["default"])([_reduxThunk["default"]])({
|
|
514
|
+
snackbar: {
|
|
515
|
+
snacks: []
|
|
516
|
+
}
|
|
517
|
+
});
|
|
518
|
+
_context1.n = 1;
|
|
519
|
+
return store.dispatch(actions.promptForRequiredPasskey());
|
|
520
|
+
case 1:
|
|
521
|
+
expect(_apex["default"].connection.RPCPromise).toHaveBeenCalledWith('GetPasskeyStatus', {});
|
|
522
|
+
expect(JSON.stringify(store.getActions())).toContain('passkeyRequiredSnack');
|
|
523
|
+
case 2:
|
|
524
|
+
return _context1.a(2);
|
|
525
|
+
}
|
|
526
|
+
}, _callee1);
|
|
527
|
+
})));
|
|
528
|
+
it('says nothing to a user who has one', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10() {
|
|
529
|
+
var store;
|
|
530
|
+
return _regenerator().w(function (_context10) {
|
|
531
|
+
while (1) switch (_context10.n) {
|
|
532
|
+
case 0:
|
|
533
|
+
statusReply({
|
|
534
|
+
Enabled: true,
|
|
535
|
+
Passkeys: 1,
|
|
536
|
+
PasskeyRequired: true
|
|
537
|
+
});
|
|
538
|
+
store = (0, _reduxMockStore["default"])([_reduxThunk["default"]])({
|
|
539
|
+
snackbar: {
|
|
540
|
+
snacks: []
|
|
541
|
+
}
|
|
542
|
+
});
|
|
543
|
+
_context10.n = 1;
|
|
544
|
+
return store.dispatch(actions.promptForRequiredPasskey());
|
|
545
|
+
case 1:
|
|
546
|
+
expect(store.getActions()).toEqual([]);
|
|
547
|
+
case 2:
|
|
548
|
+
return _context10.a(2);
|
|
549
|
+
}
|
|
550
|
+
}, _callee10);
|
|
551
|
+
})));
|
|
552
|
+
it('takes passkeyOnly from the status, which a reloaded page has otherwise lost', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11() {
|
|
553
|
+
var store;
|
|
554
|
+
return _regenerator().w(function (_context11) {
|
|
555
|
+
while (1) switch (_context11.n) {
|
|
556
|
+
case 0:
|
|
557
|
+
statusReply({
|
|
558
|
+
Enabled: true,
|
|
559
|
+
Passkeys: 1,
|
|
560
|
+
PasskeyRequired: true,
|
|
561
|
+
PasskeyOnly: true
|
|
562
|
+
});
|
|
563
|
+
store = (0, _reduxMockStore["default"])([_reduxThunk["default"]])({
|
|
564
|
+
snackbar: {
|
|
565
|
+
snacks: []
|
|
566
|
+
}
|
|
567
|
+
});
|
|
568
|
+
_context11.n = 1;
|
|
569
|
+
return store.dispatch(actions.promptForRequiredPasskey());
|
|
570
|
+
case 1:
|
|
571
|
+
expect(store.getActions()).toEqual([actions.setPasskeyOnly(true)]);
|
|
572
|
+
case 2:
|
|
573
|
+
return _context11.a(2);
|
|
574
|
+
}
|
|
575
|
+
}, _callee11);
|
|
576
|
+
})));
|
|
577
|
+
it('asks only once per session, so a reload or reconnect does not ask again', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12() {
|
|
578
|
+
var store;
|
|
579
|
+
return _regenerator().w(function (_context12) {
|
|
580
|
+
while (1) switch (_context12.n) {
|
|
581
|
+
case 0:
|
|
582
|
+
statusReply({
|
|
583
|
+
Enabled: true,
|
|
584
|
+
Passkeys: 0,
|
|
585
|
+
PasskeyRequired: true
|
|
586
|
+
});
|
|
587
|
+
store = (0, _reduxMockStore["default"])([_reduxThunk["default"]])({
|
|
588
|
+
snackbar: {
|
|
589
|
+
snacks: []
|
|
590
|
+
}
|
|
591
|
+
});
|
|
592
|
+
_context12.n = 1;
|
|
593
|
+
return store.dispatch(actions.promptForRequiredPasskey());
|
|
594
|
+
case 1:
|
|
595
|
+
store.clearActions();
|
|
596
|
+
_context12.n = 2;
|
|
597
|
+
return store.dispatch(actions.promptForRequiredPasskey());
|
|
598
|
+
case 2:
|
|
599
|
+
expect(store.getActions()).toEqual([]);
|
|
600
|
+
case 3:
|
|
601
|
+
return _context12.a(2);
|
|
602
|
+
}
|
|
603
|
+
}, _callee12);
|
|
604
|
+
})));
|
|
605
|
+
describe('a status that comes back after the session ended', function () {
|
|
606
|
+
var heldStatus = function heldStatus() {
|
|
607
|
+
var release;
|
|
608
|
+
var reply = new Promise(function (resolve) {
|
|
609
|
+
release = function release(status) {
|
|
610
|
+
return resolve({
|
|
611
|
+
o: JSON.stringify(status)
|
|
612
|
+
});
|
|
613
|
+
};
|
|
614
|
+
});
|
|
615
|
+
_apex["default"].connection.RPCPromise.mockImplementation(function (endpoint) {
|
|
616
|
+
return endpoint === 'GetPasskeyStatus' ? reply : Promise.resolve('');
|
|
617
|
+
});
|
|
618
|
+
return release;
|
|
619
|
+
};
|
|
620
|
+
var userA = {
|
|
621
|
+
Enabled: true,
|
|
622
|
+
Passkeys: 0,
|
|
623
|
+
PasskeyRequired: true,
|
|
624
|
+
PasskeyOnly: true
|
|
625
|
+
};
|
|
626
|
+
it("does not make the next user's code sign-in passkey-only", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13() {
|
|
627
|
+
var release, store, reading;
|
|
628
|
+
return _regenerator().w(function (_context13) {
|
|
629
|
+
while (1) switch (_context13.n) {
|
|
630
|
+
case 0:
|
|
631
|
+
release = heldStatus();
|
|
632
|
+
store = (0, _reduxMockStore["default"])([_reduxThunk["default"]])({
|
|
633
|
+
auth: {
|
|
634
|
+
isAuthenticated: true
|
|
635
|
+
},
|
|
636
|
+
snackbar: {
|
|
637
|
+
snacks: []
|
|
638
|
+
}
|
|
639
|
+
});
|
|
640
|
+
reading = store.dispatch(actions.promptForRequiredPasskey());
|
|
641
|
+
store.dispatch(actions.logout());
|
|
642
|
+
_context13.n = 1;
|
|
643
|
+
return store.dispatch(actions.login({
|
|
644
|
+
email: 'b@example.com',
|
|
645
|
+
requires2FA: true
|
|
646
|
+
}));
|
|
647
|
+
case 1:
|
|
648
|
+
store.clearActions();
|
|
649
|
+
release(userA);
|
|
650
|
+
_context13.n = 2;
|
|
651
|
+
return reading;
|
|
652
|
+
case 2:
|
|
653
|
+
expect(store.getActions()).toEqual([]);
|
|
654
|
+
case 3:
|
|
655
|
+
return _context13.a(2);
|
|
656
|
+
}
|
|
657
|
+
}, _callee13);
|
|
658
|
+
})));
|
|
659
|
+
it('is dropped when a new sign-in replaced the session without a logout', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee14() {
|
|
660
|
+
var release, store, reading;
|
|
661
|
+
return _regenerator().w(function (_context14) {
|
|
662
|
+
while (1) switch (_context14.n) {
|
|
663
|
+
case 0:
|
|
664
|
+
release = heldStatus();
|
|
665
|
+
store = (0, _reduxMockStore["default"])([_reduxThunk["default"]])({
|
|
666
|
+
snackbar: {
|
|
667
|
+
snacks: []
|
|
668
|
+
}
|
|
669
|
+
});
|
|
670
|
+
reading = store.dispatch(actions.promptForRequiredPasskey());
|
|
671
|
+
_context14.n = 1;
|
|
672
|
+
return store.dispatch(actions.login({
|
|
673
|
+
email: 'b@example.com',
|
|
674
|
+
requires2FA: true
|
|
675
|
+
}));
|
|
676
|
+
case 1:
|
|
677
|
+
store.clearActions();
|
|
678
|
+
release(userA);
|
|
679
|
+
_context14.n = 2;
|
|
680
|
+
return reading;
|
|
681
|
+
case 2:
|
|
682
|
+
expect(store.getActions()).toEqual([]);
|
|
683
|
+
case 3:
|
|
684
|
+
return _context14.a(2);
|
|
685
|
+
}
|
|
686
|
+
}, _callee14);
|
|
687
|
+
})));
|
|
688
|
+
it('still applies to the session that asked', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15() {
|
|
689
|
+
var release, store, reading;
|
|
690
|
+
return _regenerator().w(function (_context15) {
|
|
691
|
+
while (1) switch (_context15.n) {
|
|
692
|
+
case 0:
|
|
693
|
+
release = heldStatus();
|
|
694
|
+
store = (0, _reduxMockStore["default"])([_reduxThunk["default"]])({
|
|
695
|
+
snackbar: {
|
|
696
|
+
snacks: []
|
|
697
|
+
}
|
|
698
|
+
});
|
|
699
|
+
reading = store.dispatch(actions.promptForRequiredPasskey());
|
|
700
|
+
release({
|
|
701
|
+
Enabled: true,
|
|
702
|
+
Passkeys: 1,
|
|
703
|
+
PasskeyOnly: true
|
|
704
|
+
});
|
|
705
|
+
_context15.n = 1;
|
|
706
|
+
return reading;
|
|
707
|
+
case 1:
|
|
708
|
+
expect(store.getActions()).toEqual([actions.setPasskeyOnly(true)]);
|
|
709
|
+
case 2:
|
|
710
|
+
return _context15.a(2);
|
|
711
|
+
}
|
|
712
|
+
}, _callee15);
|
|
713
|
+
})));
|
|
714
|
+
});
|
|
715
|
+
});
|
|
716
|
+
describe('claimPasskeyOnly', function () {
|
|
717
|
+
var held = function held() {
|
|
718
|
+
var release;
|
|
719
|
+
var reply = new Promise(function (resolve) {
|
|
720
|
+
release = function release(status) {
|
|
721
|
+
return resolve({
|
|
722
|
+
o: JSON.stringify(status)
|
|
723
|
+
});
|
|
724
|
+
};
|
|
725
|
+
});
|
|
726
|
+
_apex["default"].connection.RPCPromise.mockImplementation(function () {
|
|
727
|
+
return reply;
|
|
728
|
+
});
|
|
729
|
+
return release;
|
|
730
|
+
};
|
|
731
|
+
beforeEach(function () {
|
|
732
|
+
return sessionStorage.clear();
|
|
733
|
+
});
|
|
734
|
+
it('drops the status read after sign-in when a later read claimed the state in the same session', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee16() {
|
|
735
|
+
var release, store, reading, laterRead;
|
|
736
|
+
return _regenerator().w(function (_context16) {
|
|
737
|
+
while (1) switch (_context16.n) {
|
|
738
|
+
case 0:
|
|
739
|
+
release = held();
|
|
740
|
+
store = (0, _reduxMockStore["default"])([_reduxThunk["default"]])({
|
|
741
|
+
snackbar: {
|
|
742
|
+
snacks: []
|
|
743
|
+
}
|
|
744
|
+
});
|
|
745
|
+
reading = store.dispatch(actions.promptForRequiredPasskey());
|
|
746
|
+
laterRead = actions.claimPasskeyOnly();
|
|
747
|
+
release({
|
|
748
|
+
Enabled: true,
|
|
749
|
+
Passkeys: 1,
|
|
750
|
+
PasskeyRequired: true,
|
|
751
|
+
PasskeyOnly: true
|
|
752
|
+
});
|
|
753
|
+
_context16.n = 1;
|
|
754
|
+
return reading;
|
|
755
|
+
case 1:
|
|
756
|
+
expect(store.getActions()).toEqual([]);
|
|
757
|
+
expect(laterRead()).toBe(true);
|
|
758
|
+
case 2:
|
|
759
|
+
return _context16.a(2);
|
|
760
|
+
}
|
|
761
|
+
}, _callee16);
|
|
762
|
+
})));
|
|
763
|
+
it('says nothing about a required passkey from a status that a later read replaced', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee17() {
|
|
764
|
+
var release, store, reading;
|
|
765
|
+
return _regenerator().w(function (_context17) {
|
|
766
|
+
while (1) switch (_context17.n) {
|
|
767
|
+
case 0:
|
|
768
|
+
release = held();
|
|
769
|
+
store = (0, _reduxMockStore["default"])([_reduxThunk["default"]])({
|
|
770
|
+
snackbar: {
|
|
771
|
+
snacks: []
|
|
772
|
+
}
|
|
773
|
+
});
|
|
774
|
+
reading = store.dispatch(actions.promptForRequiredPasskey());
|
|
775
|
+
actions.claimPasskeyOnly();
|
|
776
|
+
release({
|
|
777
|
+
Enabled: true,
|
|
778
|
+
Passkeys: 0,
|
|
779
|
+
PasskeyRequired: true
|
|
780
|
+
});
|
|
781
|
+
_context17.n = 1;
|
|
782
|
+
return reading;
|
|
783
|
+
case 1:
|
|
784
|
+
expect(store.getActions()).toEqual([]);
|
|
785
|
+
case 2:
|
|
786
|
+
return _context17.a(2);
|
|
787
|
+
}
|
|
788
|
+
}, _callee17);
|
|
789
|
+
})));
|
|
790
|
+
it('is lost to a later claim, and to the end of the session', function () {
|
|
791
|
+
var first = actions.claimPasskeyOnly();
|
|
792
|
+
var second = actions.claimPasskeyOnly();
|
|
793
|
+
expect(first()).toBe(false);
|
|
794
|
+
expect(second()).toBe(true);
|
|
795
|
+
(0, _reduxMockStore["default"])([_reduxThunk["default"]])({
|
|
796
|
+
auth: {
|
|
797
|
+
isAuthenticated: true
|
|
798
|
+
}
|
|
799
|
+
}).dispatch(actions.logout());
|
|
800
|
+
expect(second()).toBe(false);
|
|
801
|
+
});
|
|
802
|
+
});
|
|
265
803
|
describe('require2FA method', function () {
|
|
266
804
|
it('should the return the right action', function () {
|
|
267
805
|
var payload = {
|
|
@@ -272,10 +810,20 @@ describe('auth actions', function () {
|
|
|
272
810
|
type: actions.AUTH_2FA_REQUIRED,
|
|
273
811
|
payload: {
|
|
274
812
|
userId: 1,
|
|
275
|
-
is2FARequired: true
|
|
813
|
+
is2FARequired: true,
|
|
814
|
+
passkeyOnly: false
|
|
276
815
|
}
|
|
277
816
|
});
|
|
278
817
|
});
|
|
818
|
+
it('carries PasskeyOnly when the gateway refuses a code alone', function () {
|
|
819
|
+
var result = actions.require2FA({
|
|
820
|
+
UserId: 1,
|
|
821
|
+
AuthType: 'Google',
|
|
822
|
+
PasskeyOnly: true
|
|
823
|
+
});
|
|
824
|
+
expect(result.payload.passkeyOnly).toBe(true);
|
|
825
|
+
expect(result.payload.twoFAType).toBe('Google');
|
|
826
|
+
});
|
|
279
827
|
});
|
|
280
828
|
describe('setUserNotAuthenticated method', function () {
|
|
281
829
|
it('should the return the right action', function () {
|
|
@@ -286,7 +834,8 @@ describe('auth actions', function () {
|
|
|
286
834
|
userId: null,
|
|
287
835
|
token: null,
|
|
288
836
|
pending: false,
|
|
289
|
-
wasAuthenticatedBefore: false
|
|
837
|
+
wasAuthenticatedBefore: false,
|
|
838
|
+
passkeyOnly: false
|
|
290
839
|
}
|
|
291
840
|
});
|
|
292
841
|
});
|
|
@@ -317,41 +866,41 @@ describe('auth actions', function () {
|
|
|
317
866
|
isAuthenticated: true
|
|
318
867
|
}
|
|
319
868
|
});
|
|
320
|
-
it('should call apex.connection.WebAuthenticateUser with expected params', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
321
|
-
return _regenerator().w(function (
|
|
322
|
-
while (1) switch (
|
|
869
|
+
it('should call apex.connection.WebAuthenticateUser with expected params', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee18() {
|
|
870
|
+
return _regenerator().w(function (_context18) {
|
|
871
|
+
while (1) switch (_context18.n) {
|
|
323
872
|
case 0:
|
|
324
|
-
|
|
873
|
+
_context18.n = 1;
|
|
325
874
|
return store.dispatch(actions.validateSessionToken(token));
|
|
326
875
|
case 1:
|
|
327
876
|
expect(_apex["default"].connection.WebAuthenticateUser).toHaveBeenCalledWith({
|
|
328
877
|
SessionToken: token
|
|
329
878
|
});
|
|
330
879
|
case 2:
|
|
331
|
-
return
|
|
880
|
+
return _context18.a(2);
|
|
332
881
|
}
|
|
333
|
-
},
|
|
882
|
+
}, _callee18);
|
|
334
883
|
})));
|
|
335
|
-
it('should call setTimout if config have authTimeout', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
336
|
-
return _regenerator().w(function (
|
|
337
|
-
while (1) switch (
|
|
884
|
+
it('should call setTimout if config have authTimeout', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee19() {
|
|
885
|
+
return _regenerator().w(function (_context19) {
|
|
886
|
+
while (1) switch (_context19.n) {
|
|
338
887
|
case 0:
|
|
339
|
-
|
|
888
|
+
_context19.n = 1;
|
|
340
889
|
return store.dispatch(actions.validateSessionToken(token));
|
|
341
890
|
case 1:
|
|
342
891
|
expect(setTimeout).toHaveBeenCalledTimes(1);
|
|
343
892
|
expect(setTimeout).toHaveBeenLastCalledWith(expect.any(Function), 1000);
|
|
344
893
|
case 2:
|
|
345
|
-
return
|
|
894
|
+
return _context19.a(2);
|
|
346
895
|
}
|
|
347
|
-
},
|
|
896
|
+
}, _callee19);
|
|
348
897
|
})));
|
|
349
|
-
it('should dispatch AUTH_SUCCESS action', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
898
|
+
it('should dispatch AUTH_SUCCESS action', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee20() {
|
|
350
899
|
var dispatchedActions, haveAuthSuccessAction;
|
|
351
|
-
return _regenerator().w(function (
|
|
352
|
-
while (1) switch (
|
|
900
|
+
return _regenerator().w(function (_context20) {
|
|
901
|
+
while (1) switch (_context20.n) {
|
|
353
902
|
case 0:
|
|
354
|
-
|
|
903
|
+
_context20.n = 1;
|
|
355
904
|
return store.dispatch(actions.validateSessionToken(token));
|
|
356
905
|
case 1:
|
|
357
906
|
dispatchedActions = store.getActions();
|
|
@@ -360,17 +909,17 @@ describe('auth actions', function () {
|
|
|
360
909
|
});
|
|
361
910
|
expect(haveAuthSuccessAction).toBe(true);
|
|
362
911
|
case 2:
|
|
363
|
-
return
|
|
912
|
+
return _context20.a(2);
|
|
364
913
|
}
|
|
365
|
-
},
|
|
914
|
+
}, _callee20);
|
|
366
915
|
})));
|
|
367
|
-
it('should dispatch AUTH_NONE action', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
916
|
+
it('should dispatch AUTH_NONE action', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee21() {
|
|
368
917
|
var expiredToken, dispatchedActions, haveAuthNoneAction;
|
|
369
|
-
return _regenerator().w(function (
|
|
370
|
-
while (1) switch (
|
|
918
|
+
return _regenerator().w(function (_context21) {
|
|
919
|
+
while (1) switch (_context21.n) {
|
|
371
920
|
case 0:
|
|
372
921
|
expiredToken = 0;
|
|
373
|
-
|
|
922
|
+
_context21.n = 1;
|
|
374
923
|
return store.dispatch(actions.validateSessionToken(expiredToken));
|
|
375
924
|
case 1:
|
|
376
925
|
dispatchedActions = store.getActions();
|
|
@@ -379,9 +928,9 @@ describe('auth actions', function () {
|
|
|
379
928
|
});
|
|
380
929
|
expect(haveAuthNoneAction).toBe(true);
|
|
381
930
|
case 2:
|
|
382
|
-
return
|
|
931
|
+
return _context21.a(2);
|
|
383
932
|
}
|
|
384
|
-
},
|
|
933
|
+
}, _callee21);
|
|
385
934
|
})));
|
|
386
935
|
});
|
|
387
936
|
describe('sendTwoFactorAuthCode method', function () {
|
|
@@ -392,27 +941,27 @@ describe('auth actions', function () {
|
|
|
392
941
|
userId: 1
|
|
393
942
|
}
|
|
394
943
|
});
|
|
395
|
-
it('should call apex.connection.Authenticate2FA with expected params', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
396
|
-
return _regenerator().w(function (
|
|
397
|
-
while (1) switch (
|
|
944
|
+
it('should call apex.connection.Authenticate2FA with expected params', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee22() {
|
|
945
|
+
return _regenerator().w(function (_context22) {
|
|
946
|
+
while (1) switch (_context22.n) {
|
|
398
947
|
case 0:
|
|
399
|
-
|
|
948
|
+
_context22.n = 1;
|
|
400
949
|
return store.dispatch(actions.sendTwoFactorAuthCode(code));
|
|
401
950
|
case 1:
|
|
402
951
|
expect(_apex["default"].connection.Authenticate2FA).toHaveBeenCalledWith({
|
|
403
952
|
Code: code
|
|
404
953
|
});
|
|
405
954
|
case 2:
|
|
406
|
-
return
|
|
955
|
+
return _context22.a(2);
|
|
407
956
|
}
|
|
408
|
-
},
|
|
957
|
+
}, _callee22);
|
|
409
958
|
})));
|
|
410
|
-
it('should dispatch AUTH_SUCCESS action when code is valid', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
959
|
+
it('should dispatch AUTH_SUCCESS action when code is valid', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee23() {
|
|
411
960
|
var dispatchedActions, haveAuthSuccessAction;
|
|
412
|
-
return _regenerator().w(function (
|
|
413
|
-
while (1) switch (
|
|
961
|
+
return _regenerator().w(function (_context23) {
|
|
962
|
+
while (1) switch (_context23.n) {
|
|
414
963
|
case 0:
|
|
415
|
-
|
|
964
|
+
_context23.n = 1;
|
|
416
965
|
return store.dispatch(actions.sendTwoFactorAuthCode(code));
|
|
417
966
|
case 1:
|
|
418
967
|
dispatchedActions = store.getActions();
|
|
@@ -421,17 +970,48 @@ describe('auth actions', function () {
|
|
|
421
970
|
});
|
|
422
971
|
expect(haveAuthSuccessAction).toBe(true);
|
|
423
972
|
case 2:
|
|
424
|
-
return
|
|
973
|
+
return _context23.a(2);
|
|
974
|
+
}
|
|
975
|
+
}, _callee23);
|
|
976
|
+
})));
|
|
977
|
+
it('treats a rejected m:5 reply as the result so the "Endpoint Not Found" check still runs', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee24() {
|
|
978
|
+
var frame, errorSpy, authErrors;
|
|
979
|
+
return _regenerator().w(function (_context24) {
|
|
980
|
+
while (1) switch (_context24.n) {
|
|
981
|
+
case 0:
|
|
982
|
+
frame = {
|
|
983
|
+
m: 5,
|
|
984
|
+
i: 8,
|
|
985
|
+
n: 'Authenticate2FA',
|
|
986
|
+
o: 'Endpoint Not Found'
|
|
987
|
+
};
|
|
988
|
+
_apex["default"].connection.Authenticate2FA.mockImplementationOnce(function () {
|
|
989
|
+
return Promise.reject(frame);
|
|
990
|
+
});
|
|
991
|
+
errorSpy = jest.spyOn(console, 'error').mockImplementation(function () {});
|
|
992
|
+
_context24.n = 1;
|
|
993
|
+
return store.dispatch(actions.sendTwoFactorAuthCode(code));
|
|
994
|
+
case 1:
|
|
995
|
+
// No stored credentials to re-authenticate with, so the frame falls through to authError.
|
|
996
|
+
authErrors = store.getActions().filter(function (action) {
|
|
997
|
+
return action.type === actions.AUTH_ERROR;
|
|
998
|
+
});
|
|
999
|
+
expect(authErrors.length).toBeGreaterThan(0);
|
|
1000
|
+
expect(authErrors[authErrors.length - 1].payload.errorMsg).toBe('Endpoint Not Found');
|
|
1001
|
+
expect(errorSpy).not.toHaveBeenCalledWith('[2FA] Error during 2FA authentication:', expect.anything());
|
|
1002
|
+
errorSpy.mockRestore();
|
|
1003
|
+
case 2:
|
|
1004
|
+
return _context24.a(2);
|
|
425
1005
|
}
|
|
426
|
-
},
|
|
1006
|
+
}, _callee24);
|
|
427
1007
|
})));
|
|
428
|
-
it('should dispatch AUTH_ERROR action when code is invalid', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1008
|
+
it('should dispatch AUTH_ERROR action when code is invalid', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee25() {
|
|
429
1009
|
var code, dispatchedActions, haveAuthErrorAction;
|
|
430
|
-
return _regenerator().w(function (
|
|
431
|
-
while (1) switch (
|
|
1010
|
+
return _regenerator().w(function (_context25) {
|
|
1011
|
+
while (1) switch (_context25.n) {
|
|
432
1012
|
case 0:
|
|
433
1013
|
code = 0;
|
|
434
|
-
|
|
1014
|
+
_context25.n = 1;
|
|
435
1015
|
return store.dispatch(actions.sendTwoFactorAuthCode(code));
|
|
436
1016
|
case 1:
|
|
437
1017
|
dispatchedActions = store.getActions();
|
|
@@ -440,9 +1020,9 @@ describe('auth actions', function () {
|
|
|
440
1020
|
});
|
|
441
1021
|
expect(haveAuthErrorAction).toBe(true);
|
|
442
1022
|
case 2:
|
|
443
|
-
return
|
|
1023
|
+
return _context25.a(2);
|
|
444
1024
|
}
|
|
445
|
-
},
|
|
1025
|
+
}, _callee25);
|
|
446
1026
|
})));
|
|
447
1027
|
});
|
|
448
1028
|
});
|