@basiq/connect-auth 1.0.5 → 1.0.7

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.
@@ -5,6 +5,8 @@ interface IProps {
5
5
  shadow: boolean;
6
6
  appName: string;
7
7
  authRequestId?: string;
8
+ smsSent: boolean;
9
+ setSmsSent: (code: boolean) => void;
8
10
  test?: boolean;
9
11
  }
10
12
  declare function StartScreen(props: IProps): JSX.Element;
@@ -931,6 +931,8 @@ function StartScreen(props) {
931
931
  shadow = props.shadow,
932
932
  authRequestId = props.authRequestId,
933
933
  showErrorScreen = props.showErrorScreen,
934
+ smsSent = props.smsSent,
935
+ setSmsSent = props.setSmsSent,
934
936
  test = props.test;
935
937
  var _useState = React.useState(false),
936
938
  loading = _useState[0],
@@ -954,8 +956,8 @@ function StartScreen(props) {
954
956
  while (1) switch (_context.prev = _context.next) {
955
957
  case 0:
956
958
  setLoading(true);
957
- if (!authRequestId) {
958
- _context.next = 6;
959
+ if (!(authRequestId && !smsSent)) {
960
+ _context.next = 8;
959
961
  break;
960
962
  }
961
963
  _context.next = 4;
@@ -966,12 +968,20 @@ function StartScreen(props) {
966
968
  case 4:
967
969
  response = _context.sent;
968
970
  if (response != null && response.ok) {
971
+ setSmsSent(true);
969
972
  setLoading(false);
970
973
  onContinue();
971
974
  } else {
972
975
  showErrorScreen(response == null ? void 0 : response.statusCode.toString());
973
976
  }
974
- case 6:
977
+ _context.next = 9;
978
+ break;
979
+ case 8:
980
+ if (smsSent) {
981
+ setLoading(false);
982
+ onContinue();
983
+ }
984
+ case 9:
975
985
  case "end":
976
986
  return _context.stop();
977
987
  }
@@ -1096,7 +1106,7 @@ function AuthScreen(_ref) {
1096
1106
  return function (_x) {
1097
1107
  return _ref2.apply(this, arguments);
1098
1108
  };
1099
- }(), [smsCode, error, authRequestId]);
1109
+ }(), [smsCode, error, authRequestId, action, test]);
1100
1110
  var buttons = [{
1101
1111
  label: t('continue'),
1102
1112
  onClick: function onClick() {
@@ -1207,6 +1217,9 @@ function App(props) {
1207
1217
  var _useState9 = React.useState(''),
1208
1218
  errorCode = _useState9[0],
1209
1219
  setErrorCode = _useState9[1];
1220
+ var _useState10 = React.useState(false),
1221
+ smsSent = _useState10[0],
1222
+ setSmsSent = _useState10[1];
1210
1223
  var handleConnectionsScroll = function handleConnectionsScroll(event) {
1211
1224
  setShadow(detectScrollToBottom(event));
1212
1225
  };
@@ -1217,25 +1230,28 @@ function App(props) {
1217
1230
  React.useEffect(function () {
1218
1231
  var getData = /*#__PURE__*/function () {
1219
1232
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
1220
- var _window$location$path, id, action, response, _response$data, _response$data2, _response$data4, _response$data3, _response$data5;
1233
+ var id, actionParam, response, _response$data, _response$data2, _response$data4, _response$data3, _response$data5;
1221
1234
  return _regeneratorRuntime().wrap(function _callee$(_context) {
1222
1235
  while (1) switch (_context.prev = _context.next) {
1223
1236
  case 0:
1224
- _window$location$path = window.location.pathname.substring(1).split('?action='), id = _window$location$path[0], action = _window$location$path[1];
1225
- action && setAction(action);
1237
+ id = window.location.pathname.substring(1);
1238
+ actionParam = window.location.search.split('?action=')[1];
1239
+ if ((actionParam == null ? void 0 : actionParam.length) > 0) {
1240
+ setAction(actionParam);
1241
+ }
1226
1242
  if (!((id == null ? void 0 : id.length) > 0)) {
1227
- _context.next = 11;
1243
+ _context.next = 12;
1228
1244
  break;
1229
1245
  }
1230
1246
  setAuthId(id);
1231
1247
  setLoading(true);
1232
- _context.next = 7;
1248
+ _context.next = 8;
1233
1249
  return authUser({
1234
1250
  authRequestId: id,
1235
1251
  method: 'GET',
1236
1252
  test: test
1237
1253
  });
1238
- case 7:
1254
+ case 8:
1239
1255
  response = _context.sent;
1240
1256
  if (response != null && response.ok) {
1241
1257
  setCurrentScreen(1);
@@ -1249,13 +1265,13 @@ function App(props) {
1249
1265
  } else {
1250
1266
  showErrorScreen(response == null ? void 0 : response.statusCode.toString());
1251
1267
  }
1252
- _context.next = 12;
1268
+ _context.next = 13;
1253
1269
  break;
1254
- case 11:
1255
- showErrorScreen('404');
1256
1270
  case 12:
1257
- setLoading(false);
1271
+ showErrorScreen('404');
1258
1272
  case 13:
1273
+ setLoading(false);
1274
+ case 14:
1259
1275
  case "end":
1260
1276
  return _context.stop();
1261
1277
  }
@@ -1285,6 +1301,8 @@ function App(props) {
1285
1301
  return setCurrentScreen(2);
1286
1302
  },
1287
1303
  authRequestId: authId,
1304
+ smsSent: smsSent,
1305
+ setSmsSent: setSmsSent,
1288
1306
  test: test
1289
1307
  });
1290
1308
  case 2: