@basiq/connect-auth 0.1.89 → 1.0.1

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.
@@ -1,4 +1,4 @@
1
- import React, { useState, createRef, useEffect } from 'react';
1
+ import React, { useState, useEffect, useCallback, createRef } from 'react';
2
2
  import styled, { css, keyframes, createGlobalStyle, ThemeProvider } from 'styled-components';
3
3
  import { useTranslation, Trans, initReactI18next } from 'react-i18next';
4
4
  import i18n from 'i18next';
@@ -466,6 +466,13 @@ var hexToRGBa = function hexToRGBa(hex, opacity) {
466
466
  var opp = opacity > 1 && opacity < 0 ? 1 : opacity;
467
467
  return "rgba(" + (hexToRGBA == null ? void 0 : hexToRGBA.concat(opp).join()) + ")";
468
468
  };
469
+ var handleUserKeyPress = function handleUserKeyPress(e, onEnter) {
470
+ var keyCode = e.keyCode;
471
+
472
+ if (keyCode === 13) {
473
+ onEnter();
474
+ }
475
+ };
469
476
 
470
477
  var DASHBOARD_API_URL_TEST = 'https://c9joivz12f.execute-api.ap-southeast-2.amazonaws.com/Development/';
471
478
  var DASHBOARD_API_URL = 'https://p4c8zn20r9.execute-api.ap-southeast-2.amazonaws.com/Production_v1/';
@@ -527,10 +534,10 @@ var theme = {
527
534
  },
528
535
  mixin: {
529
536
  subtitle: function subtitle() {
530
- return " margin-top: 8px;\n margin-bottom: 4px;\n width: 100%;\n display: flex;\n align-items: center;\n justify-content: space-between;";
537
+ return " margin-top: 32px;\n margin-bottom: 4px;\n width: 100%;\n display: flex;\n align-items: center;\n justify-content: space-between;";
531
538
  },
532
539
  title: function title() {
533
- return " font-size: 26px;\n line-height: 30px;\n letter-spacing: -0.2px;\n margin-top: 0;\n margin-bottom: 24px;\n color: #130f26;\n white-space: pre-line;\n ";
540
+ return " font-size: 26px;\n line-height: 30px;\n letter-spacing: -0.2px;\n margin-top: 0;\n margin-bottom: 0;\n color: #130f26;\n white-space: pre-line;\n ";
534
541
  }
535
542
  }
536
543
  };
@@ -594,18 +601,15 @@ var PageShadowWrapper = /*#__PURE__*/styled.div(_templateObject5$2 || (_template
594
601
  return horizontal && css(_templateObject6$1 || (_templateObject6$1 = _taggedTemplateLiteralLoose(["\n\t\t\tdisplay: flex;\n\t\t\talign-items: center;\n\t\t\tjustify-content: space-between;\n\n\t\t\t", " {\n\t\t\t\tmargin-bottom: 0;\n\t\t\t\tmargin-right: 16px;\n\n\t\t\t\t&:last-child {\n\t\t\t\t\tmargin-right: unset;\n\t\t\t\t}\n\t\t\t}\n\t\t"])), ButtonStyled);
595
602
  });
