@tap-payments/auth-jsconnect 1.0.31 → 1.0.34

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.
Files changed (70) hide show
  1. package/build/@types/app.d.ts +5 -1
  2. package/build/@types/form.d.ts +23 -1
  3. package/build/api/account.d.ts +15 -0
  4. package/build/api/account.js +9 -0
  5. package/build/api/axios.d.ts +2 -0
  6. package/build/api/axios.js +10 -0
  7. package/build/api/data.d.ts +6 -0
  8. package/build/api/data.js +17 -0
  9. package/build/api/entity.d.ts +20 -0
  10. package/build/api/entity.js +9 -0
  11. package/build/api/index.d.ts +22 -2
  12. package/build/api/index.js +9 -1
  13. package/build/api/lead.d.ts +22 -0
  14. package/build/api/lead.js +21 -1
  15. package/build/app/settings.js +12 -18
  16. package/build/components/Input/Input.d.ts +1 -1
  17. package/build/components/Input/Input.js +3 -2
  18. package/build/components/Slide/Slide.d.ts +1 -1
  19. package/build/components/Warning/Warning.d.ts +1 -1
  20. package/build/components/Warning/Warning.js +13 -2
  21. package/build/constants/api.d.ts +8 -0
  22. package/build/constants/api.js +17 -1
  23. package/build/constants/app.d.ts +11 -1
  24. package/build/constants/app.js +11 -1
  25. package/build/constants/assets.js +1 -1
  26. package/build/constants/validation.d.ts +1 -0
  27. package/build/constants/validation.js +1 -0
  28. package/build/features/app/business/businessStore.d.ts +73 -4
  29. package/build/features/app/business/businessStore.js +500 -7
  30. package/build/features/app/connect/connectStore.d.ts +11 -3
  31. package/build/features/app/connect/connectStore.js +88 -43
  32. package/build/features/bank/screens/BankDetails/validation.js +2 -1
  33. package/build/features/business/Business.js +7 -3
  34. package/build/features/business/screens/Activities/Activities.js +13 -13
  35. package/build/features/business/screens/Activities/ActivitiesList.d.ts +2 -2
  36. package/build/features/business/screens/Activities/ActivitiesList.js +14 -4
  37. package/build/features/business/screens/Activities/OperationStartDate.js +1 -1
  38. package/build/features/business/screens/Activities/SalesChannels.js +11 -2
  39. package/build/features/business/screens/BusinessType/BusinessType.d.ts +1 -8
  40. package/build/features/business/screens/BusinessType/BusinessType.js +25 -27
  41. package/build/features/business/screens/Confirm/Confirm.js +10 -11
  42. package/build/features/business/screens/Customers/CustomerLocations.d.ts +3 -3
  43. package/build/features/business/screens/Customers/Customers.js +3 -2
  44. package/build/features/business/screens/IDBOD/DOB.js +1 -1
  45. package/build/features/business/screens/IDBOD/IDBOD.js +19 -12
  46. package/build/features/business/screens/OTP/OTP.d.ts +2 -5
  47. package/build/features/business/screens/OTP/OTP.js +18 -15
  48. package/build/features/business/screens/OTP/OTPInput.js +20 -5
  49. package/build/features/business/screens/Success/Success.js +6 -0
  50. package/build/features/business/screens/Verify/OTPInput.js +7 -3
  51. package/build/features/business/screens/Verify/Verify.d.ts +1 -9
  52. package/build/features/business/screens/Verify/Verify.js +16 -17
  53. package/build/features/business/screens/Verify/index.d.ts +1 -2
  54. package/build/features/connect/screens/Individual/Individual.js +6 -1
  55. package/build/features/connect/screens/Individual/Name.js +10 -1
  56. package/build/features/connect/screens/Individual/validation.js +3 -2
  57. package/build/features/connect/screens/Merchant/Merchant.js +6 -1
  58. package/build/features/connect/screens/Mobile/Mobile.js +6 -1
  59. package/build/features/connect/screens/NID/NID.js +6 -1
  60. package/build/features/connect/screens/OTP/OTP.js +6 -1
  61. package/build/features/connect/screens/Password/Password.js +7 -2
  62. package/build/features/featuresScreens.js +3 -3
  63. package/build/features/individual/screens/AdditionalIndividualInfo/validation.js +2 -4
  64. package/build/features/shared/Button/AbsherButton.js +1 -1
  65. package/build/features/shared/Input/Input.d.ts +1 -1
  66. package/build/hooks/useAppConfig.js +99 -24
  67. package/build/theme/palette.js +4 -0
  68. package/build/utils/string.d.ts +25 -0
  69. package/build/utils/string.js +56 -0
  70. package/package.json +1 -1
