@alphapoint/apex-web 5.5.6 → 5.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/apex.integration.test.js +435 -0
- package/lib/apex.js +37 -1
- package/lib/apex.test.js +138 -0
- package/lib/components/2FA/PasskeyOption.js +126 -0
- package/lib/components/2FA/TwoFactorAuthComponent.js +24 -5
- package/lib/components/2FA/TwoFactorAuthComponent.test.js +94 -0
- package/lib/components/2FA/TwoFactorAuthContainer.js +139 -27
- package/lib/components/2FA/TwoFactorAuthContainer.test.js +627 -0
- package/lib/components/AccountsDropdown/AccountsDropdownComponent.css +6 -0
- package/lib/components/AccountsDropdown/AccountsDropdownComponent.js +6 -2
- package/lib/components/AccountsDropdown/AccountsDropdownComponent.test.js +43 -0
- package/lib/components/AccountsDropdown/AccountsDropdownContainer.js +3 -1
- package/lib/components/BalancesList/BalancesListContainer.js +4 -1
- package/lib/components/ConfirmBlockTradeModal/ConfirmBlockTradeModalContainer.js +34 -6
- package/lib/components/ConfirmBlockTradeModal/ConfirmBlockTradeModalContainer.test.js +298 -0
- package/lib/components/ConfirmOrderModal/ConfirmOrderModalComponent.js +26 -4
- package/lib/components/ConfirmOrderModal/ConfirmOrderModalContainer.js +4 -1
- package/lib/components/DigitalAssets/digitalAssetsPriceLabel.test.js +238 -0
- package/lib/components/EnableTwoFactorAuth/Disable2FAForm.js +22 -7
- package/lib/components/EnableTwoFactorAuth/Disable2FAModal.js +15 -5
- package/lib/components/EnableTwoFactorAuth/Disable2FAModal.test.js +460 -0
- package/lib/components/EnableTwoFactorAuth/Disable2FAModalContainer.js +108 -16
- package/lib/components/EnableTwoFactorAuth/EnableTwoFactorAuthComponent.js +7 -0
- package/lib/components/EnableTwoFactorAuth/EnableTwoFactorAuthComponent.test.js +105 -0
- package/lib/components/EnableTwoFactorAuth/EnableTwoFactorAuthContainerFactory.js +15 -3
- package/lib/components/FusionAuth/UnlinkOAuthIdentityModal.css +13 -0
- package/lib/components/FusionAuth/UnlinkOAuthIdentityModal.js +246 -0
- package/lib/components/FusionAuth/UnlinkOAuthIdentityModal.test.js +521 -0
- package/lib/components/InstrumentPositions/InstrumentPositionsContainer.js +4 -1
- package/lib/components/Login/LoginFormComponent.js +1 -1
- package/lib/components/MarginBalances/MarginDepositWithdraw/MarginDepositModal/MarginDepositFormContainer.js +2 -1
- package/lib/components/NoAccountBanner/NoAccountBanner.css +9 -0
- package/lib/components/NoAccountBanner/NoAccountBanner.js +58 -0
- package/lib/components/NoAccountBanner/index.js +16 -0
- package/lib/components/NoAccountPlaceholder/NoAccountPlaceholder.css +31 -0
- package/lib/components/NoAccountPlaceholder/NoAccountPlaceholder.js +33 -0
- package/lib/components/NoAccountPlaceholder/index.js +9 -0
- package/lib/components/OrderEntryComponents/advancedForm/AdvancedOrderFormContainer.js +2 -0
- package/lib/components/OrderEntryComponents/common/FormAmountFields.js +5 -0
- package/lib/components/OrderEntryComponents/common/TwapScheduleFields.js +98 -0
- package/lib/components/OrderEntryComponents/defaultForm/OrderEntryAnchoring.js +86 -39
- package/lib/components/OrderEntryComponents/defaultForm/OrderEntryAnchoring.test.js +326 -0
- package/lib/components/OrderEntryComponents/defaultForm/OrderEntryContainer.js +10 -2
- package/lib/components/OrderHistoryComponents/DepositsStatus/DepositsStatusComponent.js +1 -1
- package/lib/components/OrderHistoryComponents/DepositsStatus/DepositsStatusComponent.test.js +99 -0
- package/lib/components/OrderHistoryComponents/InactiveOrders/InactiveOrdersComponent.js +1 -1
- package/lib/components/OrderHistoryComponents/OpenOrders/OpenOrdersComponent.js +1 -1
- package/lib/components/OrderHistoryComponents/WithdrawStatus/WithdrawStatusComponent.js +1 -1
- package/lib/components/OrderHistoryComponents/WithdrawStatus/WithdrawStatusComponent.test.js +113 -0
- package/lib/components/Settings/ProfileAndSecurity/PasskeysSettingsCard/PasskeysSettingsCard.css +108 -0
- package/lib/components/Settings/ProfileAndSecurity/PasskeysSettingsCard/PasskeysSettingsCard.test.js +983 -0
- package/lib/components/Settings/ProfileAndSecurity/PasskeysSettingsCard/PasskeysSettingsCardComponent.js +500 -0
- package/lib/components/Settings/ProfileAndSecurity/PasskeysSettingsCard/index.js +9 -0
- package/lib/components/Settings/ProfileAndSecurity/ProfileSettingsCard/ProfileForm/SsoLinkRowComponent.css +4 -0
- package/lib/components/Settings/ProfileAndSecurity/ProfileSettingsCard/ProfileForm/SsoLinkRowComponent.js +29 -17
- package/lib/components/Settings/ProfileAndSecurity/ProfileSettingsCard/ProfileForm/SsoLinkRowComponent.test.js +135 -0
- package/lib/components/Settings/ProfileAndSecurity/TwoFactorAuthSettingsCard/EnableTwoFactorAuth/EnableTwoFactorAuthComponent.js +12 -4
- package/lib/components/Settings/ProfileAndSecurity/TwoFactorAuthSettingsCard/EnableTwoFactorAuth/EnableTwoFactorAuthComponent.test.js +268 -0
- package/lib/components/TwoFactorAuthForm/TwoFactorAuthForm.test.js +475 -0
- package/lib/components/TwoFactorAuthForm/TwoFactorAuthFormComponent.js +26 -5
- package/lib/components/TwoFactorAuthForm/TwoFactorAuthFormContainer.js +50 -32
- package/lib/components/common/APAutoTabInput/APAutoTabInput.js +5 -2
- package/lib/components/common/APSelect/APSelect.js +3 -1
- package/lib/components/common/ErrorBoundary/ErrorBoundary.css +35 -0
- package/lib/components/common/ErrorBoundary/ErrorBoundary.js +87 -0
- package/lib/config/CONFIG.md +4 -0
- package/lib/config/configDefault.json +2 -1
- package/lib/constants/sendOrder/orderEntryFormConstants.js +23 -4
- package/lib/constants/sendOrder/timeInForceConstants.js +3 -1
- package/lib/constants/sendOrder/twapRejectReasons.js +26 -0
- package/lib/helpers/errorTextFormatter.js +13 -4
- package/lib/helpers/errorTextFormatter.test.js +26 -0
- package/lib/helpers/orderHistoryHelper.js +13 -1
- package/lib/helpers/orderHistoryHelper.test.js +58 -13
- package/lib/helpers/passkeyApi.js +228 -0
- package/lib/helpers/passkeyApi.test.js +171 -0
- package/lib/helpers/placeOrderHelper.js +76 -61
- package/lib/helpers/placeOrderHelper.test.js +169 -10
- package/lib/helpers/recalculateOrderHelper.js +4 -1
- package/lib/helpers/recalculateOrderHelper.test.js +88 -2
- package/lib/helpers/twapOrderHelper.js +265 -0
- package/lib/helpers/twapOrderHelper.test.js +467 -0
- package/lib/helpers/twoFactorAuthCancellation.js +38 -0
- package/lib/helpers/webauthnHelper.js +300 -0
- package/lib/helpers/webauthnHelper.test.js +199 -0
- package/lib/hocs/forAccount.js +33 -0
- package/lib/hocs/forAccount.test.js +50 -0
- package/lib/hocs/forVerified.js +16 -2
- package/lib/hocs/withAuthentication.js +3 -1
- package/lib/hocs/withOneSubmission.js +168 -0
- package/lib/index.js +3 -2
- package/lib/layouts/HeaderLayout/HeaderLayout.js +2 -1
- package/lib/layouts/WalletsLayout/WalletsLayoutContainer.js +3 -1
- package/lib/layouts/WalletsLayout/WalletsLayoutContainer.test.js +84 -0
- package/lib/redux/actions/apiActions.js +77 -9
- package/lib/redux/actions/apiActions.test.js +233 -0
- package/lib/redux/actions/authActions.js +514 -198
- package/lib/redux/actions/authActions.test.js +627 -47
- package/lib/redux/actions/depositActions.js +1 -1
- package/lib/redux/actions/depositActions.test.js +100 -30
- package/lib/redux/actions/fusionAuthActions.test.js +265 -84
- package/lib/redux/actions/interestAccountActions.js +12 -3
- package/lib/redux/actions/interestAccountActions.test.js +73 -0
- package/lib/redux/actions/modalActions.js +1 -0
- package/lib/redux/actions/orderEntryActions.blockTrade.test.js +306 -0
- package/lib/redux/actions/orderEntryActions.js +74 -22
- package/lib/redux/actions/orderEntryActions.test.js +63 -11
- package/lib/redux/actions/orderHistoryActions.js +20 -8
- package/lib/redux/actions/orderHistoryActions.test.js +63 -0
- package/lib/redux/actions/userActions.js +379 -179
- package/lib/redux/actions/userActions.test.js +925 -234
- package/lib/redux/actions/withdrawActions.js +62 -29
- package/lib/redux/actions/withdrawActions.test.js +246 -73
- package/lib/redux/actions/withdrawActions.travelRule.test.js +17 -3
- package/lib/redux/margin/actions/marginActions.js +6 -3
- package/lib/redux/margin/actions/marginActions.test.js +166 -0
- package/lib/redux/middlewares/authMiddleware.js +5 -0
- package/lib/redux/middlewares/authMiddleware.test.js +88 -29
- package/lib/redux/reducers/authReducer.js +1 -0
- package/lib/redux/reducers/authReducer.test.js +38 -0
- package/lib/redux/reducers/userReducer.js +10 -0
- package/lib/redux/reducers/userReducer.test.js +29 -0
- package/lib/redux/selectors/orderEntrySelector.js +19 -8
- package/lib/redux/selectors/orderEntrySelector.test.js +209 -0
- package/lib/redux/selectors/orderTotalSelector.test.js +40 -1
- package/lib/redux/selectors/recentActivitySelector.js +8 -2
- package/lib/redux/selectors/recentActivitySelector.v2.test.js +33 -0
- package/lib/redux/selectors/userSelectors.js +6 -1
- package/lib/redux/selectors/userSelectors.test.js +28 -0
- package/lib/services/fms/fms.js +2 -0
- package/lib/services/fms/fms.test.js +35 -0
- package/package.json +4 -4
|
@@ -0,0 +1,627 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _TwoFactorAuthContainer = require("./TwoFactorAuthContainer");
|
|
4
|
+
var _passkeyApi = require("../../helpers/passkeyApi");
|
|
5
|
+
var _twoFactorAuthCancellation = require("../../helpers/twoFactorAuthCancellation");
|
|
6
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
7
|
+
function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
|
|
8
|
+
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); }
|
|
9
|
+
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); }
|
|
10
|
+
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); }); }; }
|
|
11
|
+
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; }
|
|
12
|
+
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; }
|
|
13
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
14
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
15
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
16
|
+
jest.mock('../../helpers/passkeyApi', function () {
|
|
17
|
+
return {
|
|
18
|
+
PASSKEY_TFA_TYPE: 'WebAuthn',
|
|
19
|
+
answerWithPasskey: jest.fn()
|
|
20
|
+
};
|
|
21
|
+
});
|
|
22
|
+
describe('TwoFactorAuthContainer', function () {
|
|
23
|
+
var t = function t(key) {
|
|
24
|
+
return key;
|
|
25
|
+
};
|
|
26
|
+
var submitWith = function submitWith(reply) {
|
|
27
|
+
var overrides = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
28
|
+
var props = _objectSpread({
|
|
29
|
+
apiCall: jest.fn(function () {
|
|
30
|
+
return Promise.resolve({
|
|
31
|
+
o: JSON.stringify(reply)
|
|
32
|
+
});
|
|
33
|
+
}),
|
|
34
|
+
apiPayload: '{}',
|
|
35
|
+
close: jest.fn(),
|
|
36
|
+
resolve: jest.fn(),
|
|
37
|
+
t: t
|
|
38
|
+
}, overrides);
|
|
39
|
+
return {
|
|
40
|
+
props: props,
|
|
41
|
+
run: function run() {
|
|
42
|
+
return (0, _TwoFactorAuthContainer.onSubmit)({
|
|
43
|
+
code: '000000'
|
|
44
|
+
}, jest.fn(), props);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
describe('isPasskeyOnly', function () {
|
|
49
|
+
it('offers only the passkey for a passkey user, or when the gateway refuses a code alone', function () {
|
|
50
|
+
expect((0, _TwoFactorAuthContainer.isPasskeyOnly)({
|
|
51
|
+
TFaType: {
|
|
52
|
+
Value: 'WebAuthn'
|
|
53
|
+
}
|
|
54
|
+
})).toBe(true);
|
|
55
|
+
expect((0, _TwoFactorAuthContainer.isPasskeyOnly)({
|
|
56
|
+
TFaType: {
|
|
57
|
+
Value: 'Google'
|
|
58
|
+
},
|
|
59
|
+
authPasskeyOnly: true
|
|
60
|
+
})).toBe(true);
|
|
61
|
+
expect((0, _TwoFactorAuthContainer.isPasskeyOnly)({
|
|
62
|
+
TFaType: {
|
|
63
|
+
Value: 'Google'
|
|
64
|
+
},
|
|
65
|
+
authPasskeyOnly: false
|
|
66
|
+
})).toBe(false);
|
|
67
|
+
expect((0, _TwoFactorAuthContainer.isPasskeyOnly)({})).toBe(false);
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
describe('isTwoFactorRefusal', function () {
|
|
71
|
+
it('recognises both refusal shapes the gateway sends', function () {
|
|
72
|
+
expect((0, _TwoFactorAuthContainer.isTwoFactorRefusal)({
|
|
73
|
+
TFaAuthenticated: false
|
|
74
|
+
})).toBe(true);
|
|
75
|
+
expect((0, _TwoFactorAuthContainer.isTwoFactorRefusal)({
|
|
76
|
+
Authenticated: false
|
|
77
|
+
})).toBe(true);
|
|
78
|
+
});
|
|
79
|
+
it('does not treat a successful reply or an empty one as a refusal', function () {
|
|
80
|
+
expect((0, _TwoFactorAuthContainer.isTwoFactorRefusal)({
|
|
81
|
+
result: true
|
|
82
|
+
})).toBe(false);
|
|
83
|
+
expect((0, _TwoFactorAuthContainer.isTwoFactorRefusal)(null)).toBe(false);
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
describe('onSubmit', function () {
|
|
87
|
+
it('keeps the modal open and shows the backend message when 2FA is not enabled', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
88
|
+
var _submitWith, props, run;
|
|
89
|
+
return _regenerator().w(function (_context) {
|
|
90
|
+
while (1) switch (_context.n) {
|
|
91
|
+
case 0:
|
|
92
|
+
_submitWith = submitWith({
|
|
93
|
+
Authenticated: false,
|
|
94
|
+
errormsg: 'two-factor authentication is not enabled or user is not logged in'
|
|
95
|
+
}), props = _submitWith.props, run = _submitWith.run;
|
|
96
|
+
_context.n = 1;
|
|
97
|
+
return expect(run()).rejects.toMatchObject({
|
|
98
|
+
errors: {
|
|
99
|
+
_error: 'two-factor authentication is not enabled or user is not logged in'
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
case 1:
|
|
103
|
+
expect(props.close).not.toHaveBeenCalled();
|
|
104
|
+
expect(props.resolve).not.toHaveBeenCalled();
|
|
105
|
+
case 2:
|
|
106
|
+
return _context.a(2);
|
|
107
|
+
}
|
|
108
|
+
}, _callee);
|
|
109
|
+
})));
|
|
110
|
+
it('shows the errMsg for a wrong code', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
|
|
111
|
+
var _submitWith2, run;
|
|
112
|
+
return _regenerator().w(function (_context2) {
|
|
113
|
+
while (1) switch (_context2.n) {
|
|
114
|
+
case 0:
|
|
115
|
+
_submitWith2 = submitWith({
|
|
116
|
+
TFaAuthenticated: false,
|
|
117
|
+
errMsg: 'Invalid code'
|
|
118
|
+
}), run = _submitWith2.run;
|
|
119
|
+
_context2.n = 1;
|
|
120
|
+
return expect(run()).rejects.toMatchObject({
|
|
121
|
+
errors: {
|
|
122
|
+
_error: 'Invalid code'
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
case 1:
|
|
126
|
+
return _context2.a(2);
|
|
127
|
+
}
|
|
128
|
+
}, _callee2);
|
|
129
|
+
})));
|
|
130
|
+
it('falls back to a translated message when the refusal carries no text', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3() {
|
|
131
|
+
var _submitWith3, run;
|
|
132
|
+
return _regenerator().w(function (_context3) {
|
|
133
|
+
while (1) switch (_context3.n) {
|
|
134
|
+
case 0:
|
|
135
|
+
_submitWith3 = submitWith({
|
|
136
|
+
Authenticated: false
|
|
137
|
+
}), run = _submitWith3.run;
|
|
138
|
+
_context3.n = 1;
|
|
139
|
+
return expect(run()).rejects.toMatchObject({
|
|
140
|
+
errors: {
|
|
141
|
+
_error: 'Two-factor authentication failed. Please try again.'
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
case 1:
|
|
145
|
+
return _context3.a(2);
|
|
146
|
+
}
|
|
147
|
+
}, _callee3);
|
|
148
|
+
})));
|
|
149
|
+
it('treats whitespace-only text as blank', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4() {
|
|
150
|
+
var _submitWith4, run;
|
|
151
|
+
return _regenerator().w(function (_context4) {
|
|
152
|
+
while (1) switch (_context4.n) {
|
|
153
|
+
case 0:
|
|
154
|
+
_submitWith4 = submitWith({
|
|
155
|
+
Authenticated: false,
|
|
156
|
+
errormsg: ' \t\n '
|
|
157
|
+
}), run = _submitWith4.run;
|
|
158
|
+
_context4.n = 1;
|
|
159
|
+
return expect(run()).rejects.toMatchObject({
|
|
160
|
+
errors: {
|
|
161
|
+
_error: 'Two-factor authentication failed. Please try again.'
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
case 1:
|
|
165
|
+
return _context4.a(2);
|
|
166
|
+
}
|
|
167
|
+
}, _callee4);
|
|
168
|
+
})));
|
|
169
|
+
it('does not let a blank errMsg hide a populated errormsg', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5() {
|
|
170
|
+
var _submitWith5, run;
|
|
171
|
+
return _regenerator().w(function (_context5) {
|
|
172
|
+
while (1) switch (_context5.n) {
|
|
173
|
+
case 0:
|
|
174
|
+
_submitWith5 = submitWith({
|
|
175
|
+
TFaAuthenticated: false,
|
|
176
|
+
errMsg: ' ',
|
|
177
|
+
errormsg: 'Invalid TFa Code'
|
|
178
|
+
}), run = _submitWith5.run;
|
|
179
|
+
_context5.n = 1;
|
|
180
|
+
return expect(run()).rejects.toMatchObject({
|
|
181
|
+
errors: {
|
|
182
|
+
_error: 'Invalid TFa Code'
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
case 1:
|
|
186
|
+
return _context5.a(2);
|
|
187
|
+
}
|
|
188
|
+
}, _callee5);
|
|
189
|
+
})));
|
|
190
|
+
it('closes the modal and resolves with the reply on success', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6() {
|
|
191
|
+
var _submitWith6, props, run;
|
|
192
|
+
return _regenerator().w(function (_context6) {
|
|
193
|
+
while (1) switch (_context6.n) {
|
|
194
|
+
case 0:
|
|
195
|
+
_submitWith6 = submitWith({
|
|
196
|
+
result: true,
|
|
197
|
+
detail: '123'
|
|
198
|
+
}), props = _submitWith6.props, run = _submitWith6.run;
|
|
199
|
+
_context6.n = 1;
|
|
200
|
+
return run();
|
|
201
|
+
case 1:
|
|
202
|
+
expect(props.close).toHaveBeenCalled();
|
|
203
|
+
expect(props.resolve).toHaveBeenCalledWith({
|
|
204
|
+
result: true,
|
|
205
|
+
detail: '123'
|
|
206
|
+
});
|
|
207
|
+
case 2:
|
|
208
|
+
return _context6.a(2);
|
|
209
|
+
}
|
|
210
|
+
}, _callee6);
|
|
211
|
+
})));
|
|
212
|
+
});
|
|
213
|
+
describe('onCancel', function () {
|
|
214
|
+
it('settles the pending api promise and closes the modal', function () {
|
|
215
|
+
var reject = jest.fn();
|
|
216
|
+
var close = jest.fn();
|
|
217
|
+
(0, _TwoFactorAuthContainer.onCancel)({
|
|
218
|
+
reject: reject,
|
|
219
|
+
close: close
|
|
220
|
+
})();
|
|
221
|
+
expect(reject).toHaveBeenCalledTimes(1);
|
|
222
|
+
expect((0, _twoFactorAuthCancellation.isTwoFactorAuthCancellation)(reject.mock.calls[0][0])).toBe(true);
|
|
223
|
+
expect(close).toHaveBeenCalled();
|
|
224
|
+
});
|
|
225
|
+
it('still closes when no promise is pending', function () {
|
|
226
|
+
var close = jest.fn();
|
|
227
|
+
(0, _TwoFactorAuthContainer.onCancel)({
|
|
228
|
+
close: close
|
|
229
|
+
})();
|
|
230
|
+
expect(close).toHaveBeenCalled();
|
|
231
|
+
});
|
|
232
|
+
it('closes without rejecting while a code is being verified', function () {
|
|
233
|
+
var reject = jest.fn();
|
|
234
|
+
var close = jest.fn();
|
|
235
|
+
(0, _TwoFactorAuthContainer.onCancel)({
|
|
236
|
+
reject: reject,
|
|
237
|
+
close: close,
|
|
238
|
+
submitting: true
|
|
239
|
+
})();
|
|
240
|
+
expect(reject).not.toHaveBeenCalled();
|
|
241
|
+
expect(close).toHaveBeenCalled();
|
|
242
|
+
});
|
|
243
|
+
});
|
|
244
|
+
describe('onPasskey', function () {
|
|
245
|
+
it('answers the protected endpoint with a passkey as TfaType WebAuthn', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7() {
|
|
246
|
+
var _submitWith7, props;
|
|
247
|
+
return _regenerator().w(function (_context7) {
|
|
248
|
+
while (1) switch (_context7.n) {
|
|
249
|
+
case 0:
|
|
250
|
+
_passkeyApi.answerWithPasskey.mockResolvedValueOnce('assertion');
|
|
251
|
+
_submitWith7 = submitWith({
|
|
252
|
+
result: true
|
|
253
|
+
}), props = _submitWith7.props;
|
|
254
|
+
_context7.n = 1;
|
|
255
|
+
return (0, _TwoFactorAuthContainer.onPasskey)(props)();
|
|
256
|
+
case 1:
|
|
257
|
+
expect(props.apiCall).toHaveBeenCalledWith({
|
|
258
|
+
TfaType: 'WebAuthn',
|
|
259
|
+
TFaCode: 'assertion',
|
|
260
|
+
Payload: '{}'
|
|
261
|
+
});
|
|
262
|
+
expect(props.close).toHaveBeenCalled();
|
|
263
|
+
case 2:
|
|
264
|
+
return _context7.a(2);
|
|
265
|
+
}
|
|
266
|
+
}, _callee7);
|
|
267
|
+
})));
|
|
268
|
+
it('keeps the modal open with the reason when the passkey prompt fails', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8() {
|
|
269
|
+
var _submitWith8, props;
|
|
270
|
+
return _regenerator().w(function (_context8) {
|
|
271
|
+
while (1) switch (_context8.n) {
|
|
272
|
+
case 0:
|
|
273
|
+
_passkeyApi.answerWithPasskey.mockRejectedValueOnce(Object.assign(new Error('x'), {
|
|
274
|
+
name: 'NotAllowedError'
|
|
275
|
+
}));
|
|
276
|
+
_submitWith8 = submitWith({
|
|
277
|
+
result: true
|
|
278
|
+
}), props = _submitWith8.props;
|
|
279
|
+
_context8.n = 1;
|
|
280
|
+
return expect((0, _TwoFactorAuthContainer.onPasskey)(props)()).rejects.toMatchObject({
|
|
281
|
+
errors: {
|
|
282
|
+
_error: 'The passkey request was canceled or timed out. Try again.'
|
|
283
|
+
}
|
|
284
|
+
});
|
|
285
|
+
case 1:
|
|
286
|
+
expect(props.apiCall).not.toHaveBeenCalled();
|
|
287
|
+
expect(props.close).not.toHaveBeenCalled();
|
|
288
|
+
case 2:
|
|
289
|
+
return _context8.a(2);
|
|
290
|
+
}
|
|
291
|
+
}, _callee8);
|
|
292
|
+
})));
|
|
293
|
+
});
|
|
294
|
+
describe('closing the modal during a passkey answer', function () {
|
|
295
|
+
var deferred = function deferred() {
|
|
296
|
+
var resolve;
|
|
297
|
+
var promise = new Promise(function (r) {
|
|
298
|
+
resolve = r;
|
|
299
|
+
});
|
|
300
|
+
return {
|
|
301
|
+
promise: promise,
|
|
302
|
+
resolve: resolve
|
|
303
|
+
};
|
|
304
|
+
};
|
|
305
|
+
var flush = function flush() {
|
|
306
|
+
return new Promise(function (r) {
|
|
307
|
+
return setTimeout(r, 0);
|
|
308
|
+
});
|
|
309
|
+
};
|
|
310
|
+
it('leaves the caller waiting for the gateway once the answer is on its way, as for a code', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9() {
|
|
311
|
+
var reply, _submitWith9, props, passkey, answering;
|
|
312
|
+
return _regenerator().w(function (_context9) {
|
|
313
|
+
while (1) switch (_context9.n) {
|
|
314
|
+
case 0:
|
|
315
|
+
reply = deferred();
|
|
316
|
+
_passkeyApi.answerWithPasskey.mockResolvedValueOnce('assertion');
|
|
317
|
+
_submitWith9 = submitWith({}, {
|
|
318
|
+
reject: jest.fn(),
|
|
319
|
+
apiCall: jest.fn(function () {
|
|
320
|
+
return reply.promise;
|
|
321
|
+
})
|
|
322
|
+
}), props = _submitWith9.props;
|
|
323
|
+
passkey = {};
|
|
324
|
+
answering = (0, _TwoFactorAuthContainer.onPasskey)(props, passkey)();
|
|
325
|
+
_context9.n = 1;
|
|
326
|
+
return flush();
|
|
327
|
+
case 1:
|
|
328
|
+
expect(props.apiCall).toHaveBeenCalled();
|
|
329
|
+
(0, _TwoFactorAuthContainer.onCancel)(props, passkey)();
|
|
330
|
+
expect(props.reject).not.toHaveBeenCalled();
|
|
331
|
+
expect(props.close).toHaveBeenCalled();
|
|
332
|
+
reply.resolve({
|
|
333
|
+
o: JSON.stringify({
|
|
334
|
+
result: true
|
|
335
|
+
})
|
|
336
|
+
});
|
|
337
|
+
_context9.n = 2;
|
|
338
|
+
return answering;
|
|
339
|
+
case 2:
|
|
340
|
+
expect(props.resolve).toHaveBeenCalledWith({
|
|
341
|
+
result: true
|
|
342
|
+
});
|
|
343
|
+
case 3:
|
|
344
|
+
return _context9.a(2);
|
|
345
|
+
}
|
|
346
|
+
}, _callee9);
|
|
347
|
+
})));
|
|
348
|
+
it('sends nothing when closed while the browser prompt is still open', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0() {
|
|
349
|
+
var prompt, _submitWith0, props, passkey, answering;
|
|
350
|
+
return _regenerator().w(function (_context0) {
|
|
351
|
+
while (1) switch (_context0.n) {
|
|
352
|
+
case 0:
|
|
353
|
+
prompt = deferred();
|
|
354
|
+
_passkeyApi.answerWithPasskey.mockReturnValueOnce(prompt.promise);
|
|
355
|
+
_submitWith0 = submitWith({
|
|
356
|
+
result: true
|
|
357
|
+
}, {
|
|
358
|
+
reject: jest.fn()
|
|
359
|
+
}), props = _submitWith0.props;
|
|
360
|
+
passkey = {};
|
|
361
|
+
answering = (0, _TwoFactorAuthContainer.onPasskey)(props, passkey)();
|
|
362
|
+
(0, _TwoFactorAuthContainer.onCancel)(props, passkey)();
|
|
363
|
+
expect((0, _twoFactorAuthCancellation.isTwoFactorAuthCancellation)(props.reject.mock.calls[0][0])).toBe(true);
|
|
364
|
+
prompt.resolve('assertion');
|
|
365
|
+
_context0.n = 1;
|
|
366
|
+
return answering;
|
|
367
|
+
case 1:
|
|
368
|
+
expect(props.apiCall).not.toHaveBeenCalled();
|
|
369
|
+
expect(props.resolve).not.toHaveBeenCalled();
|
|
370
|
+
case 2:
|
|
371
|
+
return _context0.a(2);
|
|
372
|
+
}
|
|
373
|
+
}, _callee0);
|
|
374
|
+
})));
|
|
375
|
+
});
|
|
376
|
+
describe('one answer at a time, whether a code or a passkey', function () {
|
|
377
|
+
var deferred = function deferred() {
|
|
378
|
+
var resolve;
|
|
379
|
+
var promise = new Promise(function (r) {
|
|
380
|
+
resolve = r;
|
|
381
|
+
});
|
|
382
|
+
return {
|
|
383
|
+
promise: promise,
|
|
384
|
+
resolve: resolve
|
|
385
|
+
};
|
|
386
|
+
};
|
|
387
|
+
var flush = function flush() {
|
|
388
|
+
return new Promise(function (r) {
|
|
389
|
+
return setTimeout(r, 0);
|
|
390
|
+
});
|
|
391
|
+
};
|
|
392
|
+
var ok = {
|
|
393
|
+
o: JSON.stringify({
|
|
394
|
+
result: true
|
|
395
|
+
})
|
|
396
|
+
};
|
|
397
|
+
|
|
398
|
+
// a blocked answer leaves its queued browser reply unused
|
|
399
|
+
beforeEach(function () {
|
|
400
|
+
return _passkeyApi.answerWithPasskey.mockReset();
|
|
401
|
+
});
|
|
402
|
+
|
|
403
|
+
// the form's ownProps and the passkey answer share the submission, as in the container
|
|
404
|
+
var setUp = function setUp() {
|
|
405
|
+
var reply = deferred();
|
|
406
|
+
var submission = {
|
|
407
|
+
onChange: jest.fn()
|
|
408
|
+
};
|
|
409
|
+
var _submitWith1 = submitWith({}, {
|
|
410
|
+
apiCall: jest.fn(function () {
|
|
411
|
+
return reply.promise;
|
|
412
|
+
}),
|
|
413
|
+
submission: submission
|
|
414
|
+
}),
|
|
415
|
+
props = _submitWith1.props;
|
|
416
|
+
return {
|
|
417
|
+
reply: reply,
|
|
418
|
+
submission: submission,
|
|
419
|
+
props: props,
|
|
420
|
+
code: function code() {
|
|
421
|
+
return (0, _TwoFactorAuthContainer.onSubmit)({
|
|
422
|
+
code: '000000'
|
|
423
|
+
}, jest.fn(), props);
|
|
424
|
+
}
|
|
425
|
+
};
|
|
426
|
+
};
|
|
427
|
+
it('sends nothing for a passkey used while a code is being verified', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1() {
|
|
428
|
+
var _setUp, reply, submission, props, code, coding;
|
|
429
|
+
return _regenerator().w(function (_context1) {
|
|
430
|
+
while (1) switch (_context1.n) {
|
|
431
|
+
case 0:
|
|
432
|
+
_setUp = setUp(), reply = _setUp.reply, submission = _setUp.submission, props = _setUp.props, code = _setUp.code;
|
|
433
|
+
_passkeyApi.answerWithPasskey.mockResolvedValueOnce('assertion');
|
|
434
|
+
coding = code();
|
|
435
|
+
_context1.n = 1;
|
|
436
|
+
return (0, _TwoFactorAuthContainer.onPasskey)(props, submission)();
|
|
437
|
+
case 1:
|
|
438
|
+
reply.resolve(ok);
|
|
439
|
+
_context1.n = 2;
|
|
440
|
+
return coding;
|
|
441
|
+
case 2:
|
|
442
|
+
expect(props.apiCall).toHaveBeenCalledTimes(1);
|
|
443
|
+
expect(props.apiCall).toHaveBeenCalledWith({
|
|
444
|
+
TfaType: 'Google',
|
|
445
|
+
TFaCode: '000000',
|
|
446
|
+
Payload: '{}'
|
|
447
|
+
});
|
|
448
|
+
expect(props.resolve).toHaveBeenCalledTimes(1);
|
|
449
|
+
case 3:
|
|
450
|
+
return _context1.a(2);
|
|
451
|
+
}
|
|
452
|
+
}, _callee1);
|
|
453
|
+
})));
|
|
454
|
+
it('sends nothing for a code submitted while a passkey answer is on its way', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10() {
|
|
455
|
+
var _setUp2, reply, submission, props, code, answering;
|
|
456
|
+
return _regenerator().w(function (_context10) {
|
|
457
|
+
while (1) switch (_context10.n) {
|
|
458
|
+
case 0:
|
|
459
|
+
_setUp2 = setUp(), reply = _setUp2.reply, submission = _setUp2.submission, props = _setUp2.props, code = _setUp2.code;
|
|
460
|
+
_passkeyApi.answerWithPasskey.mockResolvedValueOnce('assertion');
|
|
461
|
+
answering = (0, _TwoFactorAuthContainer.onPasskey)(props, submission)();
|
|
462
|
+
_context10.n = 1;
|
|
463
|
+
return flush();
|
|
464
|
+
case 1:
|
|
465
|
+
_context10.n = 2;
|
|
466
|
+
return code();
|
|
467
|
+
case 2:
|
|
468
|
+
reply.resolve(ok);
|
|
469
|
+
_context10.n = 3;
|
|
470
|
+
return answering;
|
|
471
|
+
case 3:
|
|
472
|
+
expect(props.apiCall).toHaveBeenCalledTimes(1);
|
|
473
|
+
expect(props.apiCall).toHaveBeenCalledWith({
|
|
474
|
+
TfaType: 'WebAuthn',
|
|
475
|
+
TFaCode: 'assertion',
|
|
476
|
+
Payload: '{}'
|
|
477
|
+
});
|
|
478
|
+
expect(props.resolve).toHaveBeenCalledTimes(1);
|
|
479
|
+
case 4:
|
|
480
|
+
return _context10.a(2);
|
|
481
|
+
}
|
|
482
|
+
}, _callee10);
|
|
483
|
+
})));
|
|
484
|
+
it('sends nothing for a code submitted while the browser prompt is open', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11() {
|
|
485
|
+
var _setUp3, reply, submission, props, code, prompt, answering;
|
|
486
|
+
return _regenerator().w(function (_context11) {
|
|
487
|
+
while (1) switch (_context11.n) {
|
|
488
|
+
case 0:
|
|
489
|
+
_setUp3 = setUp(), reply = _setUp3.reply, submission = _setUp3.submission, props = _setUp3.props, code = _setUp3.code;
|
|
490
|
+
prompt = deferred();
|
|
491
|
+
_passkeyApi.answerWithPasskey.mockReturnValueOnce(prompt.promise);
|
|
492
|
+
answering = (0, _TwoFactorAuthContainer.onPasskey)(props, submission)();
|
|
493
|
+
_context11.n = 1;
|
|
494
|
+
return code();
|
|
495
|
+
case 1:
|
|
496
|
+
expect(props.apiCall).not.toHaveBeenCalled();
|
|
497
|
+
prompt.resolve('assertion');
|
|
498
|
+
_context11.n = 2;
|
|
499
|
+
return flush();
|
|
500
|
+
case 2:
|
|
501
|
+
reply.resolve(ok);
|
|
502
|
+
_context11.n = 3;
|
|
503
|
+
return answering;
|
|
504
|
+
case 3:
|
|
505
|
+
expect(props.apiCall).toHaveBeenCalledTimes(1);
|
|
506
|
+
expect(props.apiCall).toHaveBeenCalledWith({
|
|
507
|
+
TfaType: 'WebAuthn',
|
|
508
|
+
TFaCode: 'assertion',
|
|
509
|
+
Payload: '{}'
|
|
510
|
+
});
|
|
511
|
+
case 4:
|
|
512
|
+
return _context11.a(2);
|
|
513
|
+
}
|
|
514
|
+
}, _callee11);
|
|
515
|
+
})));
|
|
516
|
+
it('disables both answers while one holds the submission, and enables them on the reply', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12() {
|
|
517
|
+
var _setUp4, reply, submission, code, coding;
|
|
518
|
+
return _regenerator().w(function (_context12) {
|
|
519
|
+
while (1) switch (_context12.n) {
|
|
520
|
+
case 0:
|
|
521
|
+
_setUp4 = setUp(), reply = _setUp4.reply, submission = _setUp4.submission, code = _setUp4.code;
|
|
522
|
+
coding = code();
|
|
523
|
+
expect(submission.onChange).toHaveBeenLastCalledWith(true);
|
|
524
|
+
reply.resolve(ok);
|
|
525
|
+
_context12.n = 1;
|
|
526
|
+
return coding;
|
|
527
|
+
case 1:
|
|
528
|
+
expect(submission.onChange).toHaveBeenLastCalledWith(false);
|
|
529
|
+
expect(submission.current).toBeFalsy();
|
|
530
|
+
case 2:
|
|
531
|
+
return _context12.a(2);
|
|
532
|
+
}
|
|
533
|
+
}, _callee12);
|
|
534
|
+
})));
|
|
535
|
+
it('lets the user try again with either answer after a refused one', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13() {
|
|
536
|
+
var submission, apiCall, _submitWith10, props;
|
|
537
|
+
return _regenerator().w(function (_context13) {
|
|
538
|
+
while (1) switch (_context13.n) {
|
|
539
|
+
case 0:
|
|
540
|
+
submission = {};
|
|
541
|
+
apiCall = jest.fn().mockResolvedValueOnce({
|
|
542
|
+
o: JSON.stringify({
|
|
543
|
+
TFaAuthenticated: false,
|
|
544
|
+
errMsg: 'Invalid code'
|
|
545
|
+
})
|
|
546
|
+
}).mockResolvedValueOnce(ok);
|
|
547
|
+
_submitWith10 = submitWith({}, {
|
|
548
|
+
apiCall: apiCall,
|
|
549
|
+
submission: submission
|
|
550
|
+
}), props = _submitWith10.props;
|
|
551
|
+
_passkeyApi.answerWithPasskey.mockResolvedValueOnce('assertion');
|
|
552
|
+
_context13.n = 1;
|
|
553
|
+
return expect((0, _TwoFactorAuthContainer.onSubmit)({
|
|
554
|
+
code: '000000'
|
|
555
|
+
}, jest.fn(), props)).rejects.toMatchObject({
|
|
556
|
+
errors: {
|
|
557
|
+
_error: 'Invalid code'
|
|
558
|
+
}
|
|
559
|
+
});
|
|
560
|
+
case 1:
|
|
561
|
+
_context13.n = 2;
|
|
562
|
+
return (0, _TwoFactorAuthContainer.onPasskey)(props, submission)();
|
|
563
|
+
case 2:
|
|
564
|
+
expect(apiCall).toHaveBeenCalledTimes(2);
|
|
565
|
+
expect(props.resolve).toHaveBeenCalledWith({
|
|
566
|
+
result: true
|
|
567
|
+
});
|
|
568
|
+
case 3:
|
|
569
|
+
return _context13.a(2);
|
|
570
|
+
}
|
|
571
|
+
}, _callee13);
|
|
572
|
+
})));
|
|
573
|
+
it('lets go when the passkey prompt fails, so a code can still be sent', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee14() {
|
|
574
|
+
var _setUp5, reply, submission, props, code, coding;
|
|
575
|
+
return _regenerator().w(function (_context14) {
|
|
576
|
+
while (1) switch (_context14.n) {
|
|
577
|
+
case 0:
|
|
578
|
+
_setUp5 = setUp(), reply = _setUp5.reply, submission = _setUp5.submission, props = _setUp5.props, code = _setUp5.code;
|
|
579
|
+
_passkeyApi.answerWithPasskey.mockRejectedValueOnce(Object.assign(new Error('x'), {
|
|
580
|
+
name: 'NotAllowedError'
|
|
581
|
+
}));
|
|
582
|
+
_context14.n = 1;
|
|
583
|
+
return expect((0, _TwoFactorAuthContainer.onPasskey)(props, submission)()).rejects.toBeDefined();
|
|
584
|
+
case 1:
|
|
585
|
+
coding = code();
|
|
586
|
+
reply.resolve(ok);
|
|
587
|
+
_context14.n = 2;
|
|
588
|
+
return coding;
|
|
589
|
+
case 2:
|
|
590
|
+
expect(props.apiCall).toHaveBeenCalledTimes(1);
|
|
591
|
+
case 3:
|
|
592
|
+
return _context14.a(2);
|
|
593
|
+
}
|
|
594
|
+
}, _callee14);
|
|
595
|
+
})));
|
|
596
|
+
it('lets go when the modal is closed while the browser prompt is open, so the next opening can answer', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15() {
|
|
597
|
+
var _setUp6, reply, submission, props, code, prompt, stale, coding;
|
|
598
|
+
return _regenerator().w(function (_context15) {
|
|
599
|
+
while (1) switch (_context15.n) {
|
|
600
|
+
case 0:
|
|
601
|
+
_setUp6 = setUp(), reply = _setUp6.reply, submission = _setUp6.submission, props = _setUp6.props, code = _setUp6.code;
|
|
602
|
+
prompt = deferred();
|
|
603
|
+
_passkeyApi.answerWithPasskey.mockReturnValueOnce(prompt.promise);
|
|
604
|
+
stale = (0, _TwoFactorAuthContainer.onPasskey)(props, submission)();
|
|
605
|
+
(0, _TwoFactorAuthContainer.onCancel)(props, submission)();
|
|
606
|
+
coding = code();
|
|
607
|
+
prompt.resolve('assertion');
|
|
608
|
+
_context15.n = 1;
|
|
609
|
+
return stale;
|
|
610
|
+
case 1:
|
|
611
|
+
reply.resolve(ok);
|
|
612
|
+
_context15.n = 2;
|
|
613
|
+
return coding;
|
|
614
|
+
case 2:
|
|
615
|
+
expect(props.apiCall).toHaveBeenCalledTimes(1);
|
|
616
|
+
expect(props.apiCall).toHaveBeenCalledWith({
|
|
617
|
+
TfaType: 'Google',
|
|
618
|
+
TFaCode: '000000',
|
|
619
|
+
Payload: '{}'
|
|
620
|
+
});
|
|
621
|
+
case 3:
|
|
622
|
+
return _context15.a(2);
|
|
623
|
+
}
|
|
624
|
+
}, _callee15);
|
|
625
|
+
})));
|
|
626
|
+
});
|
|
627
|
+
});
|
|
@@ -128,6 +128,12 @@
|
|
|
128
128
|
color: inherit;
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
+
.accounts-dropdown__no-account {
|
|
132
|
+
font-size: var(--dropdown-font-base);
|
|
133
|
+
white-space: nowrap;
|
|
134
|
+
color: inherit;
|
|
135
|
+
}
|
|
136
|
+
|
|
131
137
|
.page-activity__username-in-display {
|
|
132
138
|
font-size: 18px;
|
|
133
139
|
font-weight: 400;
|
|
@@ -117,6 +117,7 @@ var AccountsDropdown = /*#__PURE__*/function (_React$Component) {
|
|
|
117
117
|
var _this2 = this;
|
|
118
118
|
var _this$props2 = this.props,
|
|
119
119
|
selectedAccount = _this$props2.selectedAccount,
|
|
120
|
+
hasNoAccounts = _this$props2.hasNoAccounts,
|
|
120
121
|
customClass = _this$props2.customClass,
|
|
121
122
|
t = _this$props2.t;
|
|
122
123
|
var bemClasses = (0, _cssClassesHelper.getBEMClasses)(['accounts-dropdown', customClass]);
|
|
@@ -145,7 +146,9 @@ var AccountsDropdown = /*#__PURE__*/function (_React$Component) {
|
|
|
145
146
|
customClass: 'accounts-dropdown'
|
|
146
147
|
},
|
|
147
148
|
items: this.renderMenuItems()
|
|
148
|
-
}) : /*#__PURE__*/_react["default"].createElement(
|
|
149
|
+
}) : hasNoAccounts ? /*#__PURE__*/_react["default"].createElement("span", {
|
|
150
|
+
className: bemClasses('no-account')
|
|
151
|
+
}, t('No account')) : /*#__PURE__*/_react["default"].createElement(_Spinner["default"], {
|
|
149
152
|
isInline: true,
|
|
150
153
|
customClass: bemClasses
|
|
151
154
|
}));
|
|
@@ -162,7 +165,8 @@ _defineProperty(AccountsDropdown, "propTypes", {
|
|
|
162
165
|
settingsRoute: _propTypes["default"].string,
|
|
163
166
|
activityRoute: _propTypes["default"].string,
|
|
164
167
|
betaOptedIn: _propTypes["default"].string,
|
|
165
|
-
showSelectedAccount: _propTypes["default"].bool
|
|
168
|
+
showSelectedAccount: _propTypes["default"].bool,
|
|
169
|
+
hasNoAccounts: _propTypes["default"].bool
|
|
166
170
|
});
|
|
167
171
|
_defineProperty(AccountsDropdown, "defaultProps", {
|
|
168
172
|
settingsRoute: ''
|