@basiq/connect-auth 0.1.87 → 0.1.91
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 +16 -2
- package/dist/components/BasiqConnect.d.ts +4 -1
- 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 +184 -114
- 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 +185 -115
- 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/styledComponents/pages/auth.d.ts +4 -1
- package/package.json +1 -1
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
|
};
|
|
@@ -626,13 +633,17 @@ var InputStyled = /*#__PURE__*/styled.input(_templateObject3$3 || (_templateObje
|
|
|
626
633
|
return error ? theme.color.cerise : theme.color.endeavour;
|
|
627
634
|
});
|
|
628
635
|
var InputContainer = /*#__PURE__*/styled.div(_templateObject4$3 || (_templateObject4$3 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n\twidth: 100%;\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: center;\n"])));
|
|
629
|
-
var DivAsLink = /*#__PURE__*/styled.div(_templateObject5$3 || (_templateObject5$3 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n\tcolor: ", ";\n\tdisplay: inherit;\n\tcursor:
|
|
630
|
-
var theme = _ref4.theme
|
|
631
|
-
|
|
636
|
+
var DivAsLink = /*#__PURE__*/styled.div(_templateObject5$3 || (_templateObject5$3 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n\tcolor: ", ";\n\tdisplay: inherit;\n\tcursor: ", ";\n"])), function (_ref4) {
|
|
637
|
+
var theme = _ref4.theme,
|
|
638
|
+
disabled = _ref4.disabled;
|
|
639
|
+
return disabled ? theme.color.casper : theme.color.endeavour;
|
|
640
|
+
}, function (_ref5) {
|
|
641
|
+
var disabled = _ref5.disabled;
|
|
642
|
+
return disabled ? 'not-allowed' : 'pointer';
|
|
632
643
|
});
|
|
633
644
|
|
|
634
645
|
var _templateObject$5;
|
|
635
|
-
var InnerContainer = /*#__PURE__*/styled.div(_templateObject$5 || (_templateObject$5 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n\
|
|
646
|
+
var InnerContainer = /*#__PURE__*/styled.div(_templateObject$5 || (_templateObject$5 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n\twidth: 100%;\n"])));
|
|
636
647
|
|
|
637
648
|
var _templateObject$6, _templateObject2$5, _templateObject3$4, _templateObject4$4;
|
|
638
649
|
var PageStatusScreenMain = /*#__PURE__*/styled(PageMainContainer)(_templateObject$6 || (_templateObject$6 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n\theight: 100%;\n"])));
|
|
@@ -691,7 +702,7 @@ var MarkW1GBold = "data:font/otf;base64,T1RUTwANAIAAAwBQQ0ZGICwMZMIAACp0AAFDmERT
|
|
|
691
702
|
var _templateObject$8;
|
|
692
703
|
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
704
|
|
|
694
|
-
var img = "data:image/svg+xml,%
|
|
705
|
+
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
706
|
|
|
696
707
|
function Button(props) {
|
|
697
708
|
var onClick = props.onClick,
|
|
@@ -773,12 +784,13 @@ function NotFound(_ref) {
|
|
|
773
784
|
}
|
|
774
785
|
|
|
775
786
|
var verifySmsCode = /*#__PURE__*/function () {
|
|
776
|
-
var
|
|
777
|
-
var body, reqData, result, json;
|
|
787
|
+
var _ref2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
|
|
788
|
+
var authRequestId, smsCode, test, body, reqData, result, json;
|
|
778
789
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
779
790
|
while (1) {
|
|
780
791
|
switch (_context.prev = _context.next) {
|
|
781
792
|
case 0:
|
|
793
|
+
authRequestId = _ref.authRequestId, smsCode = _ref.smsCode, test = _ref.test;
|
|
782
794
|
body = {
|
|
783
795
|
'sms-code': smsCode
|
|
784
796
|
};
|
|
@@ -790,34 +802,34 @@ var verifySmsCode = /*#__PURE__*/function () {
|
|
|
790
802
|
method: 'POST',
|
|
791
803
|
body: JSON.stringify(body)
|
|
792
804
|
};
|
|
793
|
-
_context.next =
|
|
794
|
-
return fetch(DASHBOARD_API_URL + "client_auth/" + authRequestId + "/token", reqData);
|
|
805
|
+
_context.next = 5;
|
|
806
|
+
return fetch((test ? DASHBOARD_API_URL_TEST : DASHBOARD_API_URL) + "client_auth/" + authRequestId + "/token", reqData);
|
|
795
807
|
|
|
796
|
-
case
|
|
808
|
+
case 5:
|
|
797
809
|
result = _context.sent;
|
|
798
810
|
|
|
799
811
|
if (!(result.status >= 200 && result.status < 300)) {
|
|
800
|
-
_context.next =
|
|
812
|
+
_context.next = 16;
|
|
801
813
|
break;
|
|
802
814
|
}
|
|
803
815
|
|
|
804
816
|
if (!(result.status === 204)) {
|
|
805
|
-
_context.next =
|
|
817
|
+
_context.next = 11;
|
|
806
818
|
break;
|
|
807
819
|
}
|
|
808
820
|
|
|
809
821
|
_context.t0 = null;
|
|
810
|
-
_context.next =
|
|
822
|
+
_context.next = 14;
|
|
811
823
|
break;
|
|
812
824
|
|
|
813
|
-
case
|
|
814
|
-
_context.next =
|
|
825
|
+
case 11:
|
|
826
|
+
_context.next = 13;
|
|
815
827
|
return result.json();
|
|
816
828
|
|
|
817
|
-
case
|
|
829
|
+
case 13:
|
|
818
830
|
_context.t0 = _context.sent;
|
|
819
831
|
|
|
820
|
-
case
|
|
832
|
+
case 14:
|
|
821
833
|
json = _context.t0;
|
|
822
834
|
return _context.abrupt("return", {
|
|
823
835
|
data: json,
|
|
@@ -826,9 +838,9 @@ var verifySmsCode = /*#__PURE__*/function () {
|
|
|
826
838
|
ok: true
|
|
827
839
|
});
|
|
828
840
|
|
|
829
|
-
case
|
|
841
|
+
case 16:
|
|
830
842
|
if (!(result.status >= 400)) {
|
|
831
|
-
_context.next =
|
|
843
|
+
_context.next = 18;
|
|
832
844
|
break;
|
|
833
845
|
}
|
|
834
846
|
|
|
@@ -839,7 +851,7 @@ var verifySmsCode = /*#__PURE__*/function () {
|
|
|
839
851
|
ok: false
|
|
840
852
|
});
|
|
841
853
|
|
|
842
|
-
case
|
|
854
|
+
case 18:
|
|
843
855
|
return _context.abrupt("return", {
|
|
844
856
|
headers: result.headers,
|
|
845
857
|
statusCode: result.status,
|
|
@@ -847,7 +859,7 @@ var verifySmsCode = /*#__PURE__*/function () {
|
|
|
847
859
|
ok: false
|
|
848
860
|
});
|
|
849
861
|
|
|
850
|
-
case
|
|
862
|
+
case 19:
|
|
851
863
|
case "end":
|
|
852
864
|
return _context.stop();
|
|
853
865
|
}
|
|
@@ -855,56 +867,54 @@ var verifySmsCode = /*#__PURE__*/function () {
|
|
|
855
867
|
}, _callee);
|
|
856
868
|
}));
|
|
857
869
|
|
|
858
|
-
return function verifySmsCode(_x
|
|
859
|
-
return
|
|
870
|
+
return function verifySmsCode(_x) {
|
|
871
|
+
return _ref2.apply(this, arguments);
|
|
860
872
|
};
|
|
861
873
|
}();
|
|
862
874
|
var authUser = /*#__PURE__*/function () {
|
|
863
|
-
var
|
|
864
|
-
var reqData, result, json, _json;
|
|
875
|
+
var _ref4 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref3) {
|
|
876
|
+
var authRequestId, method, test, reqData, result, json, _json;
|
|
865
877
|
|
|
866
878
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
867
879
|
while (1) {
|
|
868
880
|
switch (_context2.prev = _context2.next) {
|
|
869
881
|
case 0:
|
|
870
|
-
|
|
871
|
-
method = 'POST';
|
|
872
|
-
}
|
|
873
|
-
|
|
882
|
+
authRequestId = _ref3.authRequestId, method = _ref3.method, test = _ref3.test;
|
|
874
883
|
reqData = {
|
|
875
884
|
headers: {
|
|
876
885
|
'Content-Type': 'application/json'
|
|
877
886
|
},
|
|
878
|
-
method: method
|
|
887
|
+
method: method || 'POST'
|
|
879
888
|
};
|
|
880
|
-
_context2.
|
|
881
|
-
|
|
889
|
+
_context2.prev = 2;
|
|
890
|
+
_context2.next = 5;
|
|
891
|
+
return fetch((test ? DASHBOARD_API_URL_TEST : DASHBOARD_API_URL) + "client_auth/" + authRequestId, reqData);
|
|
882
892
|
|
|
883
|
-
case
|
|
893
|
+
case 5:
|
|
884
894
|
result = _context2.sent;
|
|
885
895
|
|
|
886
896
|
if (!(result.status >= 200 && result.status < 300)) {
|
|
887
|
-
_context2.next =
|
|
897
|
+
_context2.next = 16;
|
|
888
898
|
break;
|
|
889
899
|
}
|
|
890
900
|
|
|
891
901
|
if (!(result.status === 204)) {
|
|
892
|
-
_context2.next =
|
|
902
|
+
_context2.next = 11;
|
|
893
903
|
break;
|
|
894
904
|
}
|
|
895
905
|
|
|
896
906
|
_context2.t0 = null;
|
|
897
|
-
_context2.next =
|
|
907
|
+
_context2.next = 14;
|
|
898
908
|
break;
|
|
899
909
|
|
|
900
|
-
case
|
|
901
|
-
_context2.next =
|
|
910
|
+
case 11:
|
|
911
|
+
_context2.next = 13;
|
|
902
912
|
return result.json();
|
|
903
913
|
|
|
904
|
-
case
|
|
914
|
+
case 13:
|
|
905
915
|
_context2.t0 = _context2.sent;
|
|
906
916
|
|
|
907
|
-
case
|
|
917
|
+
case 14:
|
|
908
918
|
json = _context2.t0;
|
|
909
919
|
return _context2.abrupt("return", {
|
|
910
920
|
data: json,
|
|
@@ -913,29 +923,29 @@ var authUser = /*#__PURE__*/function () {
|
|
|
913
923
|
ok: true
|
|
914
924
|
});
|
|
915
925
|
|
|
916
|
-
case
|
|
926
|
+
case 16:
|
|
917
927
|
if (!(result.status >= 400)) {
|
|
918
|
-
_context2.next =
|
|
928
|
+
_context2.next = 26;
|
|
919
929
|
break;
|
|
920
930
|
}
|
|
921
931
|
|
|
922
932
|
if (![403, 404].includes(result.status)) {
|
|
923
|
-
_context2.next =
|
|
933
|
+
_context2.next = 21;
|
|
924
934
|
break;
|
|
925
935
|
}
|
|
926
936
|
|
|
927
937
|
_context2.t1 = null;
|
|
928
|
-
_context2.next =
|
|
938
|
+
_context2.next = 24;
|
|
929
939
|
break;
|
|
930
940
|
|
|
931
|
-
case
|
|
932
|
-
_context2.next =
|
|
941
|
+
case 21:
|
|
942
|
+
_context2.next = 23;
|
|
933
943
|
return result.json();
|
|
934
944
|
|
|
935
|
-
case
|
|
945
|
+
case 23:
|
|
936
946
|
_context2.t1 = _context2.sent;
|
|
937
947
|
|
|
938
|
-
case
|
|
948
|
+
case 24:
|
|
939
949
|
_json = _context2.t1;
|
|
940
950
|
return _context2.abrupt("return", {
|
|
941
951
|
headers: result.headers,
|
|
@@ -944,7 +954,7 @@ var authUser = /*#__PURE__*/function () {
|
|
|
944
954
|
ok: false
|
|
945
955
|
});
|
|
946
956
|
|
|
947
|
-
case
|
|
957
|
+
case 26:
|
|
948
958
|
return _context2.abrupt("return", {
|
|
949
959
|
headers: result.headers,
|
|
950
960
|
statusCode: result.status,
|
|
@@ -952,16 +962,25 @@ var authUser = /*#__PURE__*/function () {
|
|
|
952
962
|
ok: false
|
|
953
963
|
});
|
|
954
964
|
|
|
955
|
-
case
|
|
965
|
+
case 29:
|
|
966
|
+
_context2.prev = 29;
|
|
967
|
+
_context2.t2 = _context2["catch"](2);
|
|
968
|
+
return _context2.abrupt("return", {
|
|
969
|
+
statusCode: 500,
|
|
970
|
+
error: 'Something went wrong',
|
|
971
|
+
ok: false
|
|
972
|
+
});
|
|
973
|
+
|
|
974
|
+
case 32:
|
|
956
975
|
case "end":
|
|
957
976
|
return _context2.stop();
|
|
958
977
|
}
|
|
959
978
|
}
|
|
960
|
-
}, _callee2);
|
|
979
|
+
}, _callee2, null, [[2, 29]]);
|
|
961
980
|
}));
|
|
962
981
|
|
|
963
|
-
return function authUser(
|
|
964
|
-
return
|
|
982
|
+
return function authUser(_x2) {
|
|
983
|
+
return _ref4.apply(this, arguments);
|
|
965
984
|
};
|
|
966
985
|
}();
|
|
967
986
|
|
|
@@ -1009,8 +1028,9 @@ function StartScreen(props) {
|
|
|
1009
1028
|
var onContinue = props.onContinue,
|
|
1010
1029
|
appName = props.appName,
|
|
1011
1030
|
shadow = props.shadow,
|
|
1012
|
-
|
|
1013
|
-
showErrorScreen = props.showErrorScreen
|
|
1031
|
+
authRequestId = props.authRequestId,
|
|
1032
|
+
showErrorScreen = props.showErrorScreen,
|
|
1033
|
+
test = props.test;
|
|
1014
1034
|
|
|
1015
1035
|
var _useState = useState(false),
|
|
1016
1036
|
loading = _useState[0],
|
|
@@ -1019,28 +1039,41 @@ function StartScreen(props) {
|
|
|
1019
1039
|
var _useTranslation = useTranslation(),
|
|
1020
1040
|
t = _useTranslation.t;
|
|
1021
1041
|
|
|
1042
|
+
useEffect(function () {
|
|
1043
|
+
window.addEventListener('keydown', function (e) {
|
|
1044
|
+
return handleUserKeyPress(e, onContinue);
|
|
1045
|
+
});
|
|
1046
|
+
return function () {
|
|
1047
|
+
window.removeEventListener('keydown', function (e) {
|
|
1048
|
+
return handleUserKeyPress(e, onContinue);
|
|
1049
|
+
});
|
|
1050
|
+
};
|
|
1051
|
+
}, []);
|
|
1052
|
+
|
|
1022
1053
|
var handleContinue = /*#__PURE__*/function () {
|
|
1023
1054
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
1024
|
-
var
|
|
1025
|
-
|
|
1055
|
+
var response;
|
|
1026
1056
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1027
1057
|
while (1) {
|
|
1028
1058
|
switch (_context.prev = _context.next) {
|
|
1029
1059
|
case 0:
|
|
1030
1060
|
setLoading(true);
|
|
1031
1061
|
|
|
1032
|
-
if (!
|
|
1062
|
+
if (!authRequestId) {
|
|
1033
1063
|
_context.next = 6;
|
|
1034
1064
|
break;
|
|
1035
1065
|
}
|
|
1036
1066
|
|
|
1037
1067
|
_context.next = 4;
|
|
1038
|
-
return authUser(
|
|
1068
|
+
return authUser({
|
|
1069
|
+
authRequestId: authRequestId,
|
|
1070
|
+
test: test
|
|
1071
|
+
});
|
|
1039
1072
|
|
|
1040
1073
|
case 4:
|
|
1041
1074
|
response = _context.sent;
|
|
1042
1075
|
|
|
1043
|
-
if (response != null &&
|
|
1076
|
+
if (response != null && response.ok) {
|
|
1044
1077
|
setLoading(false);
|
|
1045
1078
|
onContinue();
|
|
1046
1079
|
} else {
|
|
@@ -1104,9 +1137,13 @@ function StartScreen(props) {
|
|
|
1104
1137
|
bold: React.createElement("strong", null)
|
|
1105
1138
|
}
|
|
1106
1139
|
}))), 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", {
|
|
1107
|
-
href: "https://docs.basiq.io/en/articles/415750-basiq-terms-of-service"
|
|
1140
|
+
href: "https://docs.basiq.io/en/articles/415750-basiq-terms-of-service",
|
|
1141
|
+
rel: "noreferrer",
|
|
1142
|
+
target: "_blank"
|
|
1108
1143
|
}, t('terms_of_service')), " ", t('and'), ' ', React.createElement("a", {
|
|
1109
|
-
href: "https://docs.basiq.io/en/articles/382581-basiq-privacy-policy"
|
|
1144
|
+
href: "https://docs.basiq.io/en/articles/382581-basiq-privacy-policy",
|
|
1145
|
+
rel: "noreferrer",
|
|
1146
|
+
target: "_blank"
|
|
1110
1147
|
}, t('privacy_notice')))), React.createElement(LoadingModal, {
|
|
1111
1148
|
isOpen: loading
|
|
1112
1149
|
})));
|
|
@@ -1115,8 +1152,9 @@ function StartScreen(props) {
|
|
|
1115
1152
|
function AuthScreen(_ref) {
|
|
1116
1153
|
var onBack = _ref.onBack,
|
|
1117
1154
|
number = _ref.number,
|
|
1118
|
-
|
|
1119
|
-
shadow = _ref.shadow
|
|
1155
|
+
authRequestId = _ref.authRequestId,
|
|
1156
|
+
shadow = _ref.shadow,
|
|
1157
|
+
test = _ref.test;
|
|
1120
1158
|
|
|
1121
1159
|
var _useTranslation = useTranslation(),
|
|
1122
1160
|
t = _useTranslation.t;
|
|
@@ -1126,40 +1164,51 @@ function AuthScreen(_ref) {
|
|
|
1126
1164
|
setError = _useState[1];
|
|
1127
1165
|
|
|
1128
1166
|
var _useState2 = useState(''),
|
|
1129
|
-
|
|
1130
|
-
|
|
1167
|
+
smsCode = _useState2[0],
|
|
1168
|
+
setSmsCode = _useState2[1];
|
|
1131
1169
|
|
|
1132
1170
|
var _useState3 = useState(false),
|
|
1133
1171
|
resend = _useState3[0],
|
|
1134
1172
|
setResend = _useState3[1];
|
|
1135
1173
|
|
|
1136
1174
|
var _useState4 = useState(false),
|
|
1137
|
-
|
|
1138
|
-
|
|
1175
|
+
resendLoading = _useState4[0],
|
|
1176
|
+
setResendLoading = _useState4[1];
|
|
1139
1177
|
|
|
1140
|
-
var
|
|
1141
|
-
|
|
1142
|
-
|
|
1178
|
+
var _useState5 = useState(false),
|
|
1179
|
+
loading = _useState5[0],
|
|
1180
|
+
setLoading = _useState5[1];
|
|
1143
1181
|
|
|
1144
|
-
|
|
1182
|
+
var handleCodeApply = useCallback( /*#__PURE__*/function () {
|
|
1183
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(e) {
|
|
1184
|
+
var _response$data, response, _response$data2;
|
|
1145
1185
|
|
|
1146
1186
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1147
1187
|
while (1) {
|
|
1148
1188
|
switch (_context.prev = _context.next) {
|
|
1149
1189
|
case 0:
|
|
1190
|
+
if (!(smsCode.length === 4 && error.length === 0 && (!e || (e == null ? void 0 : e.charCode) === 13))) {
|
|
1191
|
+
_context.next = 7;
|
|
1192
|
+
break;
|
|
1193
|
+
}
|
|
1194
|
+
|
|
1150
1195
|
setLoading(true);
|
|
1151
|
-
_context.next =
|
|
1152
|
-
return verifySmsCode(
|
|
1196
|
+
_context.next = 4;
|
|
1197
|
+
return verifySmsCode({
|
|
1198
|
+
authRequestId: authRequestId,
|
|
1199
|
+
smsCode: smsCode,
|
|
1200
|
+
test: test
|
|
1201
|
+
});
|
|
1153
1202
|
|
|
1154
|
-
case
|
|
1203
|
+
case 4:
|
|
1155
1204
|
response = _context.sent;
|
|
1156
|
-
setLoading(false);
|
|
1157
1205
|
|
|
1158
1206
|
if (response != null && (_response$data = response.data) != null && _response$data.access_token) {
|
|
1159
|
-
window.open("https://consent.basiq.io/home?token=" + (response == null ? void 0 : (_response$data2 = response.data) == null ? void 0 : _response$data2.access_token));
|
|
1207
|
+
window.open("https://consent.basiq.io/home?token=" + (response == null ? void 0 : (_response$data2 = response.data) == null ? void 0 : _response$data2.access_token), "_self");
|
|
1160
1208
|
}
|
|
1161
1209
|
|
|
1162
1210
|
if (response != null && response.error) {
|
|
1211
|
+
setLoading(false);
|
|
1163
1212
|
setError(t('this_code_doesnt_appear_to_be_valid'));
|
|
1164
1213
|
}
|
|
1165
1214
|
|
|
@@ -1171,16 +1220,16 @@ function AuthScreen(_ref) {
|
|
|
1171
1220
|
}, _callee);
|
|
1172
1221
|
}));
|
|
1173
1222
|
|
|
1174
|
-
return function
|
|
1223
|
+
return function (_x) {
|
|
1175
1224
|
return _ref2.apply(this, arguments);
|
|
1176
1225
|
};
|
|
1177
|
-
}();
|
|
1178
|
-
|
|
1226
|
+
}(), [smsCode, error, authRequestId]);
|
|
1179
1227
|
var buttons = [{
|
|
1180
1228
|
label: t('continue'),
|
|
1181
1229
|
onClick: function onClick() {
|
|
1182
1230
|
return handleCodeApply();
|
|
1183
|
-
}
|
|
1231
|
+
},
|
|
1232
|
+
disabled: smsCode.length < 4 || !!error
|
|
1184
1233
|
}];
|
|
1185
1234
|
|
|
1186
1235
|
var handleResend = /*#__PURE__*/function () {
|
|
@@ -1191,14 +1240,18 @@ function AuthScreen(_ref) {
|
|
|
1191
1240
|
switch (_context2.prev = _context2.next) {
|
|
1192
1241
|
case 0:
|
|
1193
1242
|
setError('');
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1243
|
+
setSmsCode('');
|
|
1244
|
+
setResend(false);
|
|
1245
|
+
setResendLoading(true);
|
|
1246
|
+
_context2.next = 6;
|
|
1247
|
+
return authUser({
|
|
1248
|
+
authRequestId: authRequestId,
|
|
1249
|
+
test: test
|
|
1250
|
+
});
|
|
1198
1251
|
|
|
1199
|
-
case
|
|
1252
|
+
case 6:
|
|
1200
1253
|
response = _context2.sent;
|
|
1201
|
-
|
|
1254
|
+
setResendLoading(false);
|
|
1202
1255
|
|
|
1203
1256
|
if (response.error) {
|
|
1204
1257
|
setError(t('failed_to_send_sms'));
|
|
@@ -1206,7 +1259,7 @@ function AuthScreen(_ref) {
|
|
|
1206
1259
|
setResend(true);
|
|
1207
1260
|
}
|
|
1208
1261
|
|
|
1209
|
-
case
|
|
1262
|
+
case 9:
|
|
1210
1263
|
case "end":
|
|
1211
1264
|
return _context2.stop();
|
|
1212
1265
|
}
|
|
@@ -1222,7 +1275,10 @@ function AuthScreen(_ref) {
|
|
|
1222
1275
|
var handleInput = function handleInput(e) {
|
|
1223
1276
|
setError('');
|
|
1224
1277
|
setResend(false);
|
|
1225
|
-
|
|
1278
|
+
|
|
1279
|
+
if (/^([0-9]+)$/.test(e.target.value) || e.target.value === '') {
|
|
1280
|
+
setSmsCode(e.target.value);
|
|
1281
|
+
}
|
|
1226
1282
|
};
|
|
1227
1283
|
|
|
1228
1284
|
return React.createElement(Page, {
|
|
@@ -1240,21 +1296,26 @@ function AuthScreen(_ref) {
|
|
|
1240
1296
|
type: "text",
|
|
1241
1297
|
maxLength: 4,
|
|
1242
1298
|
onChange: handleInput,
|
|
1243
|
-
value:
|
|
1244
|
-
filled:
|
|
1245
|
-
error: !!error
|
|
1299
|
+
value: smsCode,
|
|
1300
|
+
filled: smsCode.length === 4,
|
|
1301
|
+
error: !!error,
|
|
1302
|
+
onKeyPress: function onKeyPress(e) {
|
|
1303
|
+
return handleCodeApply(e);
|
|
1304
|
+
}
|
|
1246
1305
|
})), React.createElement(PageConnectFooterControl, null, resend && React.createElement(StatusMessage, null, t('new_sms_code_has_been_sent')), !!error && React.createElement(StatusMessage, {
|
|
1247
1306
|
error: true
|
|
1248
1307
|
}, error), React.createElement(PageConnectFooterText, null, React.createElement("span", null, React.createElement(React.Fragment, null, t('didnt_receive_the_code'), " ", React.createElement(DivAsLink, {
|
|
1308
|
+
disabled: resendLoading,
|
|
1249
1309
|
onClick: function onClick() {
|
|
1250
|
-
return handleResend();
|
|
1310
|
+
return !resendLoading && handleResend();
|
|
1251
1311
|
}
|
|
1252
1312
|
}, t('resend_sms')))))), React.createElement(LoadingModal, {
|
|
1253
1313
|
isOpen: loading
|
|
1254
1314
|
})));
|
|
1255
1315
|
}
|
|
1256
1316
|
|
|
1257
|
-
function App() {
|
|
1317
|
+
function App(props) {
|
|
1318
|
+
var test = props.test;
|
|
1258
1319
|
var ref = createRef();
|
|
1259
1320
|
|
|
1260
1321
|
var _useState = useState(false),
|
|
@@ -1293,10 +1354,15 @@ function App() {
|
|
|
1293
1354
|
setShadow(detectScrollToBottom(event));
|
|
1294
1355
|
};
|
|
1295
1356
|
|
|
1357
|
+
var showErrorScreen = function showErrorScreen(code) {
|
|
1358
|
+
setErrorCode(code);
|
|
1359
|
+
setCurrentScreen(3);
|
|
1360
|
+
};
|
|
1361
|
+
|
|
1296
1362
|
useEffect(function () {
|
|
1297
1363
|
var getData = /*#__PURE__*/function () {
|
|
1298
1364
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
1299
|
-
var id,
|
|
1365
|
+
var id, response, _response$data, _response$data2, _response$data4, _response$data4$partn, _response$data3, _response$data5, _response$data5$partn;
|
|
1300
1366
|
|
|
1301
1367
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1302
1368
|
while (1) {
|
|
@@ -1312,21 +1378,25 @@ function App() {
|
|
|
1312
1378
|
setAuthId(id);
|
|
1313
1379
|
setLoading(true);
|
|
1314
1380
|
_context.next = 6;
|
|
1315
|
-
return authUser(
|
|
1381
|
+
return authUser({
|
|
1382
|
+
authRequestId: id,
|
|
1383
|
+
method: 'GET',
|
|
1384
|
+
test: test
|
|
1385
|
+
});
|
|
1316
1386
|
|
|
1317
1387
|
case 6:
|
|
1318
1388
|
response = _context.sent;
|
|
1319
1389
|
|
|
1320
|
-
if (response != null &&
|
|
1390
|
+
if (response != null && response.ok) {
|
|
1321
1391
|
setCurrentScreen(1);
|
|
1322
|
-
setMobile(response == null ? void 0 : (_response$
|
|
1392
|
+
setMobile(response == null ? void 0 : (_response$data = response.data) == null ? void 0 : _response$data.mobile);
|
|
1323
1393
|
|
|
1324
|
-
if (response != null && (_response$
|
|
1325
|
-
setAppName(response == null ? void 0 : (_response$
|
|
1394
|
+
if (response != null && (_response$data2 = response.data) != null && _response$data2.appName) {
|
|
1395
|
+
setAppName(response == null ? void 0 : (_response$data3 = response.data) == null ? void 0 : _response$data3.appName);
|
|
1326
1396
|
}
|
|
1327
1397
|
|
|
1328
|
-
if (response != null && (_response$
|
|
1329
|
-
setLogo(response == null ? void 0 : (_response$
|
|
1398
|
+
if (response != null && (_response$data4 = response.data) != null && (_response$data4$partn = _response$data4.partner) != null && _response$data4$partn.logoUrl) {
|
|
1399
|
+
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);
|
|
1330
1400
|
}
|
|
1331
1401
|
} else {
|
|
1332
1402
|
showErrorScreen(response == null ? void 0 : response.statusCode.toString());
|
|
@@ -1357,11 +1427,6 @@ function App() {
|
|
|
1357
1427
|
getData();
|
|
1358
1428
|
}, []);
|
|
1359
1429
|
|
|
1360
|
-
var showErrorScreen = function showErrorScreen(code) {
|
|
1361
|
-
setErrorCode(code);
|
|
1362
|
-
setCurrentScreen(3);
|
|
1363
|
-
};
|
|
1364
|
-
|
|
1365
1430
|
var getScreen = function getScreen() {
|
|
1366
1431
|
switch (currentScreen) {
|
|
1367
1432
|
case 0:
|
|
@@ -1380,7 +1445,8 @@ function App() {
|
|
|
1380
1445
|
onContinue: function onContinue() {
|
|
1381
1446
|
return setCurrentScreen(2);
|
|
1382
1447
|
},
|
|
1383
|
-
|
|
1448
|
+
authRequestId: authId,
|
|
1449
|
+
test: test
|
|
1384
1450
|
});
|
|
1385
1451
|
|
|
1386
1452
|
case 2:
|
|
@@ -1390,7 +1456,8 @@ function App() {
|
|
|
1390
1456
|
return setCurrentScreen(1);
|
|
1391
1457
|
},
|
|
1392
1458
|
shadow: shadow,
|
|
1393
|
-
|
|
1459
|
+
authRequestId: authId,
|
|
1460
|
+
test: test
|
|
1394
1461
|
});
|
|
1395
1462
|
|
|
1396
1463
|
case 3:
|
|
@@ -1487,10 +1554,13 @@ i18n.use(initReactI18next) // passes i18n down to react-i18next
|
|
|
1487
1554
|
}
|
|
1488
1555
|
});
|
|
1489
1556
|
|
|
1490
|
-
function BasiqConnect() {
|
|
1557
|
+
function BasiqConnect(props) {
|
|
1558
|
+
var test = props.test;
|
|
1491
1559
|
return React.createElement(React.StrictMode, null, React.createElement(ThemeProvider, {
|
|
1492
1560
|
theme: theme
|
|
1493
|
-
}, React.createElement(App,
|
|
1561
|
+
}, React.createElement(App, {
|
|
1562
|
+
test: test
|
|
1563
|
+
})));
|
|
1494
1564
|
}
|
|
1495
1565
|
|
|
1496
1566
|
export { BasiqConnect };
|