@basiq/connect-auth 0.1.86 → 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 +2 -1
- package/dist/actions/actions.d.ts +10 -2
- package/dist/components/BasiqConnect.d.ts +6 -0
- package/dist/components/pages/AuthScreen.d.ts +3 -2
- package/dist/components/pages/StartScreen.d.ts +2 -1
- package/dist/connect-auth.cjs.development.js +79 -59
- package/dist/connect-auth.cjs.development.js.map +1 -1
- package/dist/connect-auth.cjs.production.min.js +1 -1
- package/dist/connect-auth.cjs.production.min.js.map +1 -1
- package/dist/connect-auth.esm.js +79 -59
- package/dist/connect-auth.esm.js.map +1 -1
- package/dist/helpers/constants.d.ts +1 -0
- package/dist/index.d.ts +1 -1
- package/package.json +1 -3
- package/dist/BasiqConnect.d.ts +0 -3
package/dist/App.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
export declare const verifySmsCode: (authRequestId
|
|
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
|
|
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;
|
|
@@ -3,7 +3,8 @@ interface IProps {
|
|
|
3
3
|
shadow: boolean;
|
|
4
4
|
onBack: () => void;
|
|
5
5
|
number: string;
|
|
6
|
-
|
|
6
|
+
authRequestId: string;
|
|
7
|
+
test?: boolean;
|
|
7
8
|
}
|
|
8
|
-
declare function AuthScreen({ onBack, number,
|
|
9
|
+
declare function AuthScreen({ onBack, number, authRequestId, shadow, test }: IProps): JSX.Element;
|
|
9
10
|
export default AuthScreen;
|
|
@@ -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
|
-
|
|
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
|
|
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 =
|
|
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
|
|
805
|
+
case 5:
|
|
805
806
|
result = _context.sent;
|
|
806
807
|
|
|
807
808
|
if (!(result.status >= 200 && result.status < 300)) {
|
|
808
|
-
_context.next =
|
|
809
|
+
_context.next = 16;
|
|
809
810
|
break;
|
|
810
811
|
}
|
|
811
812
|
|
|
812
813
|
if (!(result.status === 204)) {
|
|
813
|
-
_context.next =
|
|
814
|
+
_context.next = 11;
|
|
814
815
|
break;
|
|
815
816
|
}
|
|
816
817
|
|
|
817
818
|
_context.t0 = null;
|
|
818
|
-
_context.next =
|
|
819
|
+
_context.next = 14;
|
|
819
820
|
break;
|
|
820
821
|
|
|
821
|
-
case
|
|
822
|
-
_context.next =
|
|
822
|
+
case 11:
|
|
823
|
+
_context.next = 13;
|
|
823
824
|
return result.json();
|
|
824
825
|
|
|
825
|
-
case
|
|
826
|
+
case 13:
|
|
826
827
|
_context.t0 = _context.sent;
|
|
827
828
|
|
|
828
|
-
case
|
|
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
|
|
838
|
+
case 16:
|
|
838
839
|
if (!(result.status >= 400)) {
|
|
839
|
-
_context.next =
|
|
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
|
|
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
|
|
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
|
|
867
|
-
return
|
|
867
|
+
return function verifySmsCode(_x) {
|
|
868
|
+
return _ref2.apply(this, arguments);
|
|
868
869
|
};
|
|
869
870
|
}();
|
|
870
871
|
var authUser = /*#__PURE__*/function () {
|
|
871
|
-
var
|
|
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
|
-
|
|
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;
|
|
@@ -948,7 +946,7 @@ var authUser = /*#__PURE__*/function () {
|
|
|
948
946
|
return _context2.abrupt("return", {
|
|
949
947
|
headers: result.headers,
|
|
950
948
|
statusCode: result.status,
|
|
951
|
-
error: _json.message || result.statusText || 'Something went wrong',
|
|
949
|
+
error: (_json == null ? void 0 : _json.message) || result.statusText || 'Something went wrong',
|
|
952
950
|
ok: false
|
|
953
951
|
});
|
|
954
952
|
|
|
@@ -968,8 +966,8 @@ var authUser = /*#__PURE__*/function () {
|
|
|
968
966
|
}, _callee2);
|
|
969
967
|
}));
|
|
970
968
|
|
|
971
|
-
return function authUser(
|
|
972
|
-
return
|
|
969
|
+
return function authUser(_x2) {
|
|
970
|
+
return _ref4.apply(this, arguments);
|
|
973
971
|
};
|
|
974
972
|
}();
|
|
975
973
|
|
|
@@ -1017,7 +1015,9 @@ function StartScreen(props) {
|
|
|
1017
1015
|
var onContinue = props.onContinue,
|
|
1018
1016
|
appName = props.appName,
|
|
1019
1017
|
shadow = props.shadow,
|
|
1020
|
-
|
|
1018
|
+
authRequestId = props.authRequestId,
|
|
1019
|
+
showErrorScreen = props.showErrorScreen,
|
|
1020
|
+
test = props.test;
|
|
1021
1021
|
|
|
1022
1022
|
var _useState = React.useState(false),
|
|
1023
1023
|
loading = _useState[0],
|
|
@@ -1028,28 +1028,32 @@ function StartScreen(props) {
|
|
|
1028
1028
|
|
|
1029
1029
|
var handleContinue = /*#__PURE__*/function () {
|
|
1030
1030
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
1031
|
-
var
|
|
1032
|
-
|
|
1031
|
+
var response;
|
|
1033
1032
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1034
1033
|
while (1) {
|
|
1035
1034
|
switch (_context.prev = _context.next) {
|
|
1036
1035
|
case 0:
|
|
1037
1036
|
setLoading(true);
|
|
1038
1037
|
|
|
1039
|
-
if (!
|
|
1038
|
+
if (!authRequestId) {
|
|
1040
1039
|
_context.next = 6;
|
|
1041
1040
|
break;
|
|
1042
1041
|
}
|
|
1043
1042
|
|
|
1044
1043
|
_context.next = 4;
|
|
1045
|
-
return authUser(
|
|
1044
|
+
return authUser({
|
|
1045
|
+
authRequestId: authRequestId,
|
|
1046
|
+
test: test
|
|
1047
|
+
});
|
|
1046
1048
|
|
|
1047
1049
|
case 4:
|
|
1048
1050
|
response = _context.sent;
|
|
1049
1051
|
|
|
1050
|
-
if (
|
|
1052
|
+
if (response != null && response.ok) {
|
|
1051
1053
|
setLoading(false);
|
|
1052
1054
|
onContinue();
|
|
1055
|
+
} else {
|
|
1056
|
+
showErrorScreen(response == null ? void 0 : response.statusCode.toString());
|
|
1053
1057
|
}
|
|
1054
1058
|
|
|
1055
1059
|
case 6:
|
|
@@ -1120,8 +1124,9 @@ function StartScreen(props) {
|
|
|
1120
1124
|
function AuthScreen(_ref) {
|
|
1121
1125
|
var onBack = _ref.onBack,
|
|
1122
1126
|
number = _ref.number,
|
|
1123
|
-
|
|
1124
|
-
shadow = _ref.shadow
|
|
1127
|
+
authRequestId = _ref.authRequestId,
|
|
1128
|
+
shadow = _ref.shadow,
|
|
1129
|
+
test = _ref.test;
|
|
1125
1130
|
|
|
1126
1131
|
var _useTranslation = reactI18next.useTranslation(),
|
|
1127
1132
|
t = _useTranslation.t;
|
|
@@ -1131,8 +1136,8 @@ function AuthScreen(_ref) {
|
|
|
1131
1136
|
setError = _useState[1];
|
|
1132
1137
|
|
|
1133
1138
|
var _useState2 = React.useState(''),
|
|
1134
|
-
|
|
1135
|
-
|
|
1139
|
+
smsCode = _useState2[0],
|
|
1140
|
+
setSmsCode = _useState2[1];
|
|
1136
1141
|
|
|
1137
1142
|
var _useState3 = React.useState(false),
|
|
1138
1143
|
resend = _useState3[0],
|
|
@@ -1154,7 +1159,11 @@ function AuthScreen(_ref) {
|
|
|
1154
1159
|
case 0:
|
|
1155
1160
|
setLoading(true);
|
|
1156
1161
|
_context.next = 3;
|
|
1157
|
-
return verifySmsCode(
|
|
1162
|
+
return verifySmsCode({
|
|
1163
|
+
authRequestId: authRequestId,
|
|
1164
|
+
smsCode: smsCode,
|
|
1165
|
+
test: test
|
|
1166
|
+
});
|
|
1158
1167
|
|
|
1159
1168
|
case 3:
|
|
1160
1169
|
response = _context.sent;
|
|
@@ -1196,10 +1205,13 @@ function AuthScreen(_ref) {
|
|
|
1196
1205
|
switch (_context2.prev = _context2.next) {
|
|
1197
1206
|
case 0:
|
|
1198
1207
|
setError('');
|
|
1199
|
-
|
|
1208
|
+
setSmsCode('');
|
|
1200
1209
|
setLoading(true);
|
|
1201
1210
|
_context2.next = 5;
|
|
1202
|
-
return authUser(
|
|
1211
|
+
return authUser({
|
|
1212
|
+
authRequestId: authRequestId,
|
|
1213
|
+
test: test
|
|
1214
|
+
});
|
|
1203
1215
|
|
|
1204
1216
|
case 5:
|
|
1205
1217
|
response = _context2.sent;
|
|
@@ -1227,7 +1239,7 @@ function AuthScreen(_ref) {
|
|
|
1227
1239
|
var handleInput = function handleInput(e) {
|
|
1228
1240
|
setError('');
|
|
1229
1241
|
setResend(false);
|
|
1230
|
-
|
|
1242
|
+
setSmsCode(e.target.value);
|
|
1231
1243
|
};
|
|
1232
1244
|
|
|
1233
1245
|
return React__default.createElement(Page, {
|
|
@@ -1245,8 +1257,8 @@ function AuthScreen(_ref) {
|
|
|
1245
1257
|
type: "text",
|
|
1246
1258
|
maxLength: 4,
|
|
1247
1259
|
onChange: handleInput,
|
|
1248
|
-
value:
|
|
1249
|
-
filled:
|
|
1260
|
+
value: smsCode,
|
|
1261
|
+
filled: smsCode.length === 4,
|
|
1250
1262
|
error: !!error
|
|
1251
1263
|
})), React__default.createElement(PageConnectFooterControl, null, resend && React__default.createElement(StatusMessage, null, t('new_sms_code_has_been_sent')), !!error && React__default.createElement(StatusMessage, {
|
|
1252
1264
|
error: true
|
|
@@ -1259,7 +1271,7 @@ function AuthScreen(_ref) {
|
|
|
1259
1271
|
})));
|
|
1260
1272
|
}
|
|
1261
1273
|
|
|
1262
|
-
function App() {
|
|
1274
|
+
function App(props) {
|
|
1263
1275
|
var ref = React.createRef();
|
|
1264
1276
|
|
|
1265
1277
|
var _useState = React.useState(false),
|
|
@@ -1301,7 +1313,7 @@ function App() {
|
|
|
1301
1313
|
React.useEffect(function () {
|
|
1302
1314
|
var getData = /*#__PURE__*/function () {
|
|
1303
1315
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
1304
|
-
var id,
|
|
1316
|
+
var id, response, _response$data, _response$data2, _response$data4, _response$data4$partn, _response$data3, _response$data5, _response$data5$partn;
|
|
1305
1317
|
|
|
1306
1318
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1307
1319
|
while (1) {
|
|
@@ -1317,21 +1329,25 @@ function App() {
|
|
|
1317
1329
|
setAuthId(id);
|
|
1318
1330
|
setLoading(true);
|
|
1319
1331
|
_context.next = 6;
|
|
1320
|
-
return authUser(
|
|
1332
|
+
return authUser({
|
|
1333
|
+
authRequestId: id,
|
|
1334
|
+
method: 'GET',
|
|
1335
|
+
test: props.test
|
|
1336
|
+
});
|
|
1321
1337
|
|
|
1322
1338
|
case 6:
|
|
1323
1339
|
response = _context.sent;
|
|
1324
1340
|
|
|
1325
|
-
if (response != null &&
|
|
1341
|
+
if (response != null && response.ok) {
|
|
1326
1342
|
setCurrentScreen(1);
|
|
1327
|
-
setMobile(response == null ? void 0 : (_response$
|
|
1343
|
+
setMobile(response == null ? void 0 : (_response$data = response.data) == null ? void 0 : _response$data.mobile);
|
|
1328
1344
|
|
|
1329
|
-
if (response != null && (_response$
|
|
1330
|
-
setAppName(response == null ? void 0 : (_response$
|
|
1345
|
+
if (response != null && (_response$data2 = response.data) != null && _response$data2.appName) {
|
|
1346
|
+
setAppName(response == null ? void 0 : (_response$data3 = response.data) == null ? void 0 : _response$data3.appName);
|
|
1331
1347
|
}
|
|
1332
1348
|
|
|
1333
|
-
if (response != null && (_response$
|
|
1334
|
-
setLogo(response == null ? void 0 : (_response$
|
|
1349
|
+
if (response != null && (_response$data4 = response.data) != null && (_response$data4$partn = _response$data4.partner) != null && _response$data4$partn.logoUrl) {
|
|
1350
|
+
setLogo(response == null ? void 0 : (_response$data5 = response.data) == null ? void 0 : (_response$data5$partn = _response$data5.partner) == null ? void 0 : _response$data5$partn.logoUrl);
|
|
1335
1351
|
}
|
|
1336
1352
|
} else {
|
|
1337
1353
|
showErrorScreen(response == null ? void 0 : response.statusCode.toString());
|
|
@@ -1385,7 +1401,8 @@ function App() {
|
|
|
1385
1401
|
onContinue: function onContinue() {
|
|
1386
1402
|
return setCurrentScreen(2);
|
|
1387
1403
|
},
|
|
1388
|
-
|
|
1404
|
+
authRequestId: authId,
|
|
1405
|
+
test: props.test
|
|
1389
1406
|
});
|
|
1390
1407
|
|
|
1391
1408
|
case 2:
|
|
@@ -1395,7 +1412,8 @@ function App() {
|
|
|
1395
1412
|
return setCurrentScreen(1);
|
|
1396
1413
|
},
|
|
1397
1414
|
shadow: shadow,
|
|
1398
|
-
|
|
1415
|
+
authRequestId: authId,
|
|
1416
|
+
test: props.test
|
|
1399
1417
|
});
|
|
1400
1418
|
|
|
1401
1419
|
case 3:
|
|
@@ -1492,10 +1510,12 @@ i18n.use(reactI18next.initReactI18next) // passes i18n down to react-i18next
|
|
|
1492
1510
|
}
|
|
1493
1511
|
});
|
|
1494
1512
|
|
|
1495
|
-
function BasiqConnect() {
|
|
1513
|
+
function BasiqConnect(props) {
|
|
1496
1514
|
return React__default.createElement(React__default.StrictMode, null, React__default.createElement(styled.ThemeProvider, {
|
|
1497
1515
|
theme: theme
|
|
1498
|
-
}, React__default.createElement(App,
|
|
1516
|
+
}, React__default.createElement(App, {
|
|
1517
|
+
test: props.test
|
|
1518
|
+
})));
|
|
1499
1519
|
}
|
|
1500
1520
|
|
|
1501
1521
|
exports.BasiqConnect = BasiqConnect;
|