@basiq/connect-auth 1.0.7 → 1.0.8

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.
@@ -1071,6 +1071,9 @@ function AuthScreen(_ref) {
1071
1071
  var _useState5 = React.useState(false),
1072
1072
  loading = _useState5[0],
1073
1073
  setLoading = _useState5[1];
1074
+ var _useState6 = React.useState(false),
1075
+ tooManyAttemps = _useState6[0],
1076
+ setTooManyAttemps = _useState6[1];
1074
1077
  var handleCodeApply = React.useCallback( /*#__PURE__*/function () {
1075
1078
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(e) {
1076
1079
  var _response$data, response, _response$data2;
@@ -1078,7 +1081,7 @@ function AuthScreen(_ref) {
1078
1081
  while (1) switch (_context.prev = _context.next) {
1079
1082
  case 0:
1080
1083
  if (!(smsCode.length === 4 && error.length === 0 && (!e || (e == null ? void 0 : e.key) === 'Enter'))) {
1081
- _context.next = 7;
1084
+ _context.next = 6;
1082
1085
  break;
1083
1086
  }
1084
1087
  setLoading(true);
@@ -1092,12 +1095,15 @@ function AuthScreen(_ref) {
1092
1095
  response = _context.sent;
1093
1096
  if (response != null && (_response$data = response.data) != null && _response$data.access_token) {
1094
1097
  window.open("https://consent.basiq.io/home?token=" + (response == null || (_response$data2 = response.data) == null ? void 0 : _response$data2.access_token) + "&action=" + (action.length > 0 ? action : 'connect'), "_self");
1095
- }
1096
- if (response != null && response.error) {
1098
+ } else if ((response == null ? void 0 : response.statusCode) === 204) {
1099
+ setLoading(false);
1100
+ setTooManyAttemps(true);
1101
+ setError(t('too_many_attempts'));
1102
+ } else if (response != null && response.error) {
1097
1103
  setLoading(false);
1098
1104
  setError(t('this_code_doesnt_appear_to_be_valid'));
1099
1105
  }
1100
- case 7:
1106
+ case 6:
1101
1107
  case "end":
1102
1108
  return _context.stop();
1103
1109
  }
@@ -1171,14 +1177,15 @@ function AuthScreen(_ref) {
1171
1177
  onChange: handleInput,
1172
1178
  value: smsCode,
1173
1179
  filled: smsCode.length === 4,
1174
- error: !!error,
1180
+ error: tooManyAttemps || !!error,
1181
+ disabled: tooManyAttemps,
1175
1182
  onKeyPress: function onKeyPress(e) {
1176
1183
  return handleCodeApply(e);
1177
1184
  }
1178
1185
  })), React__default.createElement(PageConnectFooterControl, null, resend && React__default.createElement(StatusMessage, null, t('new_sms_code_has_been_sent')), !!error && React__default.createElement(StatusMessage, {
1179
1186
  error: true
1180
1187
  }, error), React__default.createElement(PageConnectFooterText, null, React__default.createElement("span", null, React__default.createElement(React__default.Fragment, null, t('didnt_receive_the_code'), " ", React__default.createElement(DivAsLink, {
1181
- disabled: resendLoading,
1188
+ disabled: tooManyAttemps || resendLoading,
1182
1189
  onClick: function onClick() {
1183
1190
  return !resendLoading && handleResend();
1184
1191
  }
@@ -1361,6 +1368,7 @@ var resend_sms = "Resend SMS";
1361
1368
  var failed_to_send_sms = "Failed to send SMS.";
1362
1369
  var page_not_found = "Page not found";
1363
1370
  var missing_authentication_token = "Missing Authentication Token";
1371
+ var too_many_attempts = "Too many attempts. Please use a new link to try again.";
1364
1372
  var translationEN = {
1365
1373
  back: back,
1366
1374
  error: error,
@@ -1388,7 +1396,8 @@ var translationEN = {
1388
1396
  resend_sms: resend_sms,
1389
1397
  failed_to_send_sms: failed_to_send_sms,
1390
1398
  page_not_found: page_not_found,
1391
- missing_authentication_token: missing_authentication_token
1399
+ missing_authentication_token: missing_authentication_token,
1400
+ too_many_attempts: too_many_attempts
1392
1401
  };
1393
1402
 
1394
1403
  // the translations