@basiq/connect-auth 0.1.88 → 0.1.89

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.
@@ -467,7 +467,7 @@ var hexToRGBa = function hexToRGBa(hex, opacity) {
467
467
  return "rgba(" + (hexToRGBA == null ? void 0 : hexToRGBA.concat(opp).join()) + ")";
468
468
  };
469
469
 
470
- // export const DASHBOARD_API_URL = 'https://c9joivz12f.execute-api.ap-southeast-2.amazonaws.com/Development/';
470
+ var DASHBOARD_API_URL_TEST = 'https://c9joivz12f.execute-api.ap-southeast-2.amazonaws.com/Development/';
471
471
  var DASHBOARD_API_URL = 'https://p4c8zn20r9.execute-api.ap-southeast-2.amazonaws.com/Production_v1/';
472
472
 
473
473
  var _templateObject$2, _templateObject2$2, _templateObject3$1;
@@ -773,12 +773,13 @@ function NotFound(_ref) {
773
773
  }
774
774
 
775
775
  var verifySmsCode = /*#__PURE__*/function () {
776
- var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(authRequestId, smsCode) {
777
- var body, reqData, result, json;
776
+ var _ref2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
777
+ var authRequestId, smsCode, test, body, reqData, result, json;
778
778
  return _regeneratorRuntime().wrap(function _callee$(_context) {
779
779
  while (1) {
780
780
  switch (_context.prev = _context.next) {
781
781
  case 0:
782
+ authRequestId = _ref.authRequestId, smsCode = _ref.smsCode, test = _ref.test;
782
783
  body = {
783
784
  'sms-code': smsCode
784
785
  };
@@ -790,34 +791,34 @@ var verifySmsCode = /*#__PURE__*/function () {
790
791
  method: 'POST',
791
792
  body: JSON.stringify(body)
792
793
  };
793
- _context.next = 4;
794
- return fetch(DASHBOARD_API_URL + "client_auth/" + authRequestId + "/token", reqData);
794
+ _context.next = 5;
795
+ return fetch((test ? DASHBOARD_API_URL_TEST : DASHBOARD_API_URL) + "client_auth/" + authRequestId + "/token", reqData);
795
796
 
796
- case 4:
797
+ case 5:
797
798
  result = _context.sent;
798
799
 
799
800
  if (!(result.status >= 200 && result.status < 300)) {
800
- _context.next = 15;
801
+ _context.next = 16;
801
802
  break;
802
803
  }
803
804
 
804
805
  if (!(result.status === 204)) {
805
- _context.next = 10;
806
+ _context.next = 11;
806
807
  break;
807
808
  }
808
809
 
809
810
  _context.t0 = null;
810
- _context.next = 13;
811
+ _context.next = 14;
811
812
  break;
812
813
 
813
- case 10:
814
- _context.next = 12;
814
+ case 11:
815
+ _context.next = 13;
815
816
  return result.json();
816
817
 
817
- case 12:
818
+ case 13:
818
819
  _context.t0 = _context.sent;
819
820
 
820
- case 13:
821
+ case 14:
821
822
  json = _context.t0;
822
823
  return _context.abrupt("return", {
823
824
  data: json,
@@ -826,9 +827,9 @@ var verifySmsCode = /*#__PURE__*/function () {
826
827
  ok: true
827
828
  });
828
829
 
829
- case 15:
830
+ case 16:
830
831
  if (!(result.status >= 400)) {
831
- _context.next = 17;
832
+ _context.next = 18;
832
833
  break;
833
834
  }
834
835
 
@@ -839,7 +840,7 @@ var verifySmsCode = /*#__PURE__*/function () {
839
840
  ok: false
840
841
  });
841
842
 
842
- case 17:
843
+ case 18:
843
844
  return _context.abrupt("return", {
844
845
  headers: result.headers,
845
846
  statusCode: result.status,
@@ -847,7 +848,7 @@ var verifySmsCode = /*#__PURE__*/function () {
847
848
  ok: false
848
849
  });
849
850
 
850
- case 18:
851
+ case 19:
851
852
  case "end":
852
853
  return _context.stop();
853
854
  }
@@ -855,30 +856,27 @@ var verifySmsCode = /*#__PURE__*/function () {
855
856
  }, _callee);
856
857
  }));
857
858
 
858
- return function verifySmsCode(_x, _x2) {
859
- return _ref.apply(this, arguments);
859
+ return function verifySmsCode(_x) {
860
+ return _ref2.apply(this, arguments);
860
861
  };
861
862
  }();
862
863
  var authUser = /*#__PURE__*/function () {
863
- var _ref2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(authRequestId, method) {
864
- var reqData, result, json, _json;
864
+ var _ref4 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref3) {
865
+ var authRequestId, method, test, reqData, result, json, _json;
865
866
 
866
867
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
867
868
  while (1) {
868
869
  switch (_context2.prev = _context2.next) {
869
870
  case 0:
870
- if (method === void 0) {
871
- method = 'POST';
872
- }
873
-
871
+ authRequestId = _ref3.authRequestId, method = _ref3.method, test = _ref3.test;
874
872
  reqData = {
875
873
  headers: {
876
874
  'Content-Type': 'application/json'
877
875
  },
878
- method: method
876
+ method: method || 'POST'
879
877
  };
880
878
  _context2.next = 4;
881
- return fetch(DASHBOARD_API_URL + "client_auth/" + authRequestId, reqData);
879
+ return fetch((test ? DASHBOARD_API_URL_TEST : DASHBOARD_API_URL) + "client_auth/" + authRequestId, reqData);
882
880
 
883
881
  case 4:
884
882
  result = _context2.sent;
@@ -960,8 +958,8 @@ var authUser = /*#__PURE__*/function () {
960
958
  }, _callee2);
961
959
  }));
962
960
 
963
- return function authUser(_x3, _x4) {
964
- return _ref2.apply(this, arguments);
961
+ return function authUser(_x2) {
962
+ return _ref4.apply(this, arguments);
965
963
  };
966
964
  }();
967
965
 
@@ -1009,8 +1007,9 @@ function StartScreen(props) {
1009
1007
  var onContinue = props.onContinue,
1010
1008
  appName = props.appName,
1011
1009
  shadow = props.shadow,
1012
- authId = props.authId,
1013
- showErrorScreen = props.showErrorScreen;
1010
+ authRequestId = props.authRequestId,
1011
+ showErrorScreen = props.showErrorScreen,
1012
+ test = props.test;
1014
1013
 
1015
1014
  var _useState = useState(false),
1016
1015
  loading = _useState[0],
@@ -1028,13 +1027,16 @@ function StartScreen(props) {
1028
1027
  case 0:
1029
1028
  setLoading(true);
1030
1029
 
1031
- if (!authId) {
1030
+ if (!authRequestId) {
1032
1031
  _context.next = 6;
1033
1032
  break;
1034
1033
  }
1035
1034
 
1036
1035
  _context.next = 4;
1037
- return authUser(authId);
1036
+ return authUser({
1037
+ authRequestId: authRequestId,
1038
+ test: test
1039
+ });
1038
1040
 
1039
1041
  case 4:
1040
1042
  response = _context.sent;
@@ -1114,8 +1116,9 @@ function StartScreen(props) {
1114
1116
  function AuthScreen(_ref) {
1115
1117
  var onBack = _ref.onBack,
1116
1118
  number = _ref.number,
1117
- authId = _ref.authId,
1118
- shadow = _ref.shadow;
1119
+ authRequestId = _ref.authRequestId,
1120
+ shadow = _ref.shadow,
1121
+ test = _ref.test;
1119
1122
 
1120
1123
  var _useTranslation = useTranslation(),
1121
1124
  t = _useTranslation.t;
@@ -1125,8 +1128,8 @@ function AuthScreen(_ref) {
1125
1128
  setError = _useState[1];
1126
1129
 
1127
1130
  var _useState2 = useState(''),
1128
- code = _useState2[0],
1129
- setCode = _useState2[1];
1131
+ smsCode = _useState2[0],
1132
+ setSmsCode = _useState2[1];
1130
1133
 
1131
1134
  var _useState3 = useState(false),
1132
1135
  resend = _useState3[0],
@@ -1148,7 +1151,11 @@ function AuthScreen(_ref) {
1148
1151
  case 0:
1149
1152
  setLoading(true);
1150
1153
  _context.next = 3;
1151
- return verifySmsCode(authId, code);
1154
+ return verifySmsCode({
1155
+ authRequestId: authRequestId,
1156
+ smsCode: smsCode,
1157
+ test: test
1158
+ });
1152
1159
 
1153
1160
  case 3:
1154
1161
  response = _context.sent;
@@ -1190,10 +1197,13 @@ function AuthScreen(_ref) {
1190
1197
  switch (_context2.prev = _context2.next) {
1191
1198
  case 0:
1192
1199
  setError('');
1193
- setCode('');
1200
+ setSmsCode('');
1194
1201
  setLoading(true);
1195
1202
  _context2.next = 5;
1196
- return authUser(authId);
1203
+ return authUser({
1204
+ authRequestId: authRequestId,
1205
+ test: test
1206
+ });
1197
1207
 
1198
1208
  case 5:
1199
1209
  response = _context2.sent;
@@ -1221,7 +1231,7 @@ function AuthScreen(_ref) {
1221
1231
  var handleInput = function handleInput(e) {
1222
1232
  setError('');
1223
1233
  setResend(false);
1224
- setCode(e.target.value);
1234
+ setSmsCode(e.target.value);
1225
1235
  };
1226
1236
 
1227
1237
  return React.createElement(Page, {
@@ -1239,8 +1249,8 @@ function AuthScreen(_ref) {
1239
1249
  type: "text",
1240
1250
  maxLength: 4,
1241
1251
  onChange: handleInput,
1242
- value: code,
1243
- filled: code.length === 4,
1252
+ value: smsCode,
1253
+ filled: smsCode.length === 4,
1244
1254
  error: !!error
1245
1255
  })), React.createElement(PageConnectFooterControl, null, resend && React.createElement(StatusMessage, null, t('new_sms_code_has_been_sent')), !!error && React.createElement(StatusMessage, {
1246
1256
  error: true
@@ -1253,7 +1263,7 @@ function AuthScreen(_ref) {
1253
1263
  })));
1254
1264
  }
1255
1265
 
1256
- function App() {
1266
+ function App(props) {
1257
1267
  var ref = createRef();
1258
1268
 
1259
1269
  var _useState = useState(false),
@@ -1311,7 +1321,11 @@ function App() {
1311
1321
  setAuthId(id);
1312
1322
  setLoading(true);
1313
1323
  _context.next = 6;
1314
- return authUser(id, 'GET');
1324
+ return authUser({
1325
+ authRequestId: id,
1326
+ method: 'GET',
1327
+ test: props.test
1328
+ });
1315
1329
 
1316
1330
  case 6:
1317
1331
  response = _context.sent;
@@ -1379,7 +1393,8 @@ function App() {
1379
1393
  onContinue: function onContinue() {
1380
1394
  return setCurrentScreen(2);
1381
1395
  },
1382
- authId: authId
1396
+ authRequestId: authId,
1397
+ test: props.test
1383
1398
  });
1384
1399
 
1385
1400
  case 2:
@@ -1389,7 +1404,8 @@ function App() {
1389
1404
  return setCurrentScreen(1);
1390
1405
  },
1391
1406
  shadow: shadow,
1392
- authId: authId
1407
+ authRequestId: authId,
1408
+ test: props.test
1393
1409
  });
1394
1410
 
1395
1411
  case 3:
@@ -1486,10 +1502,12 @@ i18n.use(initReactI18next) // passes i18n down to react-i18next
1486
1502
  }
1487
1503
  });
1488
1504
 
1489
- function BasiqConnect() {
1505
+ function BasiqConnect(props) {
1490
1506
  return React.createElement(React.StrictMode, null, React.createElement(ThemeProvider, {
1491
1507
  theme: theme
1492
- }, React.createElement(App, null)));
1508
+ }, React.createElement(App, {
1509
+ test: props.test
1510
+ })));
1493
1511
  }
1494
1512
 
1495
1513
  export { BasiqConnect };