@@ -13,17 +13,19 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
13
  import * as React from 'react';
14
14
  import { useAppDispatch } from '../../../../hooks';
15
15
  import { useTranslation } from 'react-i18next';
16
+ import { useSelector } from 'react-redux';
16
17
  import { useForm, FormProvider } from 'react-hook-form';
17
18
  import { yupResolver } from '@hookform/resolvers/yup';
18
19
  import Box from '@mui/material/Box/Box';
19
20
  import { styled } from '@mui/material/styles';
20
- import { handleNextScreenStep, handlePrevScreenStep } from '../../../../app/settings';
21
+ import { handlePrevScreenStep } from '../../../../app/settings';
21
22
  import { useLanguage } from '../../../../hooks';
23
+ import { maskPhone } from '../../../../utils';
22
24
  import Form from '../../../../components/Form';
23
25
  import Text from '../../../../components/Text';
24
26
  import { ScreenContainer } from '../../../shared/Containers';
27
+ import { businessSelector, clearError, verifyLeadOTP } from '../../../app/business/businessStore';
25
28
  import Button from '../../../shared/Button';
26
- import { maskPhone } from '../../../../utils';
27
29
  import { OTPValidation } from './validation';
28
30
  import OTPInput from './OTPInput';
29
31
  var OTPTitleContainerStyled = styled(Box)(function (_a) {
@@ -46,31 +48,28 @@ var FormStyled = styled(Form)(function () { return ({
46
48
  flexDirection: 'column'
47
49
  }); });
48
50
  var VerifyNumber = function (_a) {
49
- var phone = _a.phone, code = _a.code;
51
+ var _b, _c, _d;
50
52
  var dispatch = useAppDispatch();
53
+ var _e = useSelector(businessSelector), data = _e.data, loading = _e.loading, error = _e.error;
51
54
  var methods = useForm({
52
55
  resolver: yupResolver(OTPValidation),
53
- defaultValues: {
54
- otp: ''
55
- },
56
+ defaultValues: data.otpData,
56
57
  mode: 'onChange'
57
58
  });
58
59
  var t = useTranslation().t;
59
60
  var isAr = useLanguage().isAr;
60
- var onSubmit = function (data) {
61
- console.log('data', data);
62
- if (data.otp === '123456')
63
- return dispatch(handleNextScreenStep('BUSINESS_IDBOD_STEP'));
64
- dispatch(handleNextScreenStep('BUSINESS_BUSINESS_TYPE_STEP'));
61
+ React.useEffect(function () {
62
+ if (error)
63
+ dispatch(clearError());
64
+ }, [methods.formState.isValid]);
65
+ var onSubmit = function (formData) {
66
+ dispatch(verifyLeadOTP(formData));
65
67
  };
66
68
  var onBack = function () {
67
69
  dispatch(handlePrevScreenStep());
68
70
  };
69
- var loading = false;
70
- return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(OTPTitleContainerStyled, { children: _jsxs(OTPTitleStyled, { children: [loading ? t('ide_otp_waiting_title') : t('ide_opt_sent_title'), _jsx("span", __assign({ dir: 'ltr' }, { children: "".concat(maskPhone(phone || '')) }))] }) }), _jsx(OTPInput, {}), _jsx(Button, __assign({ disableBack: true, onBackClicked: function () { return onBack(); }, disabled: !methods.formState.isValid, type: 'submit', isAr: isAr, loading: loading }, { children: t('next') }))] })) })) }));
71
- };
72
- VerifyNumber.defaultProps = {
73
- phone: '564656085',
74
- code: '+996'
71
+ var disabled = !methods.formState.isValid || !!error;
72
+ var phone = ((_d = (_c = (_b = data.verify.responseBody) === null || _b === void 0 ? void 0 : _b.contact) === null || _c === void 0 ? void 0 : _c.phone) === null || _d === void 0 ? void 0 : _d.number) || '';
73
+ return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(OTPTitleContainerStyled, { children: _jsxs(OTPTitleStyled, { children: [loading ? t('ide_otp_waiting_title') : t('ide_opt_sent_title'), !loading && phone && _jsx("span", __assign({ dir: 'ltr' }, { children: "".concat(maskPhone(phone)) }))] }) }), _jsx(OTPInput, {}), _jsx(Button, __assign({ disableBack: true, onBackClicked: function () { return onBack(); }, disabled: disabled, type: 'submit', isAr: isAr, loading: loading, error: t(error || '') }, { children: t('next') }))] })) })) }));
75
74
  };
