@basiq/connect-auth 1.0.7 → 1.0.9

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.
@@ -662,7 +662,8 @@ function Page(props) {
662
662
  title = props.title,
663
663
  subTitle = props.subTitle,
664
664
  shadow = props.shadow,
665
- onBack = props.onBack;
665
+ onBack = props.onBack,
666
+ backDisabled = props.backDisabled;
666
667
  var _useTranslation = useTranslation(),
667
668
  t = _useTranslation.t;
668
669
  return React.createElement(PageStyled, {
@@ -670,7 +671,8 @@ function Page(props) {
670
671
  }, onBack && React.createElement(Button, {
671
672
  onClick: onBack,
672
673
  label: t('back'),
673
- buttonType: "back"
674
+ buttonType: "back",
675
+ disabled: backDisabled
674
676
  }), title && React.createElement("h3", null, title), subTitle && React.createElement(PageSubtitle, null, subTitle), React.createElement(PageMainContainer, null, children), React.createElement(PageControlsSection, {
675
677
  notEmpty: ((_buttons$length = buttons == null ? void 0 : buttons.length) != null ? _buttons$length : 0) > 0
676
678
  }, React.createElement(PageShadowWrapper, null, shadow && React.createElement(PageShadow, null), buttons == null ? void 0 : buttons.map(function (b, index) {
@@ -1063,6 +1065,9 @@ function AuthScreen(_ref) {
1063
1065
  var _useState5 = useState(false),
1064
1066
  loading = _useState5[0],
1065
1067
  setLoading = _useState5[1];
1068
+ var _useState6 = useState(false),
1069
+ tooManyAttemps = _useState6[0],
1070
+ setTooManyAttemps = _useState6[1];
1066
1071
  var handleCodeApply = useCallback( /*#__PURE__*/function () {
1067
1072
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(e) {
1068
1073
  var _response$data, response, _response$data2;
@@ -1070,7 +1075,7 @@ function AuthScreen(_ref) {
1070
1075
  while (1) switch (_context.prev = _context.next) {
1071
1076
  case 0:
1072
1077
  if (!(smsCode.length === 4 && error.length === 0 && (!e || (e == null ? void 0 : e.key) === 'Enter'))) {
1073
- _context.next = 7;
1078
+ _context.next = 6;
1074
1079
  break;
1075
1080
  }
1076
1081
  setLoading(true);
@@ -1084,12 +1089,15 @@ function AuthScreen(_ref) {
1084
1089
  response = _context.sent;
1085
1090
  if (response != null && (_response$data = response.data) != null && _response$data.access_token) {
1086
1091
  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");
1087
- }
1088
- if (response != null && response.error) {
1092
+ } else if ((response == null ? void 0 : response.statusCode) === 204) {
1093
+ setLoading(false);
1094
+ setTooManyAttemps(true);
1095
+ setError(t('too_many_attempts'));
1096
+ } else if (response != null && response.error) {
1089
1097
  setLoading(false);
1090
1098
  setError(t('this_code_doesnt_appear_to_be_valid'));
1091
1099
  }
1092
- case 7:
1100
+ case 6:
1093
1101
  case "end":
1094
1102
  return _context.stop();
1095
1103
  }
@@ -1153,7 +1161,8 @@ function AuthScreen(_ref) {
1153
1161
  }),
1154
1162
  shadow: shadow,
1155
1163
  buttons: buttons,
1156
- onBack: onBack
1164
+ onBack: onBack,
1165
+ backDisabled: tooManyAttemps
1157
1166
  }, React.createElement(InnerContainer, null, React.createElement(InputContainer, null, React.createElement(InputStyled, {
1158
1167
  pattern: "\\d{4}",
1159
1168
  inputMode: "numeric",
@@ -1163,16 +1172,17 @@ function AuthScreen(_ref) {
1163
1172
  onChange: handleInput,
1164
1173
  value: smsCode,
1165
1174
  filled: smsCode.length === 4,
1166
- error: !!error,
1175
+ error: tooManyAttemps || !!error,
1176
+ disabled: tooManyAttemps,
1167
1177
  onKeyPress: function onKeyPress(e) {
1168
1178
  return handleCodeApply(e);
1169
1179
  }
1170
1180
  })), React.createElement(PageConnectFooterControl, null, resend && React.createElement(StatusMessage, null, t('new_sms_code_has_been_sent')), !!error && React.createElement(StatusMessage, {
1171
1181
  error: true
1172
1182
  }, error), React.createElement(PageConnectFooterText, null, React.createElement("span", null, React.createElement(React.Fragment, null, t('didnt_receive_the_code'), " ", React.createElement(DivAsLink, {
1173
- disabled: resendLoading,
1183
+ disabled: tooManyAttemps || resendLoading,
1174
1184
  onClick: function onClick() {
1175
- return !resendLoading && handleResend();
1185
+ return !tooManyAttemps && !resendLoading && handleResend();
1176
1186
  }
1177
1187
  }, t('resend_sms')))))), React.createElement(LoadingModal, {
1178
1188
  isOpen: loading
@@ -1353,6 +1363,7 @@ var resend_sms = "Resend SMS";
1353
1363
  var failed_to_send_sms = "Failed to send SMS.";
1354
1364
  var page_not_found = "Page not found";
1355
1365
  var missing_authentication_token = "Missing Authentication Token";
1366
+ var too_many_attempts = "Too many attempts. Please use a new link to try again.";
1356
1367
  var translationEN = {
1357
1368
  back: back,
1358
1369
  error: error,
@@ -1380,7 +1391,8 @@ var translationEN = {
1380
1391
  resend_sms: resend_sms,
1381
1392
  failed_to_send_sms: failed_to_send_sms,
1382
1393
  page_not_found: page_not_found,
1383
- missing_authentication_token: missing_authentication_token
1394
+ missing_authentication_token: missing_authentication_token,
1395
+ too_many_attempts: too_many_attempts
1384
1396
  };
1385
1397
 
1386
1398
  // the translations