@tap-payments/auth-jsconnect 2.11.31-development → 2.12.0-development

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 (109) hide show
  1. package/build/api/lead.d.ts +2 -2
  2. package/build/assets/locales/ar.json +3 -3
  3. package/build/constants/app.js +60 -3
  4. package/build/constants/flows.d.ts +1 -0
  5. package/build/constants/flows.js +2 -1
  6. package/build/features/app/bank/bankStore.d.ts +7 -0
  7. package/build/features/app/bank/bankStore.js +84 -0
  8. package/build/features/app/board/boardStore.d.ts +5 -0
  9. package/build/features/app/board/boardStore.js +81 -0
  10. package/build/features/app/brand/brandStore.d.ts +7 -0
  11. package/build/features/app/brand/brandStore.js +83 -1
  12. package/build/features/app/business/businessStore.d.ts +10 -0
  13. package/build/features/app/business/businessStore.js +83 -1
  14. package/build/features/app/entity/entityStore.d.ts +7 -0
  15. package/build/features/app/entity/entityStore.js +85 -1
  16. package/build/features/app/individual/individualStore.d.ts +9 -0
  17. package/build/features/app/individual/individualStore.js +85 -1
  18. package/build/features/app/password/passwordStore.d.ts +9 -0
  19. package/build/features/app/password/passwordStore.js +82 -0
  20. package/build/features/app/tax/taxStore.d.ts +7 -0
  21. package/build/features/app/tax/taxStore.js +81 -0
  22. package/build/features/app/terminal/terminalStore.d.ts +9 -0
  23. package/build/features/app/terminal/terminalStore.js +76 -0
  24. package/build/features/auth/screens/OTPSessionExpired/OTPSessionExpired.js +2 -2
  25. package/build/features/bank/Bank.js +3 -2
  26. package/build/features/bank/screens/OTPSessionExpired/OTPInput.d.ts +7 -0
  27. package/build/features/bank/screens/OTPSessionExpired/OTPInput.js +51 -0
  28. package/build/features/bank/screens/OTPSessionExpired/OTPSessionExpired.d.ts +5 -0
  29. package/build/features/bank/screens/OTPSessionExpired/OTPSessionExpired.js +75 -0
  30. package/build/features/bank/screens/OTPSessionExpired/index.d.ts +2 -0
  31. package/build/features/bank/screens/OTPSessionExpired/index.js +2 -0
  32. package/build/features/bank/screens/OTPSessionExpired/validation.d.ts +8 -0
  33. package/build/features/bank/screens/OTPSessionExpired/validation.js +4 -0
  34. package/build/features/board/Board.js +5 -4
  35. package/build/features/board/screens/OTPSessionExpired/OTPInput.d.ts +7 -0
  36. package/build/features/board/screens/OTPSessionExpired/OTPInput.js +51 -0
  37. package/build/features/board/screens/OTPSessionExpired/OTPSessionExpired.d.ts +5 -0
  38. package/build/features/board/screens/OTPSessionExpired/OTPSessionExpired.js +75 -0
  39. package/build/features/board/screens/OTPSessionExpired/index.d.ts +2 -0
  40. package/build/features/board/screens/OTPSessionExpired/index.js +2 -0
  41. package/build/features/board/screens/OTPSessionExpired/validation.d.ts +8 -0
  42. package/build/features/board/screens/OTPSessionExpired/validation.js +4 -0
  43. package/build/features/brand/Brand.js +3 -2
  44. package/build/features/brand/screens/OTPSessionExpired/OTPInput.d.ts +7 -0
  45. package/build/features/brand/screens/OTPSessionExpired/OTPInput.js +51 -0
  46. package/build/features/brand/screens/OTPSessionExpired/OTPSessionExpired.d.ts +5 -0
  47. package/build/features/brand/screens/OTPSessionExpired/OTPSessionExpired.js +75 -0
  48. package/build/features/brand/screens/OTPSessionExpired/index.d.ts +2 -0
  49. package/build/features/brand/screens/OTPSessionExpired/index.js +2 -0
  50. package/build/features/brand/screens/OTPSessionExpired/validation.d.ts +8 -0
  51. package/build/features/brand/screens/OTPSessionExpired/validation.js +4 -0
  52. package/build/features/business/Business.js +3 -2
  53. package/build/features/business/screens/OTPSessionExpired/OTPInput.d.ts +7 -0
  54. package/build/features/business/screens/OTPSessionExpired/OTPInput.js +51 -0
  55. package/build/features/business/screens/OTPSessionExpired/OTPSessionExpired.d.ts +5 -0
  56. package/build/features/business/screens/OTPSessionExpired/OTPSessionExpired.js +75 -0
  57. package/build/features/business/screens/OTPSessionExpired/index.d.ts +2 -0
  58. package/build/features/business/screens/OTPSessionExpired/index.js +2 -0
  59. package/build/features/business/screens/OTPSessionExpired/validation.d.ts +8 -0
  60. package/build/features/business/screens/OTPSessionExpired/validation.js +4 -0
  61. package/build/features/connect/screens/OTPSessionExpired/OTPSessionExpired.js +2 -2
  62. package/build/features/connectExpress/screens/OTPSessionExpired/OTPSessionExpired.js +2 -2
  63. package/build/features/entity/Entity.js +3 -2
  64. package/build/features/entity/screens/OTPSessionExpired/OTPInput.d.ts +7 -0
  65. package/build/features/entity/screens/OTPSessionExpired/OTPInput.js +51 -0
  66. package/build/features/entity/screens/OTPSessionExpired/OTPSessionExpired.d.ts +5 -0
  67. package/build/features/entity/screens/OTPSessionExpired/OTPSessionExpired.js +75 -0
  68. package/build/features/entity/screens/OTPSessionExpired/index.d.ts +2 -0
  69. package/build/features/entity/screens/OTPSessionExpired/index.js +2 -0
  70. package/build/features/entity/screens/OTPSessionExpired/validation.d.ts +8 -0
  71. package/build/features/entity/screens/OTPSessionExpired/validation.js +4 -0
  72. package/build/features/featuresScreens.js +45 -0
  73. package/build/features/individual/Individual.js +3 -2
  74. package/build/features/individual/screens/OTPSessionExpired/OTPInput.d.ts +7 -0
  75. package/build/features/individual/screens/OTPSessionExpired/OTPInput.js +51 -0
  76. package/build/features/individual/screens/OTPSessionExpired/OTPSessionExpired.d.ts +5 -0
  77. package/build/features/individual/screens/OTPSessionExpired/OTPSessionExpired.js +75 -0
  78. package/build/features/individual/screens/OTPSessionExpired/index.d.ts +2 -0
  79. package/build/features/individual/screens/OTPSessionExpired/index.js +2 -0
  80. package/build/features/individual/screens/OTPSessionExpired/validation.d.ts +8 -0
  81. package/build/features/individual/screens/OTPSessionExpired/validation.js +4 -0
  82. package/build/features/password/Password.js +3 -2
  83. package/build/features/password/screens/OTPSessionExpired/OTPInput.d.ts +7 -0
  84. package/build/features/password/screens/OTPSessionExpired/OTPInput.js +51 -0
  85. package/build/features/password/screens/OTPSessionExpired/OTPSessionExpired.d.ts +5 -0
  86. package/build/features/password/screens/OTPSessionExpired/OTPSessionExpired.js +75 -0
  87. package/build/features/password/screens/OTPSessionExpired/index.d.ts +2 -0
  88. package/build/features/password/screens/OTPSessionExpired/index.js +2 -0
  89. package/build/features/password/screens/OTPSessionExpired/validation.d.ts +8 -0
  90. package/build/features/password/screens/OTPSessionExpired/validation.js +4 -0
  91. package/build/features/tax/Tax.js +3 -2
  92. package/build/features/tax/screens/OTPSessionExpired/OTPInput.d.ts +7 -0
  93. package/build/features/tax/screens/OTPSessionExpired/OTPInput.js +51 -0
  94. package/build/features/tax/screens/OTPSessionExpired/OTPSessionExpired.d.ts +5 -0
  95. package/build/features/tax/screens/OTPSessionExpired/OTPSessionExpired.js +75 -0
  96. package/build/features/tax/screens/OTPSessionExpired/index.d.ts +2 -0
  97. package/build/features/tax/screens/OTPSessionExpired/index.js +2 -0
  98. package/build/features/tax/screens/OTPSessionExpired/validation.d.ts +8 -0
  99. package/build/features/tax/screens/OTPSessionExpired/validation.js +4 -0
  100. package/build/features/terminal/Terminal.js +3 -2
  101. package/build/features/terminal/screens/OTPSessionExpired/OTPInput.d.ts +7 -0
  102. package/build/features/terminal/screens/OTPSessionExpired/OTPInput.js +51 -0
  103. package/build/features/terminal/screens/OTPSessionExpired/OTPSessionExpired.d.ts +5 -0
  104. package/build/features/terminal/screens/OTPSessionExpired/OTPSessionExpired.js +89 -0
  105. package/build/features/terminal/screens/OTPSessionExpired/index.d.ts +2 -0
  106. package/build/features/terminal/screens/OTPSessionExpired/index.js +2 -0
  107. package/build/features/terminal/screens/OTPSessionExpired/validation.d.ts +8 -0
  108. package/build/features/terminal/screens/OTPSessionExpired/validation.js +4 -0
  109. package/package.json +1 -1
