@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.
package/dist/App.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  /// <reference types="react" />
2
- declare function App(): JSX.Element;
2
+ import { IBCProps } from "./components/BasiqConnect";
3
+ declare function App(props: IBCProps): JSX.Element;
3
4
  export default App;
@@ -1,4 +1,8 @@
1
- export declare const verifySmsCode: (authRequestId: string, smsCode: string) => Promise<{
1
+ export declare const verifySmsCode: ({ authRequestId, smsCode, test }: {
2
+ authRequestId: string;
3
+ smsCode: string;
4
+ test?: boolean;
5
+ }) => Promise<{
2
6
  data: any;
3
7
  headers: Headers;
4
8
  statusCode: number;
@@ -11,7 +15,11 @@ export declare const verifySmsCode: (authRequestId: string, smsCode: string) =>
11
15
  ok: boolean;
12
16
  data?: undefined;
13
17
  }>;
14
- export declare const authUser: (authRequestId: string, method?: 'POST' | 'GET') => Promise<{
18
+ export declare const authUser: ({ authRequestId, method, test }: {
19
+ authRequestId: string;
20
+ method?: 'POST' | 'GET';
21
+ test?: boolean;
22
+ }) => Promise<{
15
23
  data: any;
16
24
  headers: Headers;
17
25
  statusCode: number;
@@ -1,3 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import '../locales/i18n';
3
- export declare function BasiqConnect(): JSX.Element;
3
+ export interface IBCProps {
4
+ test?: boolean;
5
+ }
6
+ export declare function BasiqConnect(props: IBCProps): JSX.Element;
@@ -3,7 +3,8 @@ interface IProps {
3
3
  shadow: boolean;
4
4
  onBack: () => void;
5
5
  number: string;
6
- authId: string;
6
+ authRequestId: string;
7
+ test?: boolean;
7
8
  }
8
- declare function AuthScreen({ onBack, number, authId, shadow }: IProps): JSX.Element;
9
+ declare function AuthScreen({ onBack, number, authRequestId, shadow, test }: IProps): JSX.Element;
9
10
  export default AuthScreen;
@@ -4,7 +4,8 @@ interface IProps {
4
4
  showErrorScreen: (code: string) => void;
5
5
  shadow: boolean;
6
6
  appName: string;
7
- authId?: string;
7
+ authRequestId?: string;
8
+ test?: boolean;
8
9
  }
9
10
  declare function StartScreen(props: IProps): JSX.Element;
10
11
  export default StartScreen;
@@ -475,7 +475,7 @@ var hexToRGBa = function hexToRGBa(hex, opacity) {
475
475
  return "rgba(" + (hexToRGBA == null ? void 0 : hexToRGBA.concat(opp).join()) + ")";
476
476
  };
477
477
 
478
- // export const DASHBOARD_API_URL = 'https://c9joivz12f.execute-api.ap-southeast-2.amazonaws.com/Development/';
478
+ var DASHBOARD_API_URL_TEST = 'https://c9joivz12f.execute-api.ap-southeast-2.amazonaws.com/Development/';
479
479
  var DASHBOARD_API_URL = 'https://p4c8zn20r9.execute-api.ap-southeast-2.amazonaws.com/Production_v1/';
480
480
 
481
481
  var _templateObject$2, _templateObject2$2, _templateObject3$1;
@@ -781,12 +781,13 @@ function NotFound(_ref) {
781
781
  }
782
782
 
783
783
  var verifySmsCode = /*#__PURE__*/function () {
784
- var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(authRequestId, smsCode) {
785
- var body, reqData, result, json;
784
+ var _ref2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
785
+ var authRequestId, smsCode, test, body, reqData, result, json;
786
786
  return _regeneratorRuntime().wrap(function _callee$(_context) {
787
787
  while (1) {
788
788
  switch (_context.prev = _context.next) {
789
789
  case 0:
790
+ authRequestId = _ref.authRequestId, smsCode = _ref.smsCode, test = _ref.test;
790
791
  body = {
791
792
  'sms-code': smsCode
792
793
  };
@@ -798,34 +799,34 @@ var verifySmsCode = /*#__PURE__*/function () {
798
799
  method: 'POST',
799
800
  body: JSON.stringify(body)
800
801
  };
801
- _context.next = 4;
802
- return fetch(DASHBOARD_API_URL + "client_auth/" + authRequestId + "/token", reqData);
802
+ _context.next = 5;
803
+ return fetch((test ? DASHBOARD_API_URL_TEST : DASHBOARD_API_URL) + "client_auth/" + authRequestId + "/token", reqData);
803
804
 
804
- case 4:
805
+ case 5:
805
806
  result = _context.sent;
806
807
 
807
808
  if (!(result.status >= 200 && result.status < 300)) {
808
- _context.next = 15;
809
+ _context.next = 16;
809
810
  break;
810
811
  }
811
812
 
812
813
  if (!(result.status === 204)) {
813
- _context.next = 10;
814
+ _context.next = 11;
814
815
  break;
815
816
  }
816
817
 
817
818
  _context.t0 = null;
818
- _context.next = 13;
819
+ _context.next = 14;
819
820
  break;
820
821
 
821
- case 10:
822
- _context.next = 12;
822
+ case 11:
823
+ _context.next = 13;
823
824
  return result.json();
824
825
 
825
- case 12:
826
+ case 13:
826
827
  _context.t0 = _context.sent;
827
828
 
828
- case 13:
829
+ case 14:
829
830
  json = _context.t0;
830
831
  return _context.abrupt("return", {
831
832
  data: json,
@@ -834,9 +835,9 @@ var verifySmsCode = /*#__PURE__*/function () {
834
835
  ok: true
835
836
  });
836
837
 
837
- case 15:
838
+ case 16:
838
839
  if (!(result.status >= 400)) {
839
- _context.next = 17;
840
+ _context.next = 18;
840
841
  break;
841
842
  }
842
843
 
@@ -847,7 +848,7 @@ var verifySmsCode = /*#__PURE__*/function () {
847
848
  ok: false
848
849
  });
849
850
 
850
- case 17:
851
+ case 18:
851
852
  return _context.abrupt("return", {
852
853
  headers: result.headers,
853
854
  statusCode: result.status,
@@ -855,7 +856,7 @@ var verifySmsCode = /*#__PURE__*/function () {
855
856
  ok: false
856
857
  });
857
858
 
858
- case 18:
859
+ case 19:
859
860
  case "end":
860
861
  return _context.stop();
861
862
  }
@@ -863,30 +864,27 @@ var verifySmsCode = /*#__PURE__*/function () {
863
864
  }, _callee);
864
865
  }));
865
866
 
866
- return function verifySmsCode(_x, _x2) {
867
- return _ref.apply(this, arguments);
867
+ return function verifySmsCode(_x) {
868
+ return _ref2.apply(this, arguments);
868
869
  };
869
870
  }();
870
871
  var authUser = /*#__PURE__*/function () {
871
- var _ref2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(authRequestId, method) {
872
- var reqData, result, json, _json;
872
+ var _ref4 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref3) {
873
+ var authRequestId, method, test, reqData, result, json, _json;
873
874
 
874
875
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
875
876
  while (1) {
876
877
  switch (_context2.prev = _context2.next) {
877
878
  case 0:
878
- if (method === void 0) {
879
- method = 'POST';
880
- }
881
-
879
+ authRequestId = _ref3.authRequestId, method = _ref3.method, test = _ref3.test;
882
880
  reqData = {
883
881
  headers: {
884
882
  'Content-Type': 'application/json'
885
883
  },
886
- method: method
884
+ method: method || 'POST'
887
885
  };
888
886
  _context2.next = 4;
889
- return fetch(DASHBOARD_API_URL + "client_auth/" + authRequestId, reqData);
887
+ return fetch((test ? DASHBOARD_API_URL_TEST : DASHBOARD_API_URL) + "client_auth/" + authRequestId, reqData);
890
888
 
891
889
  case 4:
892
890
  result = _context2.sent;
@@ -968,8 +966,8 @@ var authUser = /*#__PURE__*/function () {
968
966
  }, _callee2);
969
967
  }));
970
968
 
971
- return function authUser(_x3, _x4) {
972
- return _ref2.apply(this, arguments);
969
+ return function authUser(_x2) {
970
+ return _ref4.apply(this, arguments);
973
971
  };
974
972
  }();
975
973
 
@@ -1017,8 +1015,9 @@ function StartScreen(props) {
1017
1015
  var onContinue = props.onContinue,
1018
1016
  appName = props.appName,
1019
1017
  shadow = props.shadow,
1020
- authId = props.authId,
1021
- showErrorScreen = props.showErrorScreen;
1018
+ authRequestId = props.authRequestId,
1019
+ showErrorScreen = props.showErrorScreen,
1020
+ test = props.test;
1022
1021
 
1023
1022
  var _useState = React.useState(false),
1024
1023
  loading = _useState[0],
@@ -1036,13 +1035,16 @@ function StartScreen(props) {
1036
1035
  case 0:
1037
1036
  setLoading(true);
1038
1037
 
1039
- if (!authId) {
1038
+ if (!authRequestId) {
1040
1039
  _context.next = 6;
1041
1040
  break;
1042
1041
  }
1043
1042
 
1044
1043
  _context.next = 4;
1045
- return authUser(authId);
1044
+ return authUser({
1045
+ authRequestId: authRequestId,
1046
+ test: test
1047
+ });
1046
1048
 
1047
1049
  case 4:
1048
1050
  response = _context.sent;
@@ -1122,8 +1124,9 @@ function StartScreen(props) {
1122
1124
  function AuthScreen(_ref) {
1123
1125
  var onBack = _ref.onBack,
1124
1126
  number = _ref.number,
1125
- authId = _ref.authId,
1126
- shadow = _ref.shadow;
1127
+ authRequestId = _ref.authRequestId,
1128
+ shadow = _ref.shadow,
1129
+ test = _ref.test;
1127
1130
 
1128
1131
  var _useTranslation = reactI18next.useTranslation(),
1129
1132
  t = _useTranslation.t;
@@ -1133,8 +1136,8 @@ function AuthScreen(_ref) {
1133
1136
  setError = _useState[1];
1134
1137
 
1135
1138
  var _useState2 = React.useState(''),
1136
- code = _useState2[0],
1137
- setCode = _useState2[1];
1139
+ smsCode = _useState2[0],
1140
+ setSmsCode = _useState2[1];
1138
1141
 
1139
1142
  var _useState3 = React.useState(false),
1140
1143
  resend = _useState3[0],
@@ -1156,7 +1159,11 @@ function AuthScreen(_ref) {
1156
1159
  case 0:
1157
1160
  setLoading(true);
1158
1161
  _context.next = 3;
1159
- return verifySmsCode(authId, code);
1162
+ return verifySmsCode({
1163
+ authRequestId: authRequestId,
1164
+ smsCode: smsCode,
1165
+ test: test
1166
+ });
1160
1167
 
1161
1168
  case 3:
1162
1169
  response = _context.sent;
@@ -1198,10 +1205,13 @@ function AuthScreen(_ref) {
1198
1205
  switch (_context2.prev = _context2.next) {
1199
1206
  case 0:
1200
1207
  setError('');
1201
- setCode('');
1208
+ setSmsCode('');
1202
1209
  setLoading(true);
1203
1210
  _context2.next = 5;
1204
- return authUser(authId);
1211
+ return authUser({
1212
+ authRequestId: authRequestId,
1213
+ test: test
1214
+ });
1205
1215
 
1206
1216
  case 5:
1207
1217
  response = _context2.sent;
@@ -1229,7 +1239,7 @@ function AuthScreen(_ref) {
1229
1239
  var handleInput = function handleInput(e) {
1230
1240
  setError('');
1231
1241
  setResend(false);
1232
- setCode(e.target.value);
1242
+ setSmsCode(e.target.value);
1233
1243
  };
1234
1244
 
1235
1245
  return React__default.createElement(Page, {
@@ -1247,8 +1257,8 @@ function AuthScreen(_ref) {
1247
1257
  type: "text",
1248
1258
  maxLength: 4,
1249
1259
  onChange: handleInput,
1250
- value: code,
1251
- filled: code.length === 4,
1260
+ value: smsCode,
1261
+ filled: smsCode.length === 4,
1252
1262
  error: !!error
1253
1263
  })), React__default.createElement(PageConnectFooterControl, null, resend && React__default.createElement(StatusMessage, null, t('new_sms_code_has_been_sent')), !!error && React__default.createElement(StatusMessage, {
1254
1264
  error: true
@@ -1261,7 +1271,7 @@ function AuthScreen(_ref) {
1261
1271
  })));
1262
1272
  }
1263
1273
 
1264
- function App() {
1274
+ function App(props) {
1265
1275
  var ref = React.createRef();
1266
1276
 
1267
1277
  var _useState = React.useState(false),
@@ -1319,7 +1329,11 @@ function App() {
1319
1329
  setAuthId(id);
1320
1330
  setLoading(true);
1321
1331
  _context.next = 6;
1322
- return authUser(id, 'GET');
1332
+ return authUser({
1333
+ authRequestId: id,
1334
+ method: 'GET',
1335
+ test: props.test
1336
+ });
1323
1337
 
1324
1338
  case 6:
1325
1339
  response = _context.sent;
@@ -1387,7 +1401,8 @@ function App() {
1387
1401
  onContinue: function onContinue() {
1388
1402
  return setCurrentScreen(2);
1389
1403
  },
1390
- authId: authId
1404
+ authRequestId: authId,
1405
+ test: props.test
1391
1406
  });
1392
1407
 
1393
1408
  case 2:
@@ -1397,7 +1412,8 @@ function App() {
1397
1412
  return setCurrentScreen(1);
1398
1413
  },
1399
1414
  shadow: shadow,
1400
- authId: authId
1415
+ authRequestId: authId,
1416
+ test: props.test
1401
1417
  });
1402
1418
 
1403
1419
  case 3:
@@ -1494,10 +1510,12 @@ i18n.use(reactI18next.initReactI18next) // passes i18n down to react-i18next
1494
1510
  }
1495
1511
  });
1496
1512
 
1497
- function BasiqConnect() {
1513
+ function BasiqConnect(props) {
1498
1514
  return React__default.createElement(React__default.StrictMode, null, React__default.createElement(styled.ThemeProvider, {
1499
1515
  theme: theme
1500
- }, React__default.createElement(App, null)));
1516
+ }, React__default.createElement(App, {
1517
+ test: props.test
1518
+ })));
1501
1519
  }
1502
1520
 
1503
1521
  exports.BasiqConnect = BasiqConnect;