@alphapoint/apex-web 5.5.6 → 5.7.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/components/2FA/TwoFactorAuthContainer.js +58 -24
- package/lib/components/2FA/TwoFactorAuthContainer.test.js +215 -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/DigitalAssets/digitalAssetsPriceLabel.test.js +238 -0
- package/lib/components/EnableTwoFactorAuth/EnableTwoFactorAuthComponent.js +7 -0
- package/lib/components/EnableTwoFactorAuth/EnableTwoFactorAuthComponent.test.js +105 -0
- package/lib/components/EnableTwoFactorAuth/EnableTwoFactorAuthContainerFactory.js +12 -1
- package/lib/components/InstrumentPositions/InstrumentPositionsContainer.js +4 -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/Settings/ProfileAndSecurity/TwoFactorAuthSettingsCard/EnableTwoFactorAuth/EnableTwoFactorAuthComponent.js +12 -4
- package/lib/components/Settings/ProfileAndSecurity/TwoFactorAuthSettingsCard/EnableTwoFactorAuth/EnableTwoFactorAuthComponent.test.js +246 -0
- package/lib/components/common/ErrorBoundary/ErrorBoundary.css +35 -0
- package/lib/components/common/ErrorBoundary/ErrorBoundary.js +87 -0
- package/lib/helpers/errorTextFormatter.js +13 -4
- package/lib/helpers/errorTextFormatter.test.js +26 -0
- package/lib/helpers/twoFactorAuthCancellation.js +38 -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/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 +25 -8
- package/lib/redux/actions/apiActions.test.js +98 -0
- package/lib/redux/actions/interestAccountActions.js +12 -3
- package/lib/redux/actions/interestAccountActions.test.js +73 -0
- package/lib/redux/actions/orderHistoryActions.js +11 -4
- package/lib/redux/actions/userActions.js +97 -34
- package/lib/redux/actions/userActions.test.js +303 -188
- 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/reducers/userReducer.js +10 -0
- package/lib/redux/reducers/userReducer.test.js +29 -0
- 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/package.json +4 -4
|
@@ -0,0 +1,246 @@
|
|
|
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 _react = _interopRequireWildcard(require("react"));
|
|
5
|
+
var _client = require("react-dom/client");
|
|
6
|
+
var _reactRedux = require("react-redux");
|
|
7
|
+
var _redux = require("redux");
|
|
8
|
+
var _reduxThunk = _interopRequireDefault(require("redux-thunk"));
|
|
9
|
+
var _reduxForm = require("redux-form");
|
|
10
|
+
var _apex = _interopRequireDefault(require("../../../../../apex"));
|
|
11
|
+
var _EnableTwoFactorAuthContainerFactory = _interopRequireDefault(require("../../../../EnableTwoFactorAuth/EnableTwoFactorAuthContainerFactory"));
|
|
12
|
+
var _EnableTwoFactorAuthComponent = _interopRequireDefault(require("./EnableTwoFactorAuthComponent"));
|
|
13
|
+
var _modalActions = require("../../../../../redux/actions/modalActions");
|
|
14
|
+
var _snackbarActions = require("../../../../../redux/actions/snackbarActions");
|
|
15
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
16
|
+
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); }
|
|
17
|
+
function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
|
|
18
|
+
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
|
|
19
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
20
|
+
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
21
|
+
jest.mock('../../../../../apex', function () {
|
|
22
|
+
return {
|
|
23
|
+
__esModule: true,
|
|
24
|
+
"default": {
|
|
25
|
+
connection: {
|
|
26
|
+
EnableGoogle2FA: jest.fn()
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
});
|
|
31
|
+
jest.mock('react-i18next', function () {
|
|
32
|
+
return {
|
|
33
|
+
useTranslation: function useTranslation() {
|
|
34
|
+
return {
|
|
35
|
+
t: function t(key) {
|
|
36
|
+
return key;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// the modals are not under test; they need the modal and QR code slices of a full store
|
|
44
|
+
jest.mock('../../../../EnableTwoFactorAuth/Enable2FAModalContainer', function () {
|
|
45
|
+
return function () {
|
|
46
|
+
return null;
|
|
47
|
+
};
|
|
48
|
+
});
|
|
49
|
+
jest.mock('../../../../EnableTwoFactorAuth/Disable2FAModalContainer', function () {
|
|
50
|
+
return function () {
|
|
51
|
+
return null;
|
|
52
|
+
};
|
|
53
|
+
});
|
|
54
|
+
jest.mock('../../../../EnableTwoFactorAuth/GetGoogle2FARecoveryKeyModalContainer', function () {
|
|
55
|
+
return function () {
|
|
56
|
+
return null;
|
|
57
|
+
};
|
|
58
|
+
});
|
|
59
|
+
global.IS_REACT_ACT_ENVIRONMENT = true;
|
|
60
|
+
var SSO_MESSAGE = 'Two-factor authentication for this account is managed by your single sign-on provider.';
|
|
61
|
+
var EnableTwoFactorAuthContainer = (0, _EnableTwoFactorAuthContainerFactory["default"])(_EnableTwoFactorAuthComponent["default"]);
|
|
62
|
+
var render = function render(userInfo) {
|
|
63
|
+
var actions = [];
|
|
64
|
+
var record = function record() {
|
|
65
|
+
return function (next) {
|
|
66
|
+
return function (action) {
|
|
67
|
+
actions.push(action);
|
|
68
|
+
return next(action);
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
var store = (0, _redux.createStore)((0, _redux.combineReducers)({
|
|
73
|
+
form: _reduxForm.reducer,
|
|
74
|
+
user: function user() {
|
|
75
|
+
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
|
|
76
|
+
userInfo: userInfo,
|
|
77
|
+
userConfig: []
|
|
78
|
+
};
|
|
79
|
+
return state;
|
|
80
|
+
},
|
|
81
|
+
snackbar: function snackbar() {
|
|
82
|
+
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
|
|
83
|
+
snacks: []
|
|
84
|
+
};
|
|
85
|
+
return state;
|
|
86
|
+
}
|
|
87
|
+
}), (0, _redux.applyMiddleware)(_reduxThunk["default"], record));
|
|
88
|
+
var container = document.createElement('div');
|
|
89
|
+
document.body.appendChild(container);
|
|
90
|
+
var root = (0, _client.createRoot)(container);
|
|
91
|
+
(0, _react.act)(function () {
|
|
92
|
+
return root.render(/*#__PURE__*/_react["default"].createElement(_reactRedux.Provider, {
|
|
93
|
+
store: store
|
|
94
|
+
}, /*#__PURE__*/_react["default"].createElement(EnableTwoFactorAuthContainer, null)));
|
|
95
|
+
});
|
|
96
|
+
return {
|
|
97
|
+
actions: actions,
|
|
98
|
+
switchControl: function switchControl() {
|
|
99
|
+
return container.querySelector('.ap-switch__switch');
|
|
100
|
+
},
|
|
101
|
+
text: function text() {
|
|
102
|
+
return container.textContent;
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
describe('Profile & Security two-factor card', function () {
|
|
107
|
+
beforeEach(function () {
|
|
108
|
+
jest.clearAllMocks();
|
|
109
|
+
});
|
|
110
|
+
afterEach(function () {
|
|
111
|
+
document.body.innerHTML = '';
|
|
112
|
+
});
|
|
113
|
+
it('offers the 2FA switch to a password user', function () {
|
|
114
|
+
var card = render({
|
|
115
|
+
Use2FA: false,
|
|
116
|
+
IsOAuthUser: false
|
|
117
|
+
});
|
|
118
|
+
expect(card.switchControl()).not.toBeNull();
|
|
119
|
+
expect(card.text()).not.toContain(SSO_MESSAGE);
|
|
120
|
+
});
|
|
121
|
+
it('replaces the switch with the SSO message for an SSO user', function () {
|
|
122
|
+
var card = render({
|
|
123
|
+
Use2FA: false,
|
|
124
|
+
IsOAuthUser: true
|
|
125
|
+
});
|
|
126
|
+
expect(card.switchControl()).toBeNull();
|
|
127
|
+
expect(card.text()).toContain(SSO_MESSAGE);
|
|
128
|
+
});
|
|
129
|
+
it('keeps the switch for an SSO user who already has local 2FA, so it can be turned off', function () {
|
|
130
|
+
var card = render({
|
|
131
|
+
Use2FA: true,
|
|
132
|
+
IsOAuthUser: true
|
|
133
|
+
});
|
|
134
|
+
expect(card.switchControl()).not.toBeNull();
|
|
135
|
+
expect(card.text()).not.toContain(SSO_MESSAGE);
|
|
136
|
+
});
|
|
137
|
+
it('opens the enrol modal when the gateway returns a QR code', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
|
|
138
|
+
var card;
|
|
139
|
+
return _regenerator().w(function (_context2) {
|
|
140
|
+
while (1) switch (_context2.n) {
|
|
141
|
+
case 0:
|
|
142
|
+
_apex["default"].connection.EnableGoogle2FA.mockResolvedValueOnce({
|
|
143
|
+
GoogleQRCode: 'otpauth://totp/x',
|
|
144
|
+
ManualCode: 'ABC'
|
|
145
|
+
});
|
|
146
|
+
card = render({
|
|
147
|
+
Use2FA: false,
|
|
148
|
+
IsOAuthUser: false
|
|
149
|
+
});
|
|
150
|
+
_context2.n = 1;
|
|
151
|
+
return (0, _react.act)(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
152
|
+
return _regenerator().w(function (_context) {
|
|
153
|
+
while (1) switch (_context.n) {
|
|
154
|
+
case 0:
|
|
155
|
+
return _context.a(2, card.switchControl().click());
|
|
156
|
+
}
|
|
157
|
+
}, _callee);
|
|
158
|
+
})));
|
|
159
|
+
case 1:
|
|
160
|
+
expect(card.actions).toContainEqual({
|
|
161
|
+
type: _modalActions.OPEN_MODAL,
|
|
162
|
+
payload: {
|
|
163
|
+
name: _modalActions.MODAL_TYPES.ENABLE_2FA
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
case 2:
|
|
167
|
+
return _context2.a(2);
|
|
168
|
+
}
|
|
169
|
+
}, _callee2);
|
|
170
|
+
})));
|
|
171
|
+
it('shows the refusal and does not open the enrol modal when the gateway refuses', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4() {
|
|
172
|
+
var card;
|
|
173
|
+
return _regenerator().w(function (_context4) {
|
|
174
|
+
while (1) switch (_context4.n) {
|
|
175
|
+
case 0:
|
|
176
|
+
_apex["default"].connection.EnableGoogle2FA.mockResolvedValueOnce({
|
|
177
|
+
result: false,
|
|
178
|
+
errormsg: SSO_MESSAGE,
|
|
179
|
+
errorcode: 104
|
|
180
|
+
});
|
|
181
|
+
card = render({
|
|
182
|
+
Use2FA: false,
|
|
183
|
+
IsOAuthUser: false
|
|
184
|
+
});
|
|
185
|
+
_context4.n = 1;
|
|
186
|
+
return (0, _react.act)(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3() {
|
|
187
|
+
return _regenerator().w(function (_context3) {
|
|
188
|
+
while (1) switch (_context3.n) {
|
|
189
|
+
case 0:
|
|
190
|
+
return _context3.a(2, card.switchControl().click());
|
|
191
|
+
}
|
|
192
|
+
}, _callee3);
|
|
193
|
+
})));
|
|
194
|
+
case 1:
|
|
195
|
+
expect(card.actions).toContainEqual(expect.objectContaining({
|
|
196
|
+
type: _snackbarActions.ADD_SNACK,
|
|
197
|
+
payload: expect.objectContaining({
|
|
198
|
+
text: "104: ".concat(SSO_MESSAGE)
|
|
199
|
+
})
|
|
200
|
+
}));
|
|
201
|
+
expect(card.actions).not.toContainEqual(expect.objectContaining({
|
|
202
|
+
type: _modalActions.OPEN_MODAL
|
|
203
|
+
}));
|
|
204
|
+
expect(card.switchControl().textContent).toBe('Off');
|
|
205
|
+
case 2:
|
|
206
|
+
return _context4.a(2);
|
|
207
|
+
}
|
|
208
|
+
}, _callee4);
|
|
209
|
+
})));
|
|
210
|
+
it('still shows a warning when the refusal has no message', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6() {
|
|
211
|
+
var card;
|
|
212
|
+
return _regenerator().w(function (_context6) {
|
|
213
|
+
while (1) switch (_context6.n) {
|
|
214
|
+
case 0:
|
|
215
|
+
_apex["default"].connection.EnableGoogle2FA.mockResolvedValueOnce({
|
|
216
|
+
result: false,
|
|
217
|
+
errormsg: '',
|
|
218
|
+
errorcode: 104
|
|
219
|
+
});
|
|
220
|
+
card = render({
|
|
221
|
+
Use2FA: false,
|
|
222
|
+
IsOAuthUser: false
|
|
223
|
+
});
|
|
224
|
+
_context6.n = 1;
|
|
225
|
+
return (0, _react.act)(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5() {
|
|
226
|
+
return _regenerator().w(function (_context5) {
|
|
227
|
+
while (1) switch (_context5.n) {
|
|
228
|
+
case 0:
|
|
229
|
+
return _context5.a(2, card.switchControl().click());
|
|
230
|
+
}
|
|
231
|
+
}, _callee5);
|
|
232
|
+
})));
|
|
233
|
+
case 1:
|
|
234
|
+
expect(card.actions).toContainEqual(expect.objectContaining({
|
|
235
|
+
type: _snackbarActions.ADD_SNACK,
|
|
236
|
+
payload: expect.objectContaining({
|
|
237
|
+
text: 'Two-factor authentication could not be enabled.'
|
|
238
|
+
})
|
|
239
|
+
}));
|
|
240
|
+
expect(card.switchControl().textContent).toBe('Off');
|
|
241
|
+
case 2:
|
|
242
|
+
return _context6.a(2);
|
|
243
|
+
}
|
|
244
|
+
}, _callee6);
|
|
245
|
+
})));
|
|
246
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
.error-boundary {
|
|
2
|
+
display: flex;
|
|
3
|
+
align-items: center;
|
|
4
|
+
justify-content: center;
|
|
5
|
+
min-height: 100vh;
|
|
6
|
+
padding: 24px;
|
|
7
|
+
background-color: var(--component__bg-color);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.error-boundary__container {
|
|
11
|
+
max-width: 48rem;
|
|
12
|
+
text-align: center;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.error-boundary__title {
|
|
16
|
+
margin-bottom: 1.6rem;
|
|
17
|
+
font-size: 2.4rem;
|
|
18
|
+
font-weight: 600;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.error-boundary__message {
|
|
22
|
+
margin-bottom: 2.4rem;
|
|
23
|
+
font-size: 1.6rem;
|
|
24
|
+
line-height: 1.5;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.error-boundary__button {
|
|
28
|
+
padding: 1rem 2.4rem;
|
|
29
|
+
font-size: 1.6rem;
|
|
30
|
+
border: none;
|
|
31
|
+
border-radius: 5px;
|
|
32
|
+
cursor: pointer;
|
|
33
|
+
background-color: var(--primary__bg-color);
|
|
34
|
+
color: var(--font__color-primary);
|
|
35
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
+
var _cssClassesHelper = require("../../../helpers/cssClassesHelper");
|
|
10
|
+
require("./ErrorBoundary.css");
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
12
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
13
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
14
|
+
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
15
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
16
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
17
|
+
function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
|
|
18
|
+
function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
|
|
19
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
20
|
+
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
|
|
21
|
+
function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
|
|
22
|
+
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
|
|
23
|
+
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; }
|
|
24
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
25
|
+
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); }
|
|
26
|
+
var baseClass = (0, _cssClassesHelper.getBEMClasses)('error-boundary');
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Catches render-phase errors so a throw cannot unmount the whole tree into a
|
|
30
|
+
* blank page. Deliberately avoids i18n and redux so it stays useful even when
|
|
31
|
+
* those are the source of the failure.
|
|
32
|
+
*/
|
|
33
|
+
var ErrorBoundary = /*#__PURE__*/function (_React$Component) {
|
|
34
|
+
function ErrorBoundary() {
|
|
35
|
+
var _this;
|
|
36
|
+
_classCallCheck(this, ErrorBoundary);
|
|
37
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
38
|
+
args[_key] = arguments[_key];
|
|
39
|
+
}
|
|
40
|
+
_this = _callSuper(this, ErrorBoundary, [].concat(args));
|
|
41
|
+
_defineProperty(_this, "state", {
|
|
42
|
+
hasError: false
|
|
43
|
+
});
|
|
44
|
+
_defineProperty(_this, "handleReload", function () {
|
|
45
|
+
window.location.reload();
|
|
46
|
+
});
|
|
47
|
+
return _this;
|
|
48
|
+
}
|
|
49
|
+
_inherits(ErrorBoundary, _React$Component);
|
|
50
|
+
return _createClass(ErrorBoundary, [{
|
|
51
|
+
key: "componentDidCatch",
|
|
52
|
+
value: function componentDidCatch(error, errorInfo) {
|
|
53
|
+
console.error('Unhandled render error', error, errorInfo);
|
|
54
|
+
}
|
|
55
|
+
}, {
|
|
56
|
+
key: "render",
|
|
57
|
+
value: function render() {
|
|
58
|
+
if (!this.state.hasError) {
|
|
59
|
+
return this.props.children;
|
|
60
|
+
}
|
|
61
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
62
|
+
className: baseClass()
|
|
63
|
+
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
64
|
+
className: baseClass('container')
|
|
65
|
+
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
66
|
+
className: baseClass('title')
|
|
67
|
+
}, "Something went wrong"), /*#__PURE__*/_react["default"].createElement("div", {
|
|
68
|
+
className: baseClass('message')
|
|
69
|
+
}, "The page could not be displayed. Reloading may resolve it. If it persists, please contact support."), /*#__PURE__*/_react["default"].createElement("button", {
|
|
70
|
+
className: baseClass('button'),
|
|
71
|
+
onClick: this.handleReload,
|
|
72
|
+
type: "button"
|
|
73
|
+
}, "Reload")));
|
|
74
|
+
}
|
|
75
|
+
}], [{
|
|
76
|
+
key: "getDerivedStateFromError",
|
|
77
|
+
value: function getDerivedStateFromError() {
|
|
78
|
+
return {
|
|
79
|
+
hasError: true
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
}]);
|
|
83
|
+
}(_react["default"].Component);
|
|
84
|
+
ErrorBoundary.propTypes = {
|
|
85
|
+
children: _propTypes["default"].node
|
|
86
|
+
};
|
|
87
|
+
var _default = exports["default"] = ErrorBoundary;
|
|
@@ -5,11 +5,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.preprocessErrorTextForReduxForm = exports.formatErrorText = void 0;
|
|
7
7
|
var formatErrorText = exports.formatErrorText = function formatErrorText(errorResponse) {
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
var _ref = errorResponse || {},
|
|
9
|
+
errorcode = _ref.errorcode,
|
|
10
|
+
errormsg = _ref.errormsg,
|
|
11
|
+
detail = _ref.detail;
|
|
12
|
+
var parts = [errorcode !== undefined && errorcode !== null ? String(errorcode) : '', typeof errormsg === 'string' ? errormsg.trim() : '', typeof detail === 'string' ? detail.trim() : ''].filter(Boolean);
|
|
13
|
+
|
|
14
|
+
// A reply with no code, message or detail (a 2FA gate refusal, a null reply) is still an error
|
|
15
|
+
// from the caller's point of view. The generic text is returned on its own so the snackbar can
|
|
16
|
+
// translate it as a whole key.
|
|
17
|
+
if (parts.length === 0) {
|
|
18
|
+
// t('The request was not successful.')
|
|
19
|
+
return 'The request was not successful.';
|
|
11
20
|
}
|
|
12
|
-
return
|
|
21
|
+
return parts.join(': ');
|
|
13
22
|
};
|
|
14
23
|
|
|
15
24
|
/**
|
|
@@ -11,4 +11,30 @@ describe('formatErrorText', function () {
|
|
|
11
11
|
errorResponse.detail = 'Error details';
|
|
12
12
|
expect((0, _errorTextFormatter.formatErrorText)(errorResponse)).toEqual('402: Test error: Error details');
|
|
13
13
|
});
|
|
14
|
+
it('omits the code when the response has none', function () {
|
|
15
|
+
expect((0, _errorTextFormatter.formatErrorText)({
|
|
16
|
+
errormsg: 'not enabled'
|
|
17
|
+
})).toEqual('not enabled');
|
|
18
|
+
});
|
|
19
|
+
it('falls back to a generic message for an empty response', function () {
|
|
20
|
+
expect((0, _errorTextFormatter.formatErrorText)({})).toEqual('The request was not successful.');
|
|
21
|
+
expect((0, _errorTextFormatter.formatErrorText)(null)).toEqual('The request was not successful.');
|
|
22
|
+
});
|
|
23
|
+
it('keeps the code and detail when the message is empty', function () {
|
|
24
|
+
expect((0, _errorTextFormatter.formatErrorText)({
|
|
25
|
+
result: false,
|
|
26
|
+
errorcode: 101,
|
|
27
|
+
errormsg: '',
|
|
28
|
+
detail: 'Insufficient balance'
|
|
29
|
+
})).toEqual('101: Insufficient balance');
|
|
30
|
+
});
|
|
31
|
+
it('treats whitespace-only fields as empty', function () {
|
|
32
|
+
expect((0, _errorTextFormatter.formatErrorText)({
|
|
33
|
+
errormsg: ' \t\n '
|
|
34
|
+
})).toEqual('The request was not successful.');
|
|
35
|
+
expect((0, _errorTextFormatter.formatErrorText)({
|
|
36
|
+
errormsg: ' not enabled ',
|
|
37
|
+
detail: ' '
|
|
38
|
+
})).toEqual('not enabled');
|
|
39
|
+
});
|
|
14
40
|
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.isTwoFactorAuthCancellation = exports.TwoFactorAuthCancelledError = void 0;
|
|
8
|
+
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
9
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
10
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
11
|
+
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); }
|
|
12
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
13
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
14
|
+
function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
|
|
15
|
+
function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
|
|
16
|
+
function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
|
|
17
|
+
function _wrapNativeSuper(t) { var r = "function" == typeof Map ? new Map() : void 0; return _wrapNativeSuper = function _wrapNativeSuper(t) { if (null === t || !_isNativeFunction(t)) return t; if ("function" != typeof t) throw new TypeError("Super expression must either be null or a function"); if (void 0 !== r) { if (r.has(t)) return r.get(t); r.set(t, Wrapper); } function Wrapper() { return _construct(t, arguments, _getPrototypeOf(this).constructor); } return Wrapper.prototype = Object.create(t.prototype, { constructor: { value: Wrapper, enumerable: !1, writable: !0, configurable: !0 } }), _setPrototypeOf(Wrapper, t); }, _wrapNativeSuper(t); }
|
|
18
|
+
function _construct(t, e, r) { if (_isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments); var o = [null]; o.push.apply(o, e); var p = new (t.bind.apply(t, o))(); return r && _setPrototypeOf(p, r.prototype), p; }
|
|
19
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
20
|
+
function _isNativeFunction(t) { try { return -1 !== Function.toString.call(t).indexOf("[native code]"); } catch (n) { return "function" == typeof t; } }
|
|
21
|
+
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
|
|
22
|
+
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
|
|
23
|
+
// Thrown into a pending callAPI promise when the user dismisses the 2FA modal without a
|
|
24
|
+
// successful code, so the caller settles instead of waiting forever.
|
|
25
|
+
var TwoFactorAuthCancelledError = exports.TwoFactorAuthCancelledError = /*#__PURE__*/function (_Error) {
|
|
26
|
+
function TwoFactorAuthCancelledError() {
|
|
27
|
+
var _this;
|
|
28
|
+
_classCallCheck(this, TwoFactorAuthCancelledError);
|
|
29
|
+
_this = _callSuper(this, TwoFactorAuthCancelledError, ['Two-factor authentication was cancelled']);
|
|
30
|
+
_this.name = 'TwoFactorAuthCancelledError';
|
|
31
|
+
return _this;
|
|
32
|
+
}
|
|
33
|
+
_inherits(TwoFactorAuthCancelledError, _Error);
|
|
34
|
+
return _createClass(TwoFactorAuthCancelledError);
|
|
35
|
+
}(/*#__PURE__*/_wrapNativeSuper(Error));
|
|
36
|
+
var isTwoFactorAuthCancellation = exports.isTwoFactorAuthCancellation = function isTwoFactorAuthCancellation(error) {
|
|
37
|
+
return !!error && error.name === 'TwoFactorAuthCancelledError';
|
|
38
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _reactRedux = require("react-redux");
|
|
9
|
+
var _NoAccountPlaceholder = _interopRequireDefault(require("../components/NoAccountPlaceholder"));
|
|
10
|
+
var _userSelectors = require("../redux/selectors/userSelectors");
|
|
11
|
+
var _excluded = ["hasNoAccounts"];
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
13
|
+
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
14
|
+
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
15
|
+
/**
|
|
16
|
+
* Shows a placeholder instead of the wrapped component to a user with no
|
|
17
|
+
* trading account. Use it for areas that only work with an account, so they
|
|
18
|
+
* neither spin forever nor send account calls without an AccountId.
|
|
19
|
+
*/
|
|
20
|
+
function forAccount(WrappedComponent) {
|
|
21
|
+
var ModifiedComponent = function ModifiedComponent(_ref) {
|
|
22
|
+
var hasNoAccounts = _ref.hasNoAccounts,
|
|
23
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
24
|
+
return hasNoAccounts ? /*#__PURE__*/_react["default"].createElement(_NoAccountPlaceholder["default"], null) : /*#__PURE__*/_react["default"].createElement(WrappedComponent, props);
|
|
25
|
+
};
|
|
26
|
+
var mapStateToProps = function mapStateToProps(state) {
|
|
27
|
+
return {
|
|
28
|
+
hasNoAccounts: (0, _userSelectors.hasNoAccountsSelector)(state)
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
return (0, _reactRedux.connect)(mapStateToProps)(ModifiedComponent);
|
|
32
|
+
}
|
|
33
|
+
var _default = exports["default"] = forAccount;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _react = _interopRequireDefault(require("react"));
|
|
4
|
+
var _server = require("react-dom/server");
|
|
5
|
+
var _reactRedux = require("react-redux");
|
|
6
|
+
var _reduxMockStore = _interopRequireDefault(require("redux-mock-store"));
|
|
7
|
+
var _forAccount = _interopRequireDefault(require("./forAccount"));
|
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
9
|
+
jest.mock('../components/NoAccountPlaceholder', function () {
|
|
10
|
+
return function () {
|
|
11
|
+
return /*#__PURE__*/_react["default"].createElement("div", null, "placeholder");
|
|
12
|
+
};
|
|
13
|
+
});
|
|
14
|
+
var Page = function Page(_ref) {
|
|
15
|
+
var label = _ref.label;
|
|
16
|
+
return /*#__PURE__*/_react["default"].createElement("div", null, "page ".concat(label));
|
|
17
|
+
};
|
|
18
|
+
var AccountPage = (0, _forAccount["default"])(Page);
|
|
19
|
+
var mockStore = (0, _reduxMockStore["default"])();
|
|
20
|
+
var render = function render(user) {
|
|
21
|
+
return (0, _server.renderToStaticMarkup)(/*#__PURE__*/_react["default"].createElement(_reactRedux.Provider, {
|
|
22
|
+
store: mockStore({
|
|
23
|
+
user: user
|
|
24
|
+
})
|
|
25
|
+
}, /*#__PURE__*/_react["default"].createElement(AccountPage, {
|
|
26
|
+
label: "wallets"
|
|
27
|
+
})));
|
|
28
|
+
};
|
|
29
|
+
describe('forAccount', function () {
|
|
30
|
+
it('shows the placeholder once the accounts have loaded with none', function () {
|
|
31
|
+
expect(render({
|
|
32
|
+
accountsLoaded: true,
|
|
33
|
+
accounts: []
|
|
34
|
+
})).toBe('<div>placeholder</div>');
|
|
35
|
+
});
|
|
36
|
+
it('renders the wrapped component with its props for a user with an account', function () {
|
|
37
|
+
expect(render({
|
|
38
|
+
accountsLoaded: true,
|
|
39
|
+
accounts: [{
|
|
40
|
+
AccountId: 15
|
|
41
|
+
}]
|
|
42
|
+
})).toBe('<div>page wallets</div>');
|
|
43
|
+
});
|
|
44
|
+
it('renders the wrapped component while the accounts are still loading', function () {
|
|
45
|
+
expect(render({
|
|
46
|
+
accountsLoaded: false,
|
|
47
|
+
accounts: []
|
|
48
|
+
})).toBe('<div>page wallets</div>');
|
|
49
|
+
});
|
|
50
|
+
});
|
package/lib/hocs/forVerified.js
CHANGED
|
@@ -10,13 +10,24 @@ var _reactRouterDom = require("react-router-dom");
|
|
|
10
10
|
var _config = _interopRequireDefault(require("../config"));
|
|
11
11
|
var _FullPageSpinner = _interopRequireDefault(require("../components/common/FullPageSpinner/FullPageSpinner"));
|
|
12
12
|
var _path = _interopRequireDefault(require("../helpers/path"));
|
|
13
|
+
var _userSelectors = require("../redux/selectors/userSelectors");
|
|
13
14
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
14
15
|
function forVerified(WrappedComponent) {
|
|
15
16
|
var ModifiedComponent = function ModifiedComponent(props) {
|
|
16
17
|
var pending = props.pending,
|
|
18
|
+
hasNoAccounts = props.hasNoAccounts,
|
|
17
19
|
verificationLevel = props.verificationLevel;
|
|
18
20
|
if (pending) {
|
|
19
|
-
return /*#__PURE__*/_react["default"].createElement(_FullPageSpinner["default"],
|
|
21
|
+
return /*#__PURE__*/_react["default"].createElement(_FullPageSpinner["default"], {
|
|
22
|
+
pastDelay: true
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// A user with no accounts cannot satisfy a verification level, so the KYC
|
|
27
|
+
// gate below would trap them. Let them into the site instead and let the
|
|
28
|
+
// account-scoped areas render empty.
|
|
29
|
+
if (hasNoAccounts) {
|
|
30
|
+
return /*#__PURE__*/_react["default"].createElement(WrappedComponent, props);
|
|
20
31
|
}
|
|
21
32
|
if (verificationLevel <= _config["default"].KYC.MinimumVerificationLevel && _config["default"].KYC.UpfrontKYC) {
|
|
22
33
|
return /*#__PURE__*/_react["default"].createElement(_reactRouterDom.Redirect, {
|
|
@@ -28,7 +39,10 @@ function forVerified(WrappedComponent) {
|
|
|
28
39
|
var mapStateToProps = function mapStateToProps(state) {
|
|
29
40
|
return {
|
|
30
41
|
verificationLevel: state.user.accounts.length ? state.user.accounts[0].VerificationLevel : 0,
|
|
31
|
-
|
|
42
|
+
// Gate on whether the fetch has settled, not on whether it produced
|
|
43
|
+
// accounts, so a user with none is not held here indefinitely.
|
|
44
|
+
pending: !state.user.accountsLoaded,
|
|
45
|
+
hasNoAccounts: (0, _userSelectors.hasNoAccountsSelector)(state)
|
|
32
46
|
};
|
|
33
47
|
};
|
|
34
48
|
return (0, _reactRedux.connect)(mapStateToProps)(ModifiedComponent);
|
|
@@ -19,7 +19,9 @@ function withAuthentication(WrappedComponent) {
|
|
|
19
19
|
pendingAuth = props.pendingAuth,
|
|
20
20
|
redirectFromLogin = props.redirectFromLogin;
|
|
21
21
|
if (pendingAuth || !isAuthenticated && isAuthenticating) {
|
|
22
|
-
return /*#__PURE__*/_react["default"].createElement(_FullPageSpinner["default"],
|
|
22
|
+
return /*#__PURE__*/_react["default"].createElement(_FullPageSpinner["default"], {
|
|
23
|
+
pastDelay: true
|
|
24
|
+
});
|
|
23
25
|
}
|
|
24
26
|
if (!isAuthenticated) {
|
|
25
27
|
redirectFromLogin(location);
|
package/lib/index.js
CHANGED
|
@@ -13,6 +13,7 @@ var _routeTemplates = require("./routeTemplates");
|
|
|
13
13
|
var _indexHelper = require("./helpers/indexHelper");
|
|
14
14
|
var numberFormatter = _interopRequireWildcard(require("./helpers/numberFormatter"));
|
|
15
15
|
var _apexWebActions = _interopRequireDefault(require("./helpers/apexWebActions"));
|
|
16
|
+
var _ErrorBoundary = _interopRequireDefault(require("./components/common/ErrorBoundary/ErrorBoundary"));
|
|
16
17
|
var _registerServiceWorker = require("./registerServiceWorker");
|
|
17
18
|
var _config = _interopRequireDefault(require("./config"));
|
|
18
19
|
var _cssVarsPonyfill = _interopRequireDefault(require("css-vars-ponyfill"));
|
|
@@ -40,7 +41,7 @@ window.cssVariables = {};
|
|
|
40
41
|
});
|
|
41
42
|
var container = document.getElementById('root');
|
|
42
43
|
var root = (0, _client.createRoot)(container);
|
|
43
|
-
root.render(/*#__PURE__*/_react["default"].createElement(_reactRedux.Provider, {
|
|
44
|
+
root.render(/*#__PURE__*/_react["default"].createElement(_ErrorBoundary["default"], null, /*#__PURE__*/_react["default"].createElement(_reactRedux.Provider, {
|
|
44
45
|
store: _store["default"]
|
|
45
46
|
}, /*#__PURE__*/_react["default"].createElement(_reduxI18n["default"], {
|
|
46
47
|
translations: window.APEXTranslations || {
|
|
@@ -48,5 +49,5 @@ root.render(/*#__PURE__*/_react["default"].createElement(_reactRedux.Provider, {
|
|
|
48
49
|
}
|
|
49
50
|
}, /*#__PURE__*/_react["default"].createElement(_reactRouterDom.Router, {
|
|
50
51
|
history: _history["default"]
|
|
51
|
-
}, /*#__PURE__*/_react["default"].createElement(_App["default"], null)))));
|
|
52
|
+
}, /*#__PURE__*/_react["default"].createElement(_App["default"], null))))));
|
|
52
53
|
(0, _registerServiceWorker.unregister)();
|
|
@@ -8,8 +8,9 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
8
8
|
var _withAuthentication = _interopRequireDefault(require("../../hocs/withAuthentication"));
|
|
9
9
|
var _forVerified = _interopRequireDefault(require("../../hocs/forVerified"));
|
|
10
10
|
var _PageHeaderComponent = _interopRequireDefault(require("../../components/PageHeader/PageHeaderComponent"));
|
|
11
|
+
var _NoAccountBanner = require("../../components/NoAccountBanner");
|
|
11
12
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
12
13
|
var HeaderLayout = function HeaderLayout(props) {
|
|
13
|
-
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_PageHeaderComponent["default"], null), props.children);
|
|
14
|
+
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_PageHeaderComponent["default"], null), /*#__PURE__*/_react["default"].createElement(_NoAccountBanner.NoAccountBanner, null), props.children);
|
|
14
15
|
};
|
|
15
16
|
var _default = exports["default"] = (0, _withAuthentication["default"])((0, _forVerified["default"])(HeaderLayout));
|