@@ -0,0 +1,51 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ import * as React from 'react';
14
+ import Box from '@mui/material/Box/Box';
15
+ import { styled } from '@mui/material/styles';
16
+ import OTPField from '../../../shared/OTP';
17
+ import { useController, useFormContext } from 'react-hook-form';
18
+ import { useTranslation } from 'react-i18next';
19
+ import { DEFAULT_TIMER_VALUE } from '../../../../constants';
20
+ import { useAppDispatch, useAppSelector } from '../../../../hooks';
21
+ import { isTokenExpired } from '../../../../utils';
22
+ import { clearError, terminalSelector, verifyTokenSessionExpired } from '../../../app/terminal/terminalStore';
23
+ var BoxStyled = styled(Box)(function (_a) {
24
+ var theme = _a.theme;
25
+ return ({
26
+ display: 'flex',
27
+ flexDirection: 'column',
28
+ fontFamily: theme.typography.fontFamily
29
+ });
30
+ });
31
+ var OTPInput = function (_a) {
32
+ var loading = _a.loading;
33
+ var _b = useFormContext(), control = _b.control, setValue = _b.setValue;
34
+ var t = useTranslation().t;
35
+ var otpControl = useController({ name: 'otp', control: control });
36
+ var dispatch = useAppDispatch();
37
+ var error = useAppSelector(terminalSelector).error;
38
+ var handleOnOTPChange = function (otp) {
39
+ if (error)
40
+ dispatch(clearError());
41
+ otpControl.field.onChange(otp);
42
+ };
43
+ var handleOnResendOTP = function () {
44
+ if (otpControl.field.value)
45
+ setValue('otp', '', { shouldValidate: true });
46
+ dispatch(verifyTokenSessionExpired());
47
+ };
48
+ var otpValue = otpControl.field.value;
49
+ return (_jsx(BoxStyled, __assign({ dir: 'ltr' }, { children: _jsx(OTPField, { loading: loading, timeEndLabel: t('ide_otp_resend_label'), timerInSeconds: DEFAULT_TIMER_VALUE, onResetClick: handleOnResendOTP, value: otpValue, hasError: isTokenExpired(error), onChange: function (number) { return handleOnOTPChange(number.toString()); } }) })));
50
+ };
51
+ export default React.memo(OTPInput);
@@ -0,0 +1,5 @@
1
+ import * as React from 'react';
2
+ export interface OTPProps {
3
+ }
4
+ declare const _default: React.MemoExoticComponent<({}: OTPProps) => JSX.Element>;
5
+ export default _default;
@@ -0,0 +1,89 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import * as React from 'react';
14
+ import { useAppDispatch, useSetFromDefaultValues, useSanitizedTranslation, useLanguage, useAppSelector } from '../../../../hooks';
15
+ import { useTranslation } from 'react-i18next';
16
+ import { useForm, FormProvider } from 'react-hook-form';
17
+ import { yupResolver } from '@hookform/resolvers/yup';
18
+ import Box from '@mui/material/Box/Box';
19
+ import { styled } from '@mui/material/styles';
20
+ import { handleCurrentActiveScreen } from '../../../../app/settings';
21
+ import { deepCopy, isAuthenticationVerificationFailed, maskPhone } from '../../../../utils';
22
+ import Form from '../../../../components/Form';
23
+ import Text from '../../../../components/Text';
24
+ import { ScreenContainer } from '../../../shared/Containers';
25
+ import { terminalSelector, clearError, resetOTPScreen, verifyTokenOTPSessionExpired } from '../../../app/terminal/terminalStore';
26
+ import Button from '../../../shared/Button';
27
+ import { OTPValidation } from './validation';
28
+ import OTPInput from './OTPInput';
29
+ import { CONNECT_FLOWS } from '../../../../constants';
30
+ var OTPTitleContainerStyled = styled(Box)(function (_a) {
31
+ var theme = _a.theme;
32
+ return ({
33
+ background: theme.palette.common.white,
34
+ border: '1px solid',
35
+ borderColor: theme.palette.divider,
36
+ direction: theme.direction,
37
+ borderRadius: theme.spacing(0, 0, 1.25, 1.25),
38
+ marginBottom: theme.spacing(5.75)
39
+ });
40
+ });
41
+ var OTPTitleStyled = styled(Text)(function (_a) {
42
+ var theme = _a.theme;
43
+ return (__assign(__assign({}, theme.typography.body1), { color: theme.palette.text.primary, fontWeight: theme.typography.fontWeightLight, marginBlock: theme.spacing(1.75), marginInlineStart: theme.spacing(2.5), lineHeight: 1.5, display: 'flex', flexDirection: 'column' }));
44
+ });
45
+ var FormStyled = styled(Form)(function () { return ({
46
+ display: 'flex',
47
+ flexDirection: 'column'
48
+ }); });
49
+ var VerifyNumber = function (_a) {
50
+ var _b, _c, _d;
51
+ var dispatch = useAppDispatch();
52
+ var _e = useAppSelector(terminalSelector), data = _e.data, loading = _e.loading, error = _e.error;
53
+ var otp = data.otpData.otp;
54
+ var methods = useForm({
55
+ resolver: yupResolver(OTPValidation),
56
+ defaultValues: {
57
+ otp: otp
58
+ },
59
+ mode: 'onChange'
60
+ });
61
+ useSetFromDefaultValues(methods, data.otpData);
62
+ var t = useTranslation().t;
63
+ var st = useSanitizedTranslation();
64
+ var isAr = useLanguage().isAr;
65
+ var _f = React.useState(false), resendLoading = _f[0], setResendLoading = _f[1];
66
+ var phone = (_d = (_c = (_b = data.responseData) === null || _b === void 0 ? void 0 : _b.authData) === null || _c === void 0 ? void 0 : _c.verification_by) === null || _d === void 0 ? void 0 : _d.sent_to;
67
+ React.useEffect(function () {
68
+ if (error && methods.formState.isValid && phone)
69
+ dispatch(clearError());
70
+ return function () {
71
+ dispatch(resetOTPScreen());
72
+ };
73
+ }, [methods.formState.isValid]);
74
+ var onSubmit = function (formData) {
75
+ dispatch(verifyTokenOTPSessionExpired(deepCopy(formData)))
76
+ .unwrap()
77
+ .then(function (_a) {
78
+ var nextScreen = _a.nextScreen;
79
+ dispatch(handleCurrentActiveScreen(nextScreen));
80
+ })
81
+ .catch(function (err) {
82
+ if (isAuthenticationVerificationFailed(err === null || err === void 0 ? void 0 : err.message))
83
+ dispatch(handleCurrentActiveScreen(CONNECT_FLOWS.terminal.otpVerifySecurityError));
84
+ });
85
+ };
86
+ var disabled = !methods.formState.isValid || !phone || resendLoading;
87
+ return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(OTPTitleContainerStyled, { children: _jsxs(OTPTitleStyled, { children: [loading ? st('ide_otp_waiting_title') : st('session_expired_otp'), !loading && phone && (_jsxs("span", { children: [st('code_sent_to'), " ", _jsx("span", __assign({ dir: 'ltr' }, { children: maskPhone(phone) }))] }))] }) }), _jsx(OTPInput, { loading: resendLoading, setLoading: setResendLoading }), _jsx(Button, __assign({ disableBack: true, disabled: disabled, isAr: isAr, loading: loading, error: st(error || '') }, { children: t('next') }))] })) })) }));
88
+ };
89
+ export default React.memo(VerifyNumber);
@@ -0,0 +1,2 @@
1
+ import OTPSessionExpired from './OTPSessionExpired';
2
+ export default OTPSessionExpired;
@@ -0,0 +1,2 @@
1
+ import OTPSessionExpired from './OTPSessionExpired';
2
+ export default OTPSessionExpired;
@@ -0,0 +1,8 @@
1
+ import * as yup from 'yup';
2
+ export declare const OTPValidation: yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
3
+ otp: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
4
+ }>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
5
+ otp: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
6
+ }>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
7
+ otp: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
8
+ }>>>;
@@ -0,0 +1,4 @@
1
+ import * as yup from 'yup';
2
+ export var OTPValidation = yup.object().shape({
3
+ otp: yup.string().min(6, 'otp_min_length').required('otp_required')
4
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tap-payments/auth-jsconnect",
3
- "version": "2.11.31-development",
3
+ "version": "2.12.0-development",
4
4
  "description": "connect library, auth",
5
5
  "private": false,
6
6
  "main": "build/index.js",