@basiq/connect-auth 0.1.8 → 0.1.9
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/README.md +4 -157
- package/dist/App.d.ts +2 -1
- package/dist/actions/actions.d.ts +20 -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 +189 -117
- 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 +190 -118
- package/dist/connect-auth.esm.js.map +1 -1
- package/dist/helpers/constants.d.ts +1 -0
- package/dist/helpers/utils.d.ts +1 -0
- package/dist/index.d.ts +1 -1
- package/package.json +8 -9
- package/dist/BasiqConnect.d.ts +0 -3
package/dist/connect-auth.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useState,
|
|
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,8 +466,15 @@ 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;
|
|
469
471
|
|
|
470
|
-
|
|
472
|
+
if (keyCode === 13) {
|
|
473
|
+
onEnter();
|
|
474
|
+
}
|
|
475
|
+
};
|
|
476
|
+
|
|
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/';
|
|
472
479
|
|
|
473
480
|
var _templateObject$2, _templateObject2$2, _templateObject3$1;
|
|
@@ -527,10 +534,10 @@ var theme = {
|
|
|
527
534
|
},
|
|
528
535
|
mixin: {
|
|
529
536
|
subtitle: function subtitle() {
|
|
530
|
-
return " margin-top:
|
|
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:
|
|
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
|
};
|
|
@@ -632,7 +639,7 @@ var DivAsLink = /*#__PURE__*/styled.div(_templateObject5$3 || (_templateObject5$
|
|
|
632
639
|
});
|
|
633
640
|
|
|
634
641
|
var _templateObject$5;
|
|
635
|
-
var InnerContainer = /*#__PURE__*/styled.div(_templateObject$5 || (_templateObject$5 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n\
|
|
642
|
+
var InnerContainer = /*#__PURE__*/styled.div(_templateObject$5 || (_templateObject$5 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n\twidth: 100%;\n"])));
|
|
636
643
|
|
|
637
644
|
var _templateObject$6, _templateObject2$5, _templateObject3$4, _templateObject4$4;
|
|
638
645
|
var PageStatusScreenMain = /*#__PURE__*/styled(PageMainContainer)(_templateObject$6 || (_templateObject$6 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n\theight: 100%;\n"])));
|
|
@@ -691,7 +698,7 @@ var MarkW1GBold = "data:font/otf;base64,T1RUTwANAIAAAwBQQ0ZGICwMZMIAACp0AAFDmERT
|
|
|
691
698
|
var _templateObject$8;
|
|
692
699
|
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
700
|
|
|
694
|
-
var img = "data:image/svg+xml,%
|
|
701
|
+
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
702
|
|
|
696
703
|
function Button(props) {
|
|
697
704
|
var onClick = props.onClick,
|
|
@@ -773,12 +780,13 @@ function NotFound(_ref) {
|
|
|
773
780
|
}
|
|
774
781
|
|
|
775
782
|
var verifySmsCode = /*#__PURE__*/function () {
|
|
776
|
-
var
|
|
777
|
-
var body, reqData, result, json;
|
|
783
|
+
var _ref2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
|
|
784
|
+
var authRequestId, smsCode, test, body, reqData, result, json;
|
|
778
785
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
779
786
|
while (1) {
|
|
780
787
|
switch (_context.prev = _context.next) {
|
|
781
788
|
case 0:
|
|
789
|
+
authRequestId = _ref.authRequestId, smsCode = _ref.smsCode, test = _ref.test;
|
|
782
790
|
body = {
|
|
783
791
|
'sms-code': smsCode
|
|
784
792
|
};
|
|
@@ -790,61 +798,64 @@ var verifySmsCode = /*#__PURE__*/function () {
|
|
|
790
798
|
method: 'POST',
|
|
791
799
|
body: JSON.stringify(body)
|
|
792
800
|
};
|
|
793
|
-
_context.next =
|
|
794
|
-
return fetch(DASHBOARD_API_URL + "client_auth/" + authRequestId + "/token", reqData);
|
|
801
|
+
_context.next = 5;
|
|
802
|
+
return fetch((test ? DASHBOARD_API_URL_TEST : DASHBOARD_API_URL) + "client_auth/" + authRequestId + "/token", reqData);
|
|
795
803
|
|
|
796
|
-
case
|
|
804
|
+
case 5:
|
|
797
805
|
result = _context.sent;
|
|
798
806
|
|
|
799
807
|
if (!(result.status >= 200 && result.status < 300)) {
|
|
800
|
-
_context.next =
|
|
808
|
+
_context.next = 16;
|
|
801
809
|
break;
|
|
802
810
|
}
|
|
803
811
|
|
|
804
812
|
if (!(result.status === 204)) {
|
|
805
|
-
_context.next =
|
|
813
|
+
_context.next = 11;
|
|
806
814
|
break;
|
|
807
815
|
}
|
|
808
816
|
|
|
809
817
|
_context.t0 = null;
|
|
810
|
-
_context.next =
|
|
818
|
+
_context.next = 14;
|
|
811
819
|
break;
|
|
812
820
|
|
|
813
|
-
case
|
|
814
|
-
_context.next =
|
|
821
|
+
case 11:
|
|
822
|
+
_context.next = 13;
|
|
815
823
|
return result.json();
|
|
816
824
|
|
|
817
|
-
case
|
|
825
|
+
case 13:
|
|
818
826
|
_context.t0 = _context.sent;
|
|
819
827
|
|
|
820
|
-
case
|
|
828
|
+
case 14:
|
|
821
829
|
json = _context.t0;
|
|
822
830
|
return _context.abrupt("return", {
|
|
823
831
|
data: json,
|
|
824
832
|
headers: result.headers,
|
|
825
|
-
statusCode: result.status
|
|
833
|
+
statusCode: result.status,
|
|
834
|
+
ok: true
|
|
826
835
|
});
|
|
827
836
|
|
|
828
|
-
case
|
|
837
|
+
case 16:
|
|
829
838
|
if (!(result.status >= 400)) {
|
|
830
|
-
_context.next =
|
|
839
|
+
_context.next = 18;
|
|
831
840
|
break;
|
|
832
841
|
}
|
|
833
842
|
|
|
834
843
|
return _context.abrupt("return", {
|
|
835
844
|
headers: result.headers,
|
|
836
845
|
statusCode: result.status,
|
|
837
|
-
error: result.statusText || 'Something went wrong'
|
|
846
|
+
error: result.statusText || 'Something went wrong',
|
|
847
|
+
ok: false
|
|
838
848
|
});
|
|
839
849
|
|
|
840
|
-
case
|
|
850
|
+
case 18:
|
|
841
851
|
return _context.abrupt("return", {
|
|
842
852
|
headers: result.headers,
|
|
843
853
|
statusCode: result.status,
|
|
844
|
-
error: result.statusText || 'Something went wrong'
|
|
854
|
+
error: result.statusText || 'Something went wrong',
|
|
855
|
+
ok: false
|
|
845
856
|
});
|
|
846
857
|
|
|
847
|
-
case
|
|
858
|
+
case 19:
|
|
848
859
|
case "end":
|
|
849
860
|
return _context.stop();
|
|
850
861
|
}
|
|
@@ -852,110 +863,120 @@ var verifySmsCode = /*#__PURE__*/function () {
|
|
|
852
863
|
}, _callee);
|
|
853
864
|
}));
|
|
854
865
|
|
|
855
|
-
return function verifySmsCode(_x
|
|
856
|
-
return
|
|
866
|
+
return function verifySmsCode(_x) {
|
|
867
|
+
return _ref2.apply(this, arguments);
|
|
857
868
|
};
|
|
858
869
|
}();
|
|
859
870
|
var authUser = /*#__PURE__*/function () {
|
|
860
|
-
var
|
|
861
|
-
var reqData, result, json, _json;
|
|
871
|
+
var _ref4 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref3) {
|
|
872
|
+
var authRequestId, method, test, reqData, result, json, _json;
|
|
862
873
|
|
|
863
874
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
864
875
|
while (1) {
|
|
865
876
|
switch (_context2.prev = _context2.next) {
|
|
866
877
|
case 0:
|
|
867
|
-
|
|
868
|
-
method = 'POST';
|
|
869
|
-
}
|
|
870
|
-
|
|
878
|
+
authRequestId = _ref3.authRequestId, method = _ref3.method, test = _ref3.test;
|
|
871
879
|
reqData = {
|
|
872
880
|
headers: {
|
|
873
881
|
'Content-Type': 'application/json'
|
|
874
882
|
},
|
|
875
|
-
method: method
|
|
883
|
+
method: method || 'POST'
|
|
876
884
|
};
|
|
877
|
-
_context2.
|
|
878
|
-
|
|
885
|
+
_context2.prev = 2;
|
|
886
|
+
_context2.next = 5;
|
|
887
|
+
return fetch((test ? DASHBOARD_API_URL_TEST : DASHBOARD_API_URL) + "client_auth/" + authRequestId, reqData);
|
|
879
888
|
|
|
880
|
-
case
|
|
889
|
+
case 5:
|
|
881
890
|
result = _context2.sent;
|
|
882
891
|
|
|
883
892
|
if (!(result.status >= 200 && result.status < 300)) {
|
|
884
|
-
_context2.next =
|
|
893
|
+
_context2.next = 16;
|
|
885
894
|
break;
|
|
886
895
|
}
|
|
887
896
|
|
|
888
897
|
if (!(result.status === 204)) {
|
|
889
|
-
_context2.next =
|
|
898
|
+
_context2.next = 11;
|
|
890
899
|
break;
|
|
891
900
|
}
|
|
892
901
|
|
|
893
902
|
_context2.t0 = null;
|
|
894
|
-
_context2.next =
|
|
903
|
+
_context2.next = 14;
|
|
895
904
|
break;
|
|
896
905
|
|
|
897
|
-
case
|
|
898
|
-
_context2.next =
|
|
906
|
+
case 11:
|
|
907
|
+
_context2.next = 13;
|
|
899
908
|
return result.json();
|
|
900
909
|
|
|
901
|
-
case
|
|
910
|
+
case 13:
|
|
902
911
|
_context2.t0 = _context2.sent;
|
|
903
912
|
|
|
904
|
-
case
|
|
913
|
+
case 14:
|
|
905
914
|
json = _context2.t0;
|
|
906
915
|
return _context2.abrupt("return", {
|
|
907
916
|
data: json,
|
|
908
917
|
headers: result.headers,
|
|
909
|
-
statusCode: result.status
|
|
918
|
+
statusCode: result.status,
|
|
919
|
+
ok: true
|
|
910
920
|
});
|
|
911
921
|
|
|
912
|
-
case
|
|
922
|
+
case 16:
|
|
913
923
|
if (!(result.status >= 400)) {
|
|
914
|
-
_context2.next =
|
|
924
|
+
_context2.next = 26;
|
|
915
925
|
break;
|
|
916
926
|
}
|
|
917
927
|
|
|
918
|
-
if (!(result.status
|
|
919
|
-
_context2.next =
|
|
928
|
+
if (![403, 404].includes(result.status)) {
|
|
929
|
+
_context2.next = 21;
|
|
920
930
|
break;
|
|
921
931
|
}
|
|
922
932
|
|
|
923
933
|
_context2.t1 = null;
|
|
924
|
-
_context2.next =
|
|
934
|
+
_context2.next = 24;
|
|
925
935
|
break;
|
|
926
936
|
|
|
927
|
-
case
|
|
928
|
-
_context2.next =
|
|
937
|
+
case 21:
|
|
938
|
+
_context2.next = 23;
|
|
929
939
|
return result.json();
|
|
930
940
|
|
|
931
|
-
case
|
|
941
|
+
case 23:
|
|
932
942
|
_context2.t1 = _context2.sent;
|
|
933
943
|
|
|
934
|
-
case
|
|
944
|
+
case 24:
|
|
935
945
|
_json = _context2.t1;
|
|
936
946
|
return _context2.abrupt("return", {
|
|
937
947
|
headers: result.headers,
|
|
938
948
|
statusCode: result.status,
|
|
939
|
-
error: _json.message || result.statusText || 'Something went wrong'
|
|
949
|
+
error: (_json == null ? void 0 : _json.message) || result.statusText || 'Something went wrong',
|
|
950
|
+
ok: false
|
|
940
951
|
});
|
|
941
952
|
|
|
942
|
-
case
|
|
953
|
+
case 26:
|
|
943
954
|
return _context2.abrupt("return", {
|
|
944
955
|
headers: result.headers,
|
|
945
956
|
statusCode: result.status,
|
|
946
|
-
error: result.statusText || 'Something went wrong'
|
|
957
|
+
error: result.statusText || 'Something went wrong',
|
|
958
|
+
ok: false
|
|
947
959
|
});
|
|
948
960
|
|
|
949
|
-
case
|
|
961
|
+
case 29:
|
|
962
|
+
_context2.prev = 29;
|
|
963
|
+
_context2.t2 = _context2["catch"](2);
|
|
964
|
+
return _context2.abrupt("return", {
|
|
965
|
+
statusCode: 500,
|
|
966
|
+
error: 'Something went wrong',
|
|
967
|
+
ok: false
|
|
968
|
+
});
|
|
969
|
+
|
|
970
|
+
case 32:
|
|
950
971
|
case "end":
|
|
951
972
|
return _context2.stop();
|
|
952
973
|
}
|
|
953
974
|
}
|
|
954
|
-
}, _callee2);
|
|
975
|
+
}, _callee2, null, [[2, 29]]);
|
|
955
976
|
}));
|
|
956
977
|
|
|
957
|
-
return function authUser(
|
|
958
|
-
return
|
|
978
|
+
return function authUser(_x2) {
|
|
979
|
+
return _ref4.apply(this, arguments);
|
|
959
980
|
};
|
|
960
981
|
}();
|
|
961
982
|
|
|
@@ -1003,7 +1024,9 @@ function StartScreen(props) {
|
|
|
1003
1024
|
var onContinue = props.onContinue,
|
|
1004
1025
|
appName = props.appName,
|
|
1005
1026
|
shadow = props.shadow,
|
|
1006
|
-
|
|
1027
|
+
authRequestId = props.authRequestId,
|
|
1028
|
+
showErrorScreen = props.showErrorScreen,
|
|
1029
|
+
test = props.test;
|
|
1007
1030
|
|
|
1008
1031
|
var _useState = useState(false),
|
|
1009
1032
|
loading = _useState[0],
|
|
@@ -1012,30 +1035,45 @@ function StartScreen(props) {
|
|
|
1012
1035
|
var _useTranslation = useTranslation(),
|
|
1013
1036
|
t = _useTranslation.t;
|
|
1014
1037
|
|
|
1038
|
+
useEffect(function () {
|
|
1039
|
+
window.addEventListener('keydown', function (e) {
|
|
1040
|
+
return handleUserKeyPress(e, onContinue);
|
|
1041
|
+
});
|
|
1042
|
+
return function () {
|
|
1043
|
+
window.removeEventListener('keydown', function (e) {
|
|
1044
|
+
return handleUserKeyPress(e, onContinue);
|
|
1045
|
+
});
|
|
1046
|
+
};
|
|
1047
|
+
}, []);
|
|
1048
|
+
|
|
1015
1049
|
var handleContinue = /*#__PURE__*/function () {
|
|
1016
1050
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
1017
|
-
var
|
|
1018
|
-
|
|
1051
|
+
var response;
|
|
1019
1052
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1020
1053
|
while (1) {
|
|
1021
1054
|
switch (_context.prev = _context.next) {
|
|
1022
1055
|
case 0:
|
|
1023
1056
|
setLoading(true);
|
|
1024
1057
|
|
|
1025
|
-
if (!
|
|
1058
|
+
if (!authRequestId) {
|
|
1026
1059
|
_context.next = 6;
|
|
1027
1060
|
break;
|
|
1028
1061
|
}
|
|
1029
1062
|
|
|
1030
1063
|
_context.next = 4;
|
|
1031
|
-
return authUser(
|
|
1064
|
+
return authUser({
|
|
1065
|
+
authRequestId: authRequestId,
|
|
1066
|
+
test: test
|
|
1067
|
+
});
|
|
1032
1068
|
|
|
1033
1069
|
case 4:
|
|
1034
1070
|
response = _context.sent;
|
|
1035
1071
|
|
|
1036
|
-
if (
|
|
1072
|
+
if (response != null && response.ok) {
|
|
1037
1073
|
setLoading(false);
|
|
1038
1074
|
onContinue();
|
|
1075
|
+
} else {
|
|
1076
|
+
showErrorScreen(response == null ? void 0 : response.statusCode.toString());
|
|
1039
1077
|
}
|
|
1040
1078
|
|
|
1041
1079
|
case 6:
|
|
@@ -1095,9 +1133,13 @@ function StartScreen(props) {
|
|
|
1095
1133
|
bold: React.createElement("strong", null)
|
|
1096
1134
|
}
|
|
1097
1135
|
}))), 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", {
|
|
1098
|
-
href: "https://docs.basiq.io/en/articles/415750-basiq-terms-of-service"
|
|
1136
|
+
href: "https://docs.basiq.io/en/articles/415750-basiq-terms-of-service",
|
|
1137
|
+
rel: "noreferrer",
|
|
1138
|
+
target: "_blank"
|
|
1099
1139
|
}, t('terms_of_service')), " ", t('and'), ' ', React.createElement("a", {
|
|
1100
|
-
href: "https://docs.basiq.io/en/articles/382581-basiq-privacy-policy"
|
|
1140
|
+
href: "https://docs.basiq.io/en/articles/382581-basiq-privacy-policy",
|
|
1141
|
+
rel: "noreferrer",
|
|
1142
|
+
target: "_blank"
|
|
1101
1143
|
}, t('privacy_notice')))), React.createElement(LoadingModal, {
|
|
1102
1144
|
isOpen: loading
|
|
1103
1145
|
})));
|
|
@@ -1106,8 +1148,9 @@ function StartScreen(props) {
|
|
|
1106
1148
|
function AuthScreen(_ref) {
|
|
1107
1149
|
var onBack = _ref.onBack,
|
|
1108
1150
|
number = _ref.number,
|
|
1109
|
-
|
|
1110
|
-
shadow = _ref.shadow
|
|
1151
|
+
authRequestId = _ref.authRequestId,
|
|
1152
|
+
shadow = _ref.shadow,
|
|
1153
|
+
test = _ref.test;
|
|
1111
1154
|
|
|
1112
1155
|
var _useTranslation = useTranslation(),
|
|
1113
1156
|
t = _useTranslation.t;
|
|
@@ -1117,8 +1160,8 @@ function AuthScreen(_ref) {
|
|
|
1117
1160
|
setError = _useState[1];
|
|
1118
1161
|
|
|
1119
1162
|
var _useState2 = useState(''),
|
|
1120
|
-
|
|
1121
|
-
|
|
1163
|
+
smsCode = _useState2[0],
|
|
1164
|
+
setSmsCode = _useState2[1];
|
|
1122
1165
|
|
|
1123
1166
|
var _useState3 = useState(false),
|
|
1124
1167
|
resend = _useState3[0],
|
|
@@ -1128,29 +1171,36 @@ function AuthScreen(_ref) {
|
|
|
1128
1171
|
loading = _useState4[0],
|
|
1129
1172
|
setLoading = _useState4[1];
|
|
1130
1173
|
|
|
1131
|
-
var handleCodeApply = /*#__PURE__*/function () {
|
|
1132
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
1133
|
-
var _response$data;
|
|
1134
|
-
|
|
1135
|
-
var response, _response$data2;
|
|
1174
|
+
var handleCodeApply = useCallback( /*#__PURE__*/function () {
|
|
1175
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(e) {
|
|
1176
|
+
var _response$data, response, _response$data2;
|
|
1136
1177
|
|
|
1137
1178
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1138
1179
|
while (1) {
|
|
1139
1180
|
switch (_context.prev = _context.next) {
|
|
1140
1181
|
case 0:
|
|
1182
|
+
if (!(smsCode.length === 4 && error.length === 0 && (!e || (e == null ? void 0 : e.charCode) === 13))) {
|
|
1183
|
+
_context.next = 7;
|
|
1184
|
+
break;
|
|
1185
|
+
}
|
|
1186
|
+
|
|
1141
1187
|
setLoading(true);
|
|
1142
|
-
_context.next =
|
|
1143
|
-
return verifySmsCode(
|
|
1188
|
+
_context.next = 4;
|
|
1189
|
+
return verifySmsCode({
|
|
1190
|
+
authRequestId: authRequestId,
|
|
1191
|
+
smsCode: smsCode,
|
|
1192
|
+
test: test
|
|
1193
|
+
});
|
|
1144
1194
|
|
|
1145
|
-
case
|
|
1195
|
+
case 4:
|
|
1146
1196
|
response = _context.sent;
|
|
1147
|
-
setLoading(false);
|
|
1148
1197
|
|
|
1149
1198
|
if (response != null && (_response$data = response.data) != null && _response$data.access_token) {
|
|
1150
|
-
window.open("https://consent.basiq.io/home?token=" + (response == null ? void 0 : (_response$data2 = response.data) == null ? void 0 : _response$data2.access_token));
|
|
1199
|
+
window.open("https://consent.basiq.io/home?token=" + (response == null ? void 0 : (_response$data2 = response.data) == null ? void 0 : _response$data2.access_token), "_self");
|
|
1151
1200
|
}
|
|
1152
1201
|
|
|
1153
1202
|
if (response != null && response.error) {
|
|
1203
|
+
setLoading(false);
|
|
1154
1204
|
setError(t('this_code_doesnt_appear_to_be_valid'));
|
|
1155
1205
|
}
|
|
1156
1206
|
|
|
@@ -1162,16 +1212,16 @@ function AuthScreen(_ref) {
|
|
|
1162
1212
|
}, _callee);
|
|
1163
1213
|
}));
|
|
1164
1214
|
|
|
1165
|
-
return function
|
|
1215
|
+
return function (_x) {
|
|
1166
1216
|
return _ref2.apply(this, arguments);
|
|
1167
1217
|
};
|
|
1168
|
-
}();
|
|
1169
|
-
|
|
1218
|
+
}(), [smsCode, error, authRequestId]);
|
|
1170
1219
|
var buttons = [{
|
|
1171
1220
|
label: t('continue'),
|
|
1172
1221
|
onClick: function onClick() {
|
|
1173
1222
|
return handleCodeApply();
|
|
1174
|
-
}
|
|
1223
|
+
},
|
|
1224
|
+
disabled: smsCode.length < 4 || !!error
|
|
1175
1225
|
}];
|
|
1176
1226
|
|
|
1177
1227
|
var handleResend = /*#__PURE__*/function () {
|
|
@@ -1182,12 +1232,16 @@ function AuthScreen(_ref) {
|
|
|
1182
1232
|
switch (_context2.prev = _context2.next) {
|
|
1183
1233
|
case 0:
|
|
1184
1234
|
setError('');
|
|
1185
|
-
|
|
1235
|
+
setSmsCode('');
|
|
1236
|
+
setResend(false);
|
|
1186
1237
|
setLoading(true);
|
|
1187
|
-
_context2.next =
|
|
1188
|
-
return authUser(
|
|
1238
|
+
_context2.next = 6;
|
|
1239
|
+
return authUser({
|
|
1240
|
+
authRequestId: authRequestId,
|
|
1241
|
+
test: test
|
|
1242
|
+
});
|
|
1189
1243
|
|
|
1190
|
-
case
|
|
1244
|
+
case 6:
|
|
1191
1245
|
response = _context2.sent;
|
|
1192
1246
|
setLoading(false);
|
|
1193
1247
|
|
|
@@ -1197,7 +1251,7 @@ function AuthScreen(_ref) {
|
|
|
1197
1251
|
setResend(true);
|
|
1198
1252
|
}
|
|
1199
1253
|
|
|
1200
|
-
case
|
|
1254
|
+
case 9:
|
|
1201
1255
|
case "end":
|
|
1202
1256
|
return _context2.stop();
|
|
1203
1257
|
}
|
|
@@ -1213,7 +1267,10 @@ function AuthScreen(_ref) {
|
|
|
1213
1267
|
var handleInput = function handleInput(e) {
|
|
1214
1268
|
setError('');
|
|
1215
1269
|
setResend(false);
|
|
1216
|
-
|
|
1270
|
+
|
|
1271
|
+
if (/^([0-9]+)$/.test(e.target.value) || e.target.value === '') {
|
|
1272
|
+
setSmsCode(e.target.value);
|
|
1273
|
+
}
|
|
1217
1274
|
};
|
|
1218
1275
|
|
|
1219
1276
|
return React.createElement(Page, {
|
|
@@ -1231,9 +1288,12 @@ function AuthScreen(_ref) {
|
|
|
1231
1288
|
type: "text",
|
|
1232
1289
|
maxLength: 4,
|
|
1233
1290
|
onChange: handleInput,
|
|
1234
|
-
value:
|
|
1235
|
-
filled:
|
|
1236
|
-
error: !!error
|
|
1291
|
+
value: smsCode,
|
|
1292
|
+
filled: smsCode.length === 4,
|
|
1293
|
+
error: !!error,
|
|
1294
|
+
onKeyPress: function onKeyPress(e) {
|
|
1295
|
+
return handleCodeApply(e);
|
|
1296
|
+
}
|
|
1237
1297
|
})), React.createElement(PageConnectFooterControl, null, resend && React.createElement(StatusMessage, null, t('new_sms_code_has_been_sent')), !!error && React.createElement(StatusMessage, {
|
|
1238
1298
|
error: true
|
|
1239
1299
|
}, error), React.createElement(PageConnectFooterText, null, React.createElement("span", null, React.createElement(React.Fragment, null, t('didnt_receive_the_code'), " ", React.createElement(DivAsLink, {
|
|
@@ -1245,7 +1305,8 @@ function AuthScreen(_ref) {
|
|
|
1245
1305
|
})));
|
|
1246
1306
|
}
|
|
1247
1307
|
|
|
1248
|
-
function App() {
|
|
1308
|
+
function App(props) {
|
|
1309
|
+
var test = props.test;
|
|
1249
1310
|
var ref = createRef();
|
|
1250
1311
|
|
|
1251
1312
|
var _useState = useState(false),
|
|
@@ -1284,10 +1345,15 @@ function App() {
|
|
|
1284
1345
|
setShadow(detectScrollToBottom(event));
|
|
1285
1346
|
};
|
|
1286
1347
|
|
|
1348
|
+
var showErrorScreen = function showErrorScreen(code) {
|
|
1349
|
+
setErrorCode(code);
|
|
1350
|
+
setCurrentScreen(3);
|
|
1351
|
+
};
|
|
1352
|
+
|
|
1287
1353
|
useEffect(function () {
|
|
1288
1354
|
var getData = /*#__PURE__*/function () {
|
|
1289
1355
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
1290
|
-
var id,
|
|
1356
|
+
var id, response, _response$data, _response$data2, _response$data4, _response$data4$partn, _response$data3, _response$data5, _response$data5$partn;
|
|
1291
1357
|
|
|
1292
1358
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1293
1359
|
while (1) {
|
|
@@ -1296,40 +1362,46 @@ function App() {
|
|
|
1296
1362
|
id = window.location.pathname.substring(1);
|
|
1297
1363
|
|
|
1298
1364
|
if (!((id == null ? void 0 : id.length) > 0)) {
|
|
1299
|
-
_context.next =
|
|
1365
|
+
_context.next = 10;
|
|
1300
1366
|
break;
|
|
1301
1367
|
}
|
|
1302
1368
|
|
|
1303
1369
|
setAuthId(id);
|
|
1304
1370
|
setLoading(true);
|
|
1305
1371
|
_context.next = 6;
|
|
1306
|
-
return authUser(
|
|
1372
|
+
return authUser({
|
|
1373
|
+
authRequestId: id,
|
|
1374
|
+
method: 'GET',
|
|
1375
|
+
test: test
|
|
1376
|
+
});
|
|
1307
1377
|
|
|
1308
1378
|
case 6:
|
|
1309
1379
|
response = _context.sent;
|
|
1310
1380
|
|
|
1311
|
-
if (
|
|
1381
|
+
if (response != null && response.ok) {
|
|
1312
1382
|
setCurrentScreen(1);
|
|
1313
|
-
setMobile(response == null ? void 0 : (_response$
|
|
1383
|
+
setMobile(response == null ? void 0 : (_response$data = response.data) == null ? void 0 : _response$data.mobile);
|
|
1314
1384
|
|
|
1315
|
-
if (response != null && (_response$
|
|
1316
|
-
setAppName(response == null ? void 0 : (_response$
|
|
1385
|
+
if (response != null && (_response$data2 = response.data) != null && _response$data2.appName) {
|
|
1386
|
+
setAppName(response == null ? void 0 : (_response$data3 = response.data) == null ? void 0 : _response$data3.appName);
|
|
1317
1387
|
}
|
|
1318
1388
|
|
|
1319
|
-
if (response != null && (_response$
|
|
1320
|
-
setLogo(response == null ? void 0 : (_response$
|
|
1389
|
+
if (response != null && (_response$data4 = response.data) != null && (_response$data4$partn = _response$data4.partner) != null && _response$data4$partn.logoUrl) {
|
|
1390
|
+
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);
|
|
1321
1391
|
}
|
|
1322
1392
|
} else {
|
|
1323
1393
|
showErrorScreen(response == null ? void 0 : response.statusCode.toString());
|
|
1324
1394
|
}
|
|
1325
1395
|
|
|
1326
|
-
|
|
1327
|
-
_context.next = 12;
|
|
1396
|
+
_context.next = 11;
|
|
1328
1397
|
break;
|
|
1329
1398
|
|
|
1330
|
-
case
|
|
1399
|
+
case 10:
|
|
1331
1400
|
showErrorScreen('404');
|
|
1332
1401
|
|
|
1402
|
+
case 11:
|
|
1403
|
+
setLoading(false);
|
|
1404
|
+
|
|
1333
1405
|
case 12:
|
|
1334
1406
|
case "end":
|
|
1335
1407
|
return _context.stop();
|
|
@@ -1346,11 +1418,6 @@ function App() {
|
|
|
1346
1418
|
getData();
|
|
1347
1419
|
}, []);
|
|
1348
1420
|
|
|
1349
|
-
var showErrorScreen = function showErrorScreen(code) {
|
|
1350
|
-
setErrorCode(code);
|
|
1351
|
-
setCurrentScreen(3);
|
|
1352
|
-
};
|
|
1353
|
-
|
|
1354
1421
|
var getScreen = function getScreen() {
|
|
1355
1422
|
switch (currentScreen) {
|
|
1356
1423
|
case 0:
|
|
@@ -1369,7 +1436,8 @@ function App() {
|
|
|
1369
1436
|
onContinue: function onContinue() {
|
|
1370
1437
|
return setCurrentScreen(2);
|
|
1371
1438
|
},
|
|
1372
|
-
|
|
1439
|
+
authRequestId: authId,
|
|
1440
|
+
test: test
|
|
1373
1441
|
});
|
|
1374
1442
|
|
|
1375
1443
|
case 2:
|
|
@@ -1379,7 +1447,8 @@ function App() {
|
|
|
1379
1447
|
return setCurrentScreen(1);
|
|
1380
1448
|
},
|
|
1381
1449
|
shadow: shadow,
|
|
1382
|
-
|
|
1450
|
+
authRequestId: authId,
|
|
1451
|
+
test: test
|
|
1383
1452
|
});
|
|
1384
1453
|
|
|
1385
1454
|
case 3:
|
|
@@ -1476,10 +1545,13 @@ i18n.use(initReactI18next) // passes i18n down to react-i18next
|
|
|
1476
1545
|
}
|
|
1477
1546
|
});
|
|
1478
1547
|
|
|
1479
|
-
function BasiqConnect() {
|
|
1548
|
+
function BasiqConnect(props) {
|
|
1549
|
+
var test = props.test;
|
|
1480
1550
|
return React.createElement(React.StrictMode, null, React.createElement(ThemeProvider, {
|
|
1481
1551
|
theme: theme
|
|
1482
|
-
}, React.createElement(App,
|
|
1552
|
+
}, React.createElement(App, {
|
|
1553
|
+
test: test
|
|
1554
|
+
})));
|
|
1483
1555
|
}
|
|
1484
1556
|
|
|
1485
1557
|
export { BasiqConnect };
|