596
603
  var PageShadow = /*#__PURE__*/styled.div(_templateObject7$1 || (_templateObject7$1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n\tposition: absolute;\n\theight: 71px;\n\tleft: 0;\n\tright: 0;\n\ttop: -71px;\n\tbackground: linear-gradient(180deg, #cecece 0%, ", " 100%);\n\topacity: 0.8;\n\ttransform: rotate(-180deg);\n\tpointer-events: none;\n"])), /*#__PURE__*/hexToRGBa('#cecece', 0));
597
- var PageHeader = /*#__PURE__*/styled.header(_templateObject8 || (_templateObject8 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n\tmargin-bottom: 32px;\n\twidth: 100%;\n\tborder-radius: 8px;\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: center;\n\tbackground-color: ", ";\n\tpadding: 16px;\n\tbox-sizing: border-box;\n\theight: 150px;\n\t", " {\n\t\tbackground-color: unset;\n\t\toverflow: initial;\n\t\theight: 150px;\n\t\tpadding: 16px;\n\t}\n\timg {\n\t\tborder-radius: 4px;\n\t\twidth: auto !important;\n\t\theight: auto;\n\t\tmax-width: 100%;\n\t\tmax-height: 100%;\n\t\t", " {\n\t\t\twidth: 100%;\n\t\t\tpadding: 16px;\n\t\t}\n\t}\n"])), function (_ref7) {
598
- var theme = _ref7.theme;
599
- return theme.color.porcelainSecond;
600
- }, devices.phone, devices.phone);
604
+ var PageHeader = /*#__PURE__*/styled.header(_templateObject8 || (_templateObject8 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n\tmargin-bottom: 32px;\n\twidth: 100%;\n\tborder-radius: 8px;\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: center;\n\tbackground-color: unset;\n\tpadding: 16px 0;\n\tbox-sizing: border-box;\n\theight: 150px;\n\t", " {\n\t\toverflow: initial;\n\t\theight: 150px;\n\t\tmargin-bottom: 0;\n\t}\n\timg {\n\t\tborder-radius: 4px;\n\t\twidth: auto !important;\n\t\theight: auto;\n\t\tmax-width: 100%;\n\t\tmax-height: 100%;\n\t\t", " {\n\t\t\twidth: 100%;\n\t\t\tpadding: 16px;\n\t\t}\n\t}\n"])), devices.phone, devices.phone);
601
605
  var PageContent = /*#__PURE__*/styled.div(_templateObject9 || (_templateObject9 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n\twidth: 100%;\n"])));
602
- var StatusMessage = /*#__PURE__*/styled.div(_templateObject10 || (_templateObject10 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n\twidth: 100%;\n\tbackground: ", ";\n\tborder-radius: 4px;\n\tpadding: 11px;\n\tbox-sizing: border-box;\n\ttext-align: center;\n\tdisplay: flex;\n\tjustify-content: center;\n\talign-items: center;\n\tfont-weight: 400;\n\tfont-size: 14px;\n\tcolor: ", ";\n\tmargin-bottom: 16px;\n"])), function (_ref8) {
606
+ var StatusMessage = /*#__PURE__*/styled.div(_templateObject10 || (_templateObject10 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n\twidth: 100%;\n\tbackground: ", ";\n\tborder-radius: 4px;\n\tpadding: 11px;\n\tbox-sizing: border-box;\n\ttext-align: center;\n\tdisplay: flex;\n\tjustify-content: center;\n\talign-items: center;\n\tfont-weight: 400;\n\tfont-size: 14px;\n\tcolor: ", ";\n\tmargin-bottom: 16px;\n"])), function (_ref7) {
607
+ var theme = _ref7.theme,
608
+ error = _ref7.error;
609
+ return error ? theme.color.wePeep : theme.color.iceberg;
610
+ }, function (_ref8) {
603
611
  var theme = _ref8.theme,
604
612
  error = _ref8.error;
605
- return error ? theme.color.wePeep : theme.color.iceberg;
606
- }, function (_ref9) {
607
- var theme = _ref9.theme,
608
- error = _ref9.error;
609
613
  return error ? theme.color.cerise : theme.color.gossamer;
610
614
  });
611
615
 
@@ -626,13 +630,17 @@ var InputStyled = /*#__PURE__*/styled.input(_templateObject3$3 || (_templateObje
626
630
  return error ? theme.color.cerise : theme.color.endeavour;
627
631
  });
628
632
  var InputContainer = /*#__PURE__*/styled.div(_templateObject4$3 || (_templateObject4$3 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n\twidth: 100%;\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: center;\n"])));
629
- var DivAsLink = /*#__PURE__*/styled.div(_templateObject5$3 || (_templateObject5$3 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n\tcolor: ", ";\n\tdisplay: inherit;\n\tcursor: pointer;\n"])), function (_ref4) {
630
- var theme = _ref4.theme;
631
- return theme.color.endeavour;
633
+ var DivAsLink = /*#__PURE__*/styled.div(_templateObject5$3 || (_templateObject5$3 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n\tcolor: ", ";\n\tdisplay: inherit;\n\tcursor: ", ";\n"])), function (_ref4) {
634
+ var theme = _ref4.theme,
635
+ disabled = _ref4.disabled;
636
+ return disabled ? theme.color.casper : theme.color.endeavour;
637
+ }, function (_ref5) {
638
+ var disabled = _ref5.disabled;
639
+ return disabled ? 'not-allowed' : 'pointer';
632
640
  });
633
641
 
634
642
  var _templateObject$5;
635
- var InnerContainer = /*#__PURE__*/styled.div(_templateObject$5 || (_templateObject$5 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n\tmargin-top: 16px;\n\twidth: 100%;\n"])));
643
+ var InnerContainer = /*#__PURE__*/styled.div(_templateObject$5 || (_templateObject$5 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n\twidth: 100%;\n"])));
636
644
 
637
645
  var _templateObject$6, _templateObject2$5, _templateObject3$4, _templateObject4$4;
638
646
  var PageStatusScreenMain = /*#__PURE__*/styled(PageMainContainer)(_templateObject$6 || (_templateObject$6 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n\theight: 100%;\n"])));
@@ -691,7 +699,7 @@ var MarkW1GBold = "data:font/otf;base64,T1RUTwANAIAAAwBQQ0ZGICwMZMIAACp0AAFDmERT
691
699
  var _templateObject$8;
692
700
  var GlobalStyles = /*#__PURE__*/createGlobalStyle(_templateObject$8 || (_templateObject$8 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n \n@font-face {\n font-family: MarkW1G;\n src: url(", ") format('opentype');\n }\n @font-face {\n font-family: MarkW1G;\n font-weight: bold;\n src: url(", ") format('opentype');\n }\n\nbody{\n font-family: 'MarkW1G', sans-serif;\n}\nbody * {\n font-family: 'MarkW1G', sans-serif;\n font-size: 14px;\n font-style: normal;\n}\n"])), MarkW1GBook, MarkW1GBold);
693
701
 
694
- var img = "data:image/svg+xml,%3c!-- Generated by IcoMoon.io --%3e%3csvg version='1.1' xmlns='http://www.w3.org/2000/svg' width='1024' height='1024' viewBox='0 0 1024 1024'%3e%3ctitle%3e%3c/title%3e%3cg id='icomoon-ignore'%3e%3c/g%3e%3cpath fill='black' d='M682.667 469.333h-241.493l53.333-55.893c7.287-7.645 11.77-18.019 11.77-29.44 0-23.584-19.119-42.703-42.703-42.703-12.164 0-23.139 5.085-30.917 13.246l-0.016 0.017-122.027 128c-1.338 1.628-2.607 3.44-3.731 5.347l-0.109 0.199c-1.886 2.326-3.467 5.004-4.62 7.899l-0.073 0.207c-1.426 3.52-2.347 7.596-2.557 11.859l-0.003 0.088-0.853 3.84c0.073 5.873 1.322 11.435 3.52 16.489l-0.107-0.275c2.2 5.299 5.227 9.831 8.968 13.662l127.992 127.992c7.733 7.795 18.45 12.621 30.293 12.621s22.56-4.826 30.291-12.618l0.003-0.003c7.795-7.733 12.621-18.45 12.621-30.293s-4.826-22.56-12.618-30.291l-0.003-0.003-55.467-54.613h238.507c23.564 0 42.667-19.103 42.667-42.667s-19.103-42.667-42.667-42.667v0z'%3e%3c/path%3e%3cpath fill='black' d='M512 85.333c-235.641 0-426.667 191.025-426.667 426.667s191.025 426.667 426.667 426.667c235.641 0 426.667-191.025 426.667-426.667v0c0-235.641-191.025-426.667-426.667-426.667v0zM512 853.333c-188.513 0-341.333-152.82-341.333-341.333s152.82-341.333 341.333-341.333c188.513 0 341.333 152.82 341.333 341.333v0c0 188.513-152.82 341.333-341.333 341.333v0z'%3e%3c/path%3e%3c/svg%3e";
702
+ var img = "data:image/svg+xml,%3csvg width='21' height='21' viewBox='0 0 21 21' fill='none' xmlns='http://www.w3.org/2000/svg'%3e%3cpath fill-rule='evenodd' clip-rule='evenodd' d='M10.25 1.75C5.55621 1.75 1.75 5.55621 1.75 10.25C1.75 14.9447 5.55616 18.75 10.25 18.75C14.9438 18.75 18.75 14.9447 18.75 10.25C18.75 5.55621 14.9438 1.75 10.25 1.75ZM0.25 10.25C0.25 4.72779 4.72779 0.25 10.25 0.25C15.7722 0.25 20.25 4.72779 20.25 10.25C20.25 15.7733 15.7722 20.25 10.25 20.25C4.72784 20.25 0.25 15.7733 0.25 10.25ZM12.2238 6.25001C12.516 6.54354 12.515 7.01841 12.2215 7.31067L9.26925 10.2502L12.2215 13.1897C12.515 13.482 12.516 13.9569 12.2238 14.2504C11.9315 14.5439 11.4566 14.5449 11.1631 14.2527L7.67711 10.7817C7.53576 10.6409 7.4563 10.4497 7.4563 10.2502C7.4563 10.0507 7.53576 9.85947 7.67711 9.71873L11.1631 6.24773C11.4566 5.95547 11.9315 5.95649 12.2238 6.25001Z' fill='black'/%3e%3c/svg%3e";
695
703
 
696
704
  function Button(props) {
697
705
  var onClick = props.onClick,
@@ -875,34 +883,35 @@ var authUser = /*#__PURE__*/function () {
875
883
  },
876
884
  method: method || 'POST'
877
885
  };
878
- _context2.next = 4;
886
+ _context2.prev = 2;
887
+ _context2.next = 5;
879
888
  return fetch((test ? DASHBOARD_API_URL_TEST : DASHBOARD_API_URL) + "client_auth/" + authRequestId, reqData);
880
889
 
881
- case 4:
890
+ case 5:
882
891
  result = _context2.sent;
883
892
 
884
893
  if (!(result.status >= 200 && result.status < 300)) {
885
- _context2.next = 15;
894
+ _context2.next = 16;
886
895
  break;
887
896
  }
888
897
 
889
898
  if (!(result.status === 204)) {
890
- _context2.next = 10;
899
+ _context2.next = 11;
891
900
  break;
892
901
  }
893
902
 
894
903
  _context2.t0 = null;
895
- _context2.next = 13;
904
+ _context2.next = 14;
896
905
  break;
897
906
 
898
- case 10:
899
- _context2.next = 12;
907
+ case 11:
908
+ _context2.next = 13;
900
909
  return result.json();
901
910
 
902
- case 12:
911
+ case 13:
903
912
  _context2.t0 = _context2.sent;
904
913
 
905
- case 13:
914
+ case 14:
906
915
  json = _context2.t0;
907
916
  return _context2.abrupt("return", {
908
917
  data: json,
@@ -911,29 +920,29 @@ var authUser = /*#__PURE__*/function () {
911
920
  ok: true
912
921
  });
913
922
 
914
- case 15:
923
+ case 16:
915
924
  if (!(result.status >= 400)) {
916
- _context2.next = 25;
925
+ _context2.next = 26;
917
926
  break;
918
927
  }
919
928
 
920
929
  if (![403, 404].includes(result.status)) {
921
- _context2.next = 20;
930
+ _context2.next = 21;
922
931
  break;
923
932
  }
924
933
 
925
934
  _context2.t1 = null;
926
- _context2.next = 23;
935
+ _context2.next = 24;
927
936
  break;
928
937
 
929
- case 20:
930
- _context2.next = 22;
938
+ case 21:
939
+ _context2.next = 23;
931
940
  return result.json();
932
941
 
933
- case 22:
942
+ case 23:
934
943
  _context2.t1 = _context2.sent;
935
944
 
936
- case 23:
945
+ case 24:
937
946
  _json = _context2.t1;
938
947
  return _context2.abrupt("return", {
939
948
  headers: result.headers,
@@ -942,7 +951,7 @@ var authUser = /*#__PURE__*/function () {
942
951
  ok: false
943
952
  });
944
953
 
945
- case 25:
954
+ case 26:
946
955
  return _context2.abrupt("return", {
947
956
  headers: result.headers,
948
957
  statusCode: result.status,
@@ -950,12 +959,21 @@ var authUser = /*#__PURE__*/function () {
950
959
  ok: false
951
960
  });
952
961
 
953
- case 26:
962
+ case 29:
963
+ _context2.prev = 29;
964
+ _context2.t2 = _context2["catch"](2);
965
+ return _context2.abrupt("return", {
966
+ statusCode: 500,
967
+ error: 'Something went wrong',
968
+ ok: false
969
+ });
970
+
971
+ case 32:
954
972
  case "end":
955
973
  return _context2.stop();
956
974
  }
957
975
  }
958
- }, _callee2);
976
+ }, _callee2, null, [[2, 29]]);
959
977
  }));
960
978
 
961
979
  return function authUser(_x2) {
@@ -1018,6 +1036,17 @@ function StartScreen(props) {
1018
1036
  var _useTranslation = useTranslation(),
1019
1037
  t = _useTranslation.t;
1020
1038
 
1039
+ useEffect(function () {
1040
+ window.addEventListener('keydown', function (e) {
1041
+ return handleUserKeyPress(e, onContinue);
1042
+ });
1043
+ return function () {
1044
+ window.removeEventListener('keydown', function (e) {
1045
+ return handleUserKeyPress(e, onContinue);
1046
+ });
1047
+ };
1048
+ }, []);
1049
+
1021
1050
  var handleContinue = /*#__PURE__*/function () {
1022
1051
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
1023
1052
  var response;
@@ -1105,9 +1134,13 @@ function StartScreen(props) {
1105
1134
  bold: React.createElement("strong", null)
1106
1135
  }
1107
1136
  }))), React.createElement(H4Styled, null, t('things_you_should_know')), React.createElement("ul", null, React.createElement("li", null, t('we_dont_share_your_data_without_your_consent')), React.createElement("li", null, t('you_can_easily_stop_sharing_your_data_at_any_time')), React.createElement("li", null, t('you_can_choose_to_delete_shared_data_when_we_no_longer_need_it'))), React.createElement(Spacer, null), React.createElement("span", null, React.createElement(React.Fragment, null, t('by_proceeding_you_agree_to_the'), ' ', React.createElement("a", {
1108
- href: "https://docs.basiq.io/en/articles/415750-basiq-terms-of-service"
1137
+ href: "https://docs.basiq.io/en/articles/415750-basiq-terms-of-service",
1138
+ rel: "noreferrer",
1139
+ target: "_blank"
1109
1140
  }, t('terms_of_service')), " ", t('and'), ' ', React.createElement("a", {
1110
- href: "https://docs.basiq.io/en/articles/382581-basiq-privacy-policy"
1141
+ href: "https://docs.basiq.io/en/articles/382581-basiq-privacy-policy",
1142
+ rel: "noreferrer",
1143
+ target: "_blank"
1111
1144
  }, t('privacy_notice')))), React.createElement(LoadingModal, {
1112
1145
  isOpen: loading
1113
1146
  })));
@@ -1136,36 +1169,43 @@ function AuthScreen(_ref) {
1136
1169
  setResend = _useState3[1];
1137
1170
 
1138
1171
  var _useState4 = useState(false),
1139
- loading = _useState4[0],
1140
- setLoading = _useState4[1];
1172
+ resendLoading = _useState4[0],
1173
+ setResendLoading = _useState4[1];
1141
1174
 
1142
- var handleCodeApply = /*#__PURE__*/function () {
1143
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
1144
- var _response$data;
1175
+ var _useState5 = useState(false),
1176
+ loading = _useState5[0],
1177
+ setLoading = _useState5[1];
1145
1178
 
1146
- var response, _response$data2;
1179
+ var handleCodeApply = useCallback( /*#__PURE__*/function () {
1180
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(e) {
1181
+ var _response$data, response, _response$data2;
1147
1182
 
1148
1183
  return _regeneratorRuntime().wrap(function _callee$(_context) {
1149
1184
  while (1) {
1150
1185
  switch (_context.prev = _context.next) {
1151
1186
  case 0:
1187
+ if (!(smsCode.length === 4 && error.length === 0 && (!e || (e == null ? void 0 : e.charCode) === 13))) {
1188
+ _context.next = 7;
1189
+ break;
1190
+ }
1191
+
1152
1192
  setLoading(true);
1153
- _context.next = 3;
1193
+ _context.next = 4;
1154
1194
  return verifySmsCode({
1155
1195
  authRequestId: authRequestId,
1156
1196
  smsCode: smsCode,
1157
1197
  test: test
1158
1198
  });
1159
1199
 
1160
- case 3:
1200
+ case 4:
1161
1201
  response = _context.sent;
1162
- setLoading(false);
1163
1202
 
1164
1203
  if (response != null && (_response$data = response.data) != null && _response$data.access_token) {
1165
- window.open("https://consent.basiq.io/home?token=" + (response == null ? void 0 : (_response$data2 = response.data) == null ? void 0 : _response$data2.access_token));
1204
+ window.open("https://consent.basiq.io/home?token=" + (response == null ? void 0 : (_response$data2 = response.data) == null ? void 0 : _response$data2.access_token), "_self");
1166
1205
  }
1167
1206
 
1168
1207
  if (response != null && response.error) {
1208
+ setLoading(false);
1169
1209
  setError(t('this_code_doesnt_appear_to_be_valid'));
1170
1210
  }
1171
1211
 
@@ -1177,16 +1217,16 @@ function AuthScreen(_ref) {
1177
1217
  }, _callee);
1178
1218
  }));
1179
1219
 
1180
- return function handleCodeApply() {
1220
+ return function (_x) {
1181
1221
  return _ref2.apply(this, arguments);
1182
1222
  };
1183
- }();
1184
-
1223
+ }(), [smsCode, error, authRequestId]);
1185
1224
  var buttons = [{
1186
1225
  label: t('continue'),
1187
1226
  onClick: function onClick() {
1188
1227
  return handleCodeApply();
1189
- }
1228
+ },
1229
+ disabled: smsCode.length < 4 || !!error
1190
1230
  }];
1191
1231
 
1192
1232
  var handleResend = /*#__PURE__*/function () {
@@ -1198,16 +1238,17 @@ function AuthScreen(_ref) {
1198
1238
  case 0:
1199
1239
  setError('');
1200
1240
  setSmsCode('');
1201
- setLoading(true);
1202
- _context2.next = 5;
1241
+ setResend(false);
1242
+ setResendLoading(true);
1243
+ _context2.next = 6;
1203
1244
  return authUser({
1204
1245
  authRequestId: authRequestId,
1205
1246
  test: test
1206
1247
  });
1207
1248
 
1208
- case 5:
1249
+ case 6:
1209
1250
  response = _context2.sent;
1210
- setLoading(false);
1251
+ setResendLoading(false);
1211
1252
 
1212
1253
  if (response.error) {
1213
1254
  setError(t('failed_to_send_sms'));
@@ -1215,7 +1256,7 @@ function AuthScreen(_ref) {
1215
1256
  setResend(true);
1216
1257
  }
1217
1258
 
1218
- case 8:
1259
+ case 9:
1219
1260
  case "end":
1220
1261
  return _context2.stop();
1221
1262
  }
@@ -1231,7 +1272,10 @@ function AuthScreen(_ref) {
1231
1272
  var handleInput = function handleInput(e) {
1232
1273
  setError('');
1233
1274
  setResend(false);
1234
- setSmsCode(e.target.value);
1275
+
1276
+ if (/^([0-9]+)$/.test(e.target.value) || e.target.value === '') {
1277
+ setSmsCode(e.target.value);
1278
+ }
1235
1279
  };
1236
1280
 
1237
1281
  return React.createElement(Page, {
@@ -1251,12 +1295,16 @@ function AuthScreen(_ref) {
1251
1295
  onChange: handleInput,
1252
1296
  value: smsCode,
1253
1297
  filled: smsCode.length === 4,
1254
- error: !!error
1298
+ error: !!error,
1299
+ onKeyPress: function onKeyPress(e) {
1300
+ return handleCodeApply(e);
1301
+ }
1255
1302
  })), React.createElement(PageConnectFooterControl, null, resend && React.createElement(StatusMessage, null, t('new_sms_code_has_been_sent')), !!error && React.createElement(StatusMessage, {
1256
1303
  error: true
1257
1304
  }, error), React.createElement(PageConnectFooterText, null, React.createElement("span", null, React.createElement(React.Fragment, null, t('didnt_receive_the_code'), " ", React.createElement(DivAsLink, {
1305
+ disabled: resendLoading,
1258
1306
  onClick: function onClick() {
1259
- return handleResend();
1307
+ return !resendLoading && handleResend();
1260
1308
  }
1261
1309
  }, t('resend_sms')))))), React.createElement(LoadingModal, {
1262
1310
  isOpen: loading
@@ -1264,6 +1312,7 @@ function AuthScreen(_ref) {
1264
1312
  }
1265
1313
 
1266
1314
  function App(props) {
1315
+ var test = props.test;
1267
1316
  var ref = createRef();
1268
1317
 
1269
1318
  var _useState = useState(false),
@@ -1302,6 +1351,11 @@ function App(props) {
1302
1351
  setShadow(detectScrollToBottom(event));
1303
1352
  };
1304
1353
 
1354
+ var showErrorScreen = function showErrorScreen(code) {
1355
+ setErrorCode(code);
1356
+ setCurrentScreen(3);
1357
+ };
1358
+
1305
1359
  useEffect(function () {
1306
1360
  var getData = /*#__PURE__*/function () {
1307
1361
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
@@ -1324,7 +1378,7 @@ function App(props) {
1324
1378
  return authUser({
1325
1379
  authRequestId: id,
1326
1380
  method: 'GET',
1327
- test: props.test
1381
+ test: test
1328
1382
  });
1329
1383
 
1330
1384
  case 6:
@@ -1370,11 +1424,6 @@ function App(props) {
1370
1424
  getData();
1371
1425
  }, []);
1372
1426
 
1373
- var showErrorScreen = function showErrorScreen(code) {
1374
- setErrorCode(code);
1375
- setCurrentScreen(3);
1376
- };
1377
-
1378
1427
  var getScreen = function getScreen() {
1379
1428
  switch (currentScreen) {
1380
1429
  case 0:
@@ -1394,7 +1443,7 @@ function App(props) {
1394
1443
  return setCurrentScreen(2);
1395
1444
  },
1396
1445
  authRequestId: authId,
1397
- test: props.test
1446
+ test: test
1398
1447
  });
1399
1448
 
1400
1449
  case 2:
@@ -1405,7 +1454,7 @@ function App(props) {
1405
1454
  },
1406
1455
  shadow: shadow,
1407
1456
  authRequestId: authId,
1408
- test: props.test
1457
+ test: test
1409
1458
  });
1410
1459
 
1411
1460
  case 3:
@@ -1503,10 +1552,11 @@ i18n.use(initReactI18next) // passes i18n down to react-i18next
1503
1552
  });
1504
1553
 
1505
1554
  function BasiqConnect(props) {
1555
+ var test = props.test;
1506
1556
  return React.createElement(React.StrictMode, null, React.createElement(ThemeProvider, {
1507
1557
  theme: theme
1508
1558
  }, React.createElement(App, {
1509
- test: props.test
1559
+ test: test
1510
1560
  })));
1511
1561
  }
1512
1562