76
75
  export default React.memo(VerifyNumber);
@@ -1,3 +1,2 @@
1
- import OTP, { OTPProps } from './Verify';
2
- export type { OTPProps };
1
+ import OTP from './Verify';
3
2
  export default OTP;
@@ -24,7 +24,7 @@ import { IndividualValidation, IndividualMobileValidation } from './validation';
24
24
  import Form from '../../../../components/Form';
25
25
  import Button from '../../../shared/Button';
26
26
  import { ScreenContainer } from '../../../shared/Containers';
27
- import { clearError, connectSelector, updateLeadIndividual } from '../../../app/connect/connectStore';
27
+ import { clearError, connectSelector, resetIndividualScreen, updateLeadIndividual } from '../../../app/connect/connectStore';
28
28
  import { useLanguage } from '../../../../hooks';
29
29
  import MobileNumber from './MobileNumber';
30
30
  import { countriesCode } from '../../../../constants';
@@ -58,6 +58,11 @@ var Individual = function (_a) {
58
58
  if (error)
59
59
  dispatch(clearError());
60
60
  }, [methods.formState.isValid]);
61
+ React.useEffect(function () {
62
+ return function () {
63
+ dispatch(resetIndividualScreen());
64
+ };
65
+ }, []);
61
66
  React.useEffect(function () {
62
67
  var name = individualData.name, email = individualData.email, mobile = individualData.mobile, countryCode = individualData.countryCode;
63
68
  if (!!name)
@@ -19,6 +19,15 @@ import { useController, useFormContext } from 'react-hook-form';
19
19
  import ClearIcon from '../../../shared/ClearIcon';
20
20
  import CheckIcon from '../../../shared/CheckIcon';
21
21
  import Collapse from '../../../../components/Collapse';
22
+ import { styled } from '@mui/material/styles';
23
+ var InputStyled = styled(Input)(function (_a) {
24
+ var theme = _a.theme;
25
+ return ({
26
+ input: {
27
+ textTransform: 'capitalize'
28
+ }
29
+ });
30
+ });
22
31
  var Name = function (_a) {
23
32
  var _b;
24
33
  var show = _a.show;
@@ -34,6 +43,6 @@ var Name = function (_a) {
34
43
  var clearNumber = function () {
35
44
  nameControl.field.onChange('');
36
45
  };
37
- return (_jsx(Collapse, __assign({ in: show }, { children: _jsx(ScreenContainer, __assign({ sx: { mb: 3, mt: 2.5 } }, { children: _jsx(Input, { label: t('signup_merchant_name_label'), value: nameValue, onChange: handleNameChange, placeholder: t('signup_merchant_name_label'), warningType: 'alert', warningMessage: error && t(error), endAdornment: !error && nameValue ? _jsx(CheckIcon, {}) : nameValue && _jsx(ClearIcon, { onClick: clearNumber }) }) })) })));
46
+ return (_jsx(Collapse, __assign({ in: show }, { children: _jsx(ScreenContainer, __assign({ sx: { mb: 3, mt: 2.5 } }, { children: _jsx(InputStyled, { label: t('signup_merchant_name_label'), value: nameValue, onChange: handleNameChange, placeholder: t('signup_merchant_name_label'), warningType: 'alert', warningMessage: error && t(error), endAdornment: !error && nameValue ? _jsx(CheckIcon, {}) : nameValue && _jsx(ClearIcon, { onClick: clearNumber }) }) })) })));
38
47
  };
39
48
  export default React.memo(Name);
@@ -1,9 +1,10 @@
1
+ import { REGEX_FULL_NAME } from '../../../../constants';
1
2
  import * as yup from 'yup';
2
3
  export var IndividualValidation = function () {
3
4
  return yup.object().shape({
4
5
  name: yup
5
6
  .string()
6
- .matches(/^([a-zA-Z0-9]+\s{1}[a-zA-Z0-9]{2,}|[a-zA-Z0-9]+\s{1}[a-zA-Z0-9]{1,}\s{1}[a-zA-Z0-9]{2,})$/g, 'please write your first and last name')
7
+ .matches(REGEX_FULL_NAME, 'please write your first and last name')
7
8
  .required('please write your first and last name'),
8
9
  email: yup.string().email('email_not_valid').required('email_not_valid')
9
10
  });
@@ -12,7 +13,7 @@ export var IndividualMobileValidation = function (length) {
12
13
  return yup.object().shape({
13
14
  name: yup
14
15
  .string()
15
- .matches(/^([a-zA-Z0-9]+\s{1}[a-zA-Z0-9]{2,}|[a-zA-Z0-9]+\s{1}[a-zA-Z0-9]{1,}\s{1}[a-zA-Z0-9]{2,})$/g, 'please write your first and last name')
16
+ .matches(REGEX_FULL_NAME, 'please write your first and last name')
16
17
  .required('please write your first and last name'),
17
18
  email: yup.string().email('email_not_valid').required('email_not_valid'),
18
19
  mobile: yup.string().length(length, 'enter_valid_mobile_number').required('mobile_number_error')
@@ -20,7 +20,7 @@ import { handlePrevScreenStep } from '../../../../app/settings';
20
20
  import Form from '../../../../components/Form';
21
21
  import { ScreenContainer } from '../../../shared/Containers';
22
22
  import Button from '../../../shared/Button';
23
- import { clearError, connectSelector, updateLeadBrand } from '../../../app/connect/connectStore';
23
+ import { clearError, connectSelector, resetMerchantScreen, updateLeadBrand } from '../../../app/connect/connectStore';
24
24
  import { useLanguage } from '../../../../hooks';
25
25
  import { MerchantValidationSchema } from './validation';
26
26
  import BrandName from './BrandName';
@@ -47,6 +47,11 @@ var Merchant = function (_a) {
47
47
  if (error)
48
48
  dispatch(clearError());
49
49
  }, [methods.formState.isValid]);
50
+ React.useEffect(function () {
51
+ return function () {
52
+ dispatch(resetMerchantScreen());
53
+ };
54
+ }, []);
50
55
  React.useEffect(function () {
51
56
  var _a, _b;
52
57
  if (((_b = (_a = data.brandData) === null || _a === void 0 ? void 0 : _a.responseBody) === null || _b === void 0 ? void 0 : _b.response_code) === '5')
@@ -23,7 +23,7 @@ import Button, { AbsherButton } from '../../../shared/Button';
23
23
  import { useAppDispatch } from '../../../../hooks';
24
24
  import { handlePrevScreenStep, settingsSelector } from '../../../../app/settings';
25
25
  import ScreenContainer from '../../../shared/Containers/ScreenContainer';
26
- import { clearError, connectSelector, createMobileAuth } from '../../../app/connect/connectStore';
26
+ import { clearError, resetMobileScreen, connectSelector, createMobileAuth } from '../../../app/connect/connectStore';
27
27
  import { useLanguage } from '../../../../hooks';
28
28
  import Divider from '@mui/material/Divider';
29
29
  import Text from '../../../../components/Text';
@@ -101,6 +101,11 @@ var Mobile = function (_a) {
101
101
  if (error)
102
102
  dispatch(clearError());
103
103
  }, [methods.formState.isValid]);
104
+ React.useEffect(function () {
105
+ return function () {
106
+ dispatch(resetMobileScreen());
107
+ };
108
+ }, []);
104
109
  var onSubmit = function (formData) {
105
110
  dispatch(createMobileAuth(__assign(__assign({}, formData), { isResend: false })));
106
111
  };
@@ -19,7 +19,7 @@ import { yupResolver } from '@hookform/resolvers/yup';
19
19
  import { NIDValidationSchema } from './validation';
20
20
  import { useAppDispatch, useLanguage } from '../../../../hooks';
21
21
  import { handlePrevScreenStep, settingsSelector } from '../../../../app/settings';
22
- import { clearError, connectSelector, createNIDAuth } from '../../../app/connect/connectStore';
22
+ import { clearError, resetNIDScreen, connectSelector, createNIDAuth } from '../../../app/connect/connectStore';
23
23
  import Form from '../../../../components/Form';
24
24
  import Button, { AbsherButton } from '../../../shared/Button';
25
25
  import { ScreenContainer } from '../../../shared/Containers';
@@ -73,6 +73,11 @@ var NID = function (_a) {
73
73
  React.useEffect(function () {
74
74
  handleClearError();
75
75
  }, [methods.formState.isValid]);
76
+ React.useEffect(function () {
77
+ return function () {
78
+ dispatch(resetNIDScreen());
79
+ };
80
+ }, []);
76
81
  var onSubmit = function (data) {
77
82
  dispatch(createNIDAuth(__assign(__assign({}, data), { isResend: false })));
78
83
  };
@@ -16,7 +16,7 @@ import { styled } from '@mui/material/styles';
16
16
  import * as React from 'react';
17
17
  import { useTranslation } from 'react-i18next';
18
18
  import Text from '../../../../components/Text';
19
- import { clearError, connectSelector, verifyAuth } from '../../../app/connect/connectStore';
19
+ import { clearError, connectSelector, resetOTPScreen, verifyAuth } from '../../../app/connect/connectStore';
20
20
  import Button from '../../../shared/Button';
21
21
  import { ScreenContainer } from '../../../shared/Containers';
22
22
  import { useAppDispatch } from '../../../../hooks';
@@ -63,6 +63,11 @@ var OTP = function () {
63
63
  if (error)
64
64
  dispatch(clearError());
65
65
  }, [methods.formState.isValid]);
66
+ React.useEffect(function () {
67
+ return function () {
68
+ dispatch(resetOTPScreen());
69
+ };
70
+ }, []);
66
71
  var onSubmit = function (formData) {
67
72
  dispatch(verifyAuth(formData));
68
73
  };
@@ -18,7 +18,7 @@ import { useTranslation } from 'react-i18next';
18
18
  import { yupResolver } from '@hookform/resolvers/yup';
19
19
  import { styled } from '@mui/material/styles';
20
20
  import { handlePrevScreenStep } from '../../../../app/settings';
21
- import { clearError, connectSelector, verifyAuthPassword } from '../../../app/connect/connectStore';
21
+ import { clearError, connectSelector, createVerifyAuthPassword, resetPasswordScreen } from '../../../app/connect/connectStore';
22
22
  import Form from '../../../../components/Form';
23
23
  import Button from '../../../shared/Button';
24
24
  import { ScreenContainer } from '../../../shared/Containers';
@@ -46,8 +46,13 @@ var Password = function (_a) {
46
46
  if (error)
47
47
  dispatch(clearError());
48
48
  }, [methods.formState.isValid]);
49
+ React.useEffect(function () {
50
+ return function () {
51
+ dispatch(resetPasswordScreen());
52
+ };
53
+ }, []);
49
54
  var onSubmit = function (formData) {
50
- dispatch(verifyAuthPassword(formData));
55
+ dispatch(createVerifyAuthPassword(formData));
51
56
  };
52
57
  var onBack = function () {
53
58
  dispatch(handlePrevScreenStep(isAbsher ? 'CONNECT_NID_STEP' : 'CONNECT_MOBILE_STEP'));
@@ -1,4 +1,4 @@
1
- import MobileScreen from '../features/connect/screens/Mobile';
1
+ import MobileScreen from './connect/screens/Mobile';
2
2
  import NIDScreen from './connect/screens/NID';
3
3
  import IndividualScreen from './connect/screens/Individual';
4
4
  import MerchantInfoScreen from './connect/screens/Merchant';
@@ -7,8 +7,8 @@ import ThankYouScreen from './connect/screens/ThankYou';
7
7
  import PasswordScreen from './connect/screens/Password';
8
8
  import CustomersPage from './business/screens/Customers';
9
9
  import IDBODPage from './business/screens/IDBOD';
10
- import BusinessVerifyPage from '../features/business/screens/Verify';
11
- import BusinessOTPPage from '../features/business/screens/OTP';
10
+ import BusinessVerifyPage from './business/screens/Verify';
11
+ import BusinessOTPPage from './business/screens/OTP';
12
12
  import BusinessTypePage from './business/screens/BusinessType';
13
13
  import ActivitiesPage from './business/screens/Activities';
14
14
  import SuccessPage from './business/screens/Success';
@@ -1,14 +1,12 @@
1
1
  import * as yup from 'yup';
2
+ import { REGEX_FULL_NAME } from '../../../../constants';
2
3
  export var IndividualInfoValidationSchema = yup.object().shape({
3
4
  sourceIncome: yup.object().required('choose_any_source_of_income'),
4
5
  monthlyIncome: yup.string().optional(),
5
6
  employerName: yup.string().when('sourceIncome', function (sourceIncomeValue) {
6
7
  var _a;
7
8
  if (((_a = sourceIncomeValue === null || sourceIncomeValue === void 0 ? void 0 : sourceIncomeValue.nameEn) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === 'salary') {
8
- return yup
9
- .string()
10
- .matches(/^([a-zA-Z0-9]+\s{1}[a-zA-Z0-9]{2,}|[a-zA-Z0-9]+\s{1}[a-zA-Z0-9]{1,}\s{1}[a-zA-Z0-9]{2,})$/g, 'employer_name_invalid')
11
- .required('please_enter_employer_name');
9
+ return yup.string().matches(REGEX_FULL_NAME, 'employer_name_invalid').required('please_enter_employer_name');
12
10
  }
13
11
  else {
14
12
  return yup.string().optional();
@@ -31,7 +31,7 @@ var IconStyled = styled(Icon)(function (_a) {
31
31
  return ({
32
32
  width: theme.spacing(3),
33
33
  height: theme.spacing(3),
34
- marginInlineStart: theme.spacing(2)
34
+ marginInlineStart: theme.spacing(0.75)
35
35
  });
36
36
  });
37
37
  var ButtonBoxStyled = styled(Box)(function (_a) {
@@ -16,7 +16,7 @@ export declare const InputLabelStyled: import("@emotion/styled").StyledComponent
16
16
  export declare const InputStyled: import("@emotion/styled").StyledComponent<Pick<InputProps, "name" | "type" | "className" | "style" | "classes" | "color" | "margin" | "translate" | "slot" | "title" | "ref" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "spellCheck" | "tabIndex" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "sx" | "size" | "disabled" | "error" | "components" | "componentsProps" | "value" | "autoFocus" | "fullWidth" | "required" | "rows" | "inputProps" | "inputRef" | "readOnly" | "autoComplete" | "disableInjectingGlobalStyles" | "endAdornment" | "inputComponent" | "multiline" | "renderSuffix" | "maxRows" | "minRows" | "startAdornment" | "disableUnderline" | "onEnterPressed" | "warningMessage"> & {
17
17
  placeholder?: string | undefined;
18
18
  hide?: boolean | undefined;
19
- warningType?: "alert" | "error" | undefined;
19
+ warningType?: "alert" | "error" | "hint" | undefined;
20
20
  } & {} & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, {}, {}>;
21
21
  interface CustomButtonProps extends InputProps {
22
22
  label?: string;
@@ -9,6 +9,42 @@ var __assign = (this && this.__assign) || function () {
9
9
  };
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
+ return new (P || (P = Promise))(function (resolve, reject) {
15
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
16
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
19
+ });
20
+ };
21
+ var __generator = (this && this.__generator) || function (thisArg, body) {
22
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
23
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
24
+ function verb(n) { return function (v) { return step([n, v]); }; }
25
+ function step(op) {
26
+ if (f) throw new TypeError("Generator is already executing.");
27
+ while (_) try {
28
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
29
+ if (y = 0, t) op = [op[0] & 2, t.value];
30
+ switch (op[0]) {
31
+ case 0: case 1: t = op; break;
32
+ case 4: _.label++; return { value: op[1], done: false };
33
+ case 5: _.label++; y = op[1]; op = [0]; continue;
34
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
35
+ default:
36
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
37
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
38
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
39
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
40
+ if (t[2]) _.ops.pop();
41
+ _.trys.pop(); continue;
42
+ }
43
+ op = body.call(thisArg, _);
44
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
45
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
+ }
47
+ };
12
48
  var __rest = (this && this.__rest) || function (s, e) {
13
49
  var t = {};
14
50
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
@@ -20,43 +56,82 @@ var __rest = (this && this.__rest) || function (s, e) {
20
56
  }
21
57
  return t;
22
58
  };
23
- import { useEffect } from 'react';
59
+ import { useEffect, useState } from 'react';
24
60
  import { handleActiveFlowScreens, settingsSelector, getClientIp, getLocale, getBrowserFingerPrint, getOperator, handleSetAppConfig, handleLanguage } from '../app/settings';
25
61
  import { useAppDispatch } from './useAppDispatch';
26
62
  import { useAppSelector } from './useAppSelector';
63
+ import { setAxiosGlobalHeaders } from '../api';
64
+ import { getRequestHeaders, encryptString } from '../utils';
27
65
  export var useAppConfig = function (_a) {
28
66
  var appInfo = _a.appInfo, navigation = _a.navigation, publicKey = _a.publicKey, rest = __rest(_a, ["appInfo", "navigation", "publicKey"]);
67
+ var _b = useState(true), loading = _b[0], setLoading = _b[1];
29
68
  var dispatch = useAppDispatch();
30
- var _b = useAppSelector(settingsSelector), data = _b.data, error = _b.error, loading = _b.loading;
31
- var deviceInfo = data.deviceInfo, language = data.language;
32
- var device = deviceInfo.device, browser = deviceInfo.browser;
33
- useEffect(function () {
34
- dispatch(getLocale());
35
- dispatch(handleActiveFlowScreens(navigation));
36
- dispatch(getClientIp());
37
- dispatch(getBrowserFingerPrint(appInfo));
38
- dispatch(handleSetAppConfig(__assign({ appInfo: appInfo, publicKey: publicKey }, rest)));
39
- }, []);
40
- var handleGetOperator = function () {
41
- var _a, _b;
42
- var payload = {
43
- type: 'website',
44
- app_client_version: 'onboarding_version_2',
45
- requirer_browser: "".concat(browser === null || browser === void 0 ? void 0 : browser.name, " , ").concat(browser === null || browser === void 0 ? void 0 : browser.version),
46
- os: "".concat((_a = device.os) === null || _a === void 0 ? void 0 : _a.name, " , ").concat((_b = device.os) === null || _b === void 0 ? void 0 : _b.version),
47
- locale: language,
48
- connect_pkey: publicKey || ''
49
- };
50
- dispatch(getOperator(payload));
69
+ var _c = useAppSelector(settingsSelector), data = _c.data, error = _c.error;
70
+ var deviceInfo = data.deviceInfo, language = data.language, appConfig = data.appConfig;
71
+ var device = deviceInfo.device, browser = deviceInfo.browser, connection = deviceInfo.connection;
72
+ var addAxiosHeader = function () {
73
+ setAxiosGlobalHeaders(__assign(__assign({}, getRequestHeaders(deviceInfo)), { authorization: encryptString(publicKey), mdn: encryptString(window.location.origin) }));
51
74
  };
75
+ var handleAppConfig = function () { return __awaiter(void 0, void 0, void 0, function () {
76
+ return __generator(this, function (_a) {
77
+ dispatch(handleSetAppConfig(__assign({ appInfo: appInfo, publicKey: publicKey }, rest)));
78
+ dispatch(handleActiveFlowScreens(navigation));
79
+ return [2];
80
+ });
81
+ }); };
82
+ var handleAppApiConfig = function () { return __awaiter(void 0, void 0, void 0, function () {
83
+ return __generator(this, function (_a) {
84
+ switch (_a.label) {
85
+ case 0: return [4, dispatch(getLocale())];
86
+ case 1:
87
+ _a.sent();
88
+ return [4, dispatch(getClientIp())];
89
+ case 2:
90
+ _a.sent();
91
+ return [4, dispatch(getBrowserFingerPrint(appInfo))];
92
+ case 3:
93
+ _a.sent();
94
+ return [2];
95
+ }
96
+ });
97
+ }); };
98
+ var handleGetOperator = function () { return __awaiter(void 0, void 0, void 0, function () {
99
+ var payload;
100
+ var _a, _b;
101
+ return __generator(this, function (_c) {
102
+ switch (_c.label) {
103
+ case 0:
104
+ payload = {
105
+ type: 'website',
106
+ app_client_version: 'js-auth-connect',
107
+ requirer_browser: "".concat(browser === null || browser === void 0 ? void 0 : browser.name, " , ").concat(browser === null || browser === void 0 ? void 0 : browser.version),
108
+ os: "".concat((_a = device.os) === null || _a === void 0 ? void 0 : _a.name, " , ").concat((_b = device.os) === null || _b === void 0 ? void 0 : _b.version),
109
+ locale: language
110
+ };
111
+ return [4, dispatch(getOperator(payload))];
112
+ case 1:
113
+ _c.sent();
114
+ setLoading(false);
115
+ return [2];
116
+ }
117
+ });
118
+ }); };
52
119
  useEffect(function () {
53
120
  if (data.appConfig.language)
54
121
  dispatch(handleLanguage(data.appConfig.language));
55
122
  }, [data.appConfig.language]);
56
123
  useEffect(function () {
57
- if (device.os.name && browser.name && publicKey) {
124
+ handleAppConfig();
125
+ }, []);
126
+ useEffect(function () {
127
+ if (appConfig.publicKey)
128
+ handleAppApiConfig();
129
+ }, [appConfig]);
130
+ useEffect(function () {
131
+ if (connection.ip && browser.browser_id) {
132
+ addAxiosHeader();
58
133
  handleGetOperator();
59
134
  }
60
- }, [device, browser, publicKey]);
135
+ }, [connection, browser]);
61
136
  return { loading: loading, error: error };
62
137
  };
@@ -42,6 +42,10 @@ export var lightPalette = {
42
42
  main: '#F5A623',
43
43
  light: '#FF9F00',
44
44
  dark: '#F5A6234D'
45
+ },
46
+ info: {
47
+ main: '#808592',
48
+ light: '#EAECEF'
45
49
  }
46
50
  };
47
51
  export var darkPalette = {
@@ -1,3 +1,4 @@
1
+ import { DeviceInfo } from '../@types';
1
2
  export declare const maskPhone: (str?: string) => string;
2
3
  export declare const maskID: (str: string) => string;
3
4
  export declare const getIndividualName: (name: string) => {
@@ -9,3 +10,27 @@ export declare const convertNumbers2English: (str: string) => string;
9
10
  export declare const getParameterByName: (name: string) => string | null;
10
11
  export declare const getClientEmailUrl: () => string;
11
12
  export declare const capitalizeTheFirstLetterOfEachWord: (words: string) => string;
13
+ export declare const getRequestHeaders: (deviceInfo: DeviceInfo) => {
14
+ al: string;
15
+ at: string;
16
+ aid: string;
17
+ an: string;
18
+ av: string;
19
+ acv: string;
20
+ asv: string;
21
+ rn: string;
22
+ rt: string;
23
+ rb: string;
24
+ rm: string;
25
+ ro: string;
26
+ rov: string;
27
+ bn: string;
28
+ bb: string;
29
+ bv: string;
30
+ bua: string;
31
+ bi: string;
32
+ ci: string;
33
+ cm: string;
34
+ l: string;
35
+ };
36
+ export declare const removeRequestHeaders: () => void;
@@ -1,3 +1,5 @@
1
+ import { encryptString } from '.';
2
+ import { removeAxiosGlobalHeaders } from '../api';
1
3
  export var maskPhone = function (str) {
2
4
  if (str === void 0) { str = ''; }
3
5
  var lastTwo = str.substring(str.length - 2, str.length);
@@ -57,3 +59,57 @@ export var capitalizeTheFirstLetterOfEachWord = function (words) {
57
59
  }
58
60
  return separateWord.join(' ');
59
61
  };
62
+ export var getRequestHeaders = function (deviceInfo) {
63
+ console.log(deviceInfo);
64
+ var app = deviceInfo.app, browser = deviceInfo.browser, connection = deviceInfo.connection, device = deviceInfo.device, source = deviceInfo.source;
65
+ return {
66
+ al: encryptString(app.language || ''),
67
+ at: encryptString(source || ''),
68
+ aid: encryptString(app.identifier || ''),
69
+ an: encryptString(app.name || ''),
70
+ av: encryptString(app.version || '0.0.0'),
71
+ acv: encryptString(''),
72
+ asv: encryptString(''),
73
+ rn: encryptString(device.name || ''),
74
+ rt: encryptString(device.type || ''),
75
+ rb: encryptString(device.brand || ''),
76
+ rm: encryptString(device.model || ''),
77
+ ro: encryptString(device.os.name || ''),
78
+ rov: encryptString(device.os.version || ''),
79
+ bn: encryptString(browser.name || ''),
80
+ bb: encryptString(''),
81
+ bv: encryptString(browser.version || ''),
82
+ bua: encryptString((browser.user_agent || '').substring(0, 80)),
83
+ bi: encryptString(browser.browser_id || ''),
84
+ ci: encryptString(connection.ip || ''),
85
+ cm: encryptString(connection.mac || ''),
86
+ l: encryptString((connection.latitude || 0).toString() + '-' + (connection.longitude || 0).toString())
87
+ };
88
+ };
89
+ export var removeRequestHeaders = function () {
90
+ removeAxiosGlobalHeaders([
91
+ 'al',
92
+ 'at',
93
+ 'aid',
94
+ 'an',
95
+ 'av',
96
+ 'acv',
97
+ 'asv',
98
+ 'rn',
99
+ 'rt',
100
+ 'rb',
101
+ 'rm',
102
+ 'ro',
103
+ 'rov',
104
+ 'bn',
105
+ 'bb',
106
+ 'bv',
107
+ 'bua',
108
+ 'bi',
109
+ 'ci',
110
+ 'cm',
111
+ 'l',
112
+ 'mdn',
113
+ 'authorization'
114
+ ]);
115
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tap-payments/auth-jsconnect",
3
- "version": "1.0.31",
3
+ "version": "1.0.34",
4
4
  "description": "connect library, auth",
5
5
  "private": false,
6
6
  "main": "build/index.js",