@tap-payments/auth-jsconnect 2.0.81-test → 2.0.83-test

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.
@@ -16,6 +16,10 @@ export declare type NIDFormValues = {
16
16
  nid: string;
17
17
  dob: string;
18
18
  };
19
+ export declare type IDFormValues = {
20
+ nid: string;
21
+ termAndConditionChecked: boolean;
22
+ };
19
23
  export declare type CivilFormValues = {
20
24
  civilId: string;
21
25
  };
@@ -66,6 +66,7 @@ export declare type VerifyAuthKitOTPBody = {
66
66
  data: string;
67
67
  post_url: string;
68
68
  scopes: Array<string>;
69
+ terms: Array<string>;
69
70
  encryption_contract: Array<string>;
70
71
  };
71
72
  declare const authService: {
@@ -348,10 +348,16 @@ export var OTP_SCREENS_NAVIGATION = [
348
348
  ];
349
349
  export var AUTH_SCREENS_NAVIGATION = [
350
350
  {
351
- name: 'AUTH_VERIFY_STEP',
352
- next: '',
351
+ name: 'AUTH_NID_STEP',
352
+ next: 'AUTH_VERIFY_STEP',
353
353
  prev: '',
354
354
  order: 1
355
+ },
356
+ {
357
+ name: 'AUTH_VERIFY_STEP',
358
+ next: '',
359
+ prev: 'AUTH_NID_STEP',
360
+ order: 2
355
361
  }
356
362
  ];
357
363
  export var DefaultDeviceInfo = {
@@ -10,6 +10,8 @@ export interface AuthData extends ResponseData {
10
10
  postUrl: string;
11
11
  otp: string;
12
12
  mobileNumber: string;
13
+ nid: string;
14
+ termAndConditionChecked: boolean;
13
15
  }
14
16
  export interface AuthState extends SharedState<AuthData> {
15
17
  customLoading?: boolean;
@@ -24,11 +26,16 @@ export declare const authSlice: import("@reduxjs/toolkit").Slice<AuthState, {
24
26
  storePostUrl: (state: AuthState, action: ActionState<{
25
27
  postUrl: string;
26
28
  }>) => void;
29
+ storeTerms: (state: AuthState, action: ActionState<{
30
+ termAndConditionChecked: boolean;
31
+ }>) => void;
27
32
  }, "auth/store">;
28
33
  export declare const clearError: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, stopLoader: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, resetOTPScreen: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, storeLeadId: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
29
34
  leadId: string;
30
35
  }, string>, storePostUrl: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
31
36
  postUrl: string;
37
+ }, string>, storeTerms: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
38
+ termAndConditionChecked: boolean;
32
39
  }, string>;
33
40
  declare const _default: import("redux").Reducer<AuthState, import("redux").AnyAction>;
34
41
  export default _default;
@@ -62,6 +62,7 @@ export var verifyAuthOTP = createAsyncThunk('verifyAuthOTPKit', function (params
62
62
  data: params.otp,
63
63
  post_url: postUrl,
64
64
  scopes: settings.data.appConfig.scope || [],
65
+ terms: auth.data.termAndConditionChecked ? ['general'] : [],
65
66
  encryption_contract: ['data']
66
67
  };
67
68
  return [4, API.authService.verifyAuthKitOTP(payload)];
@@ -82,7 +83,9 @@ var initialState = {
82
83
  leadId: '',
83
84
  postUrl: '',
84
85
  otp: '',
85
- mobileNumber: ''
86
+ mobileNumber: '',
87
+ nid: '',
88
+ termAndConditionChecked: false
86
89
  }
87
90
  };
88
91
  export var authSlice = createSlice({
@@ -105,6 +108,10 @@ export var authSlice = createSlice({
105
108
  storePostUrl: function (state, action) {
106
109
  var postUrl = action.payload.postUrl;
107
110
  state.data.postUrl = postUrl;
111
+ },
112
+ storeTerms: function (state, action) {
113
+ var termAndConditionChecked = action.payload.termAndConditionChecked;
114
+ state.data.termAndConditionChecked = termAndConditionChecked;
108
115
  }
109
116
  },
110
117
  extraReducers: function (builder) {
@@ -124,6 +131,7 @@ export var authSlice = createSlice({
124
131
  return;
125
132
  }
126
133
  state.data.mobileNumber = ((_c = (_b = data === null || data === void 0 ? void 0 : data.contact) === null || _b === void 0 ? void 0 : _b.phone) === null || _c === void 0 ? void 0 : _c.number) || '';
134
+ state.data.nid = data === null || data === void 0 ? void 0 : data.identification_id;
127
135
  })
128
136
  .addCase(retrieveLead.rejected, function (state, action) {
129
137
  state.loading = false;
@@ -143,6 +151,6 @@ export var authSlice = createSlice({
143
151
  });
144
152
  }
145
153
  });
146
- export var clearError = (_a = authSlice.actions, _a.clearError), stopLoader = _a.stopLoader, resetOTPScreen = _a.resetOTPScreen, storeLeadId = _a.storeLeadId, storePostUrl = _a.storePostUrl;
154
+ export var clearError = (_a = authSlice.actions, _a.clearError), stopLoader = _a.stopLoader, resetOTPScreen = _a.resetOTPScreen, storeLeadId = _a.storeLeadId, storePostUrl = _a.storePostUrl, storeTerms = _a.storeTerms;
147
155
  export default authSlice.reducer;
148
156
  export var authSelector = function (state) { return state.auth; };
@@ -57,7 +57,7 @@ var Auth = memo(function (_a) {
57
57
  }, []);
58
58
  useEffect(function () {
59
59
  var leadId = (props || {}).leadId;
60
- if (!settingLoading)
60
+ if (!settingLoading && activeScreen.name === 'AUTH_NID_STEP')
61
61
  dispatch(retrieveLead(leadId));
62
62
  }, [settingLoading]);
63
63
  var handleDialogClose = function () {
@@ -0,0 +1,3 @@
1
+ import * as React from 'react';
2
+ declare const _default: React.MemoExoticComponent<React.ForwardRefExoticComponent<React.RefAttributes<unknown>>>;
3
+ export default _default;
@@ -0,0 +1,48 @@
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, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import * as React from 'react';
14
+ import Box from '@mui/material/Box';
15
+ import { useTranslation } from 'react-i18next';
16
+ import { useController, useFormContext } from 'react-hook-form';
17
+ import { styled, alpha } from '@mui/material/styles';
18
+ import Text from '../../../../components/Text';
19
+ import Input from '../../../shared/Input';
20
+ import CheckIcon from '../../../shared/CheckIcon';
21
+ import ScreenContainer from '../../../shared/Containers/ScreenContainer';
22
+ import { ID_NUMBER_LENGTH } from '../../../../constants';
23
+ var LabelContainerStyled = styled(Box)(function (_a) {
24
+ var theme = _a.theme;
25
+ return ({
26
+ display: 'flex',
27
+ justifyContent: 'space-between',
28
+ padding: theme.spacing(0, 2.5, 1.25, 2.5)
29
+ });
30
+ });
31
+ var InputLabelStyled = styled(Text)(function (_a) {
32
+ var theme = _a.theme;
33
+ return (__assign(__assign({ color: alpha(theme.palette.text.primary, 0.6), fontWeight: theme.typography.fontWeightMedium }, theme.typography.caption), { lineHeight: theme.spacing(2.5) }));
34
+ });
35
+ var IDNumber = React.forwardRef(function (_a, ref) {
36
+ var _b;
37
+ var t = useTranslation().t;
38
+ var _c = useFormContext(), control = _c.control, setValue = _c.setValue;
39
+ var nidControl = useController({ control: control, name: 'nid' });
40
+ React.useEffect(function () {
41
+ if (nidControl.field.value)
42
+ setValue('nid', nidControl.field.value, { shouldValidate: true });
43
+ }, []);
44
+ var nidValue = nidControl.field.value;
45
+ var error = (_b = nidControl.fieldState.error) === null || _b === void 0 ? void 0 : _b.message;
46
+ return (_jsxs(ScreenContainer, __assign({ ref: ref }, { children: [_jsx(LabelContainerStyled, { children: _jsx(InputLabelStyled, { children: t('enter_national_id') }) }), _jsx(Input, { dir: 'ltr', type: 'tel', readOnly: true, inputProps: { maxLength: ID_NUMBER_LENGTH }, value: nidValue, endAdornment: !error && nidValue ? _jsx(CheckIcon, {}) : _jsx(_Fragment, {}), placeholder: t('national_id_placeholder'), warningType: 'alert', warningMessage: error && t(error, { number: '1' }), required: true })] })));
47
+ });
48
+ export default React.memo(IDNumber);
@@ -0,0 +1,5 @@
1
+ import * as React from 'react';
2
+ export interface NIDProps {
3
+ }
4
+ declare const _default: React.MemoExoticComponent<({}: NIDProps) => JSX.Element>;
5
+ export default _default;
@@ -0,0 +1,60 @@
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 { useTranslation } from 'react-i18next';
15
+ import { styled } from '@mui/material/styles';
16
+ import { useForm, FormProvider } from 'react-hook-form';
17
+ import { yupResolver } from '@hookform/resolvers/yup';
18
+ import { NIDValidationSchema } from './validation';
19
+ import { useAppDispatch, useLanguage, useAppSelector } from '../../../../hooks';
20
+ import { handleNextScreenStep, settingsSelector } from '../../../../app/settings';
21
+ import { clearError, authSelector, storeTerms } from '../../../app/auth/authStore';
22
+ import Form from '../../../../components/Form';
23
+ import Button from '../../../shared/Button';
24
+ import { ScreenContainer } from '../../../shared/Containers';
25
+ import IDNumber from './IDNumber';
26
+ import TAC from './TAC';
27
+ var FormStyled = styled(Form)(function () { return ({
28
+ display: 'flex',
29
+ flexDirection: 'column'
30
+ }); });
31
+ var NID = function (_a) {
32
+ var isAr = useLanguage().isAr;
33
+ var dispatch = useAppDispatch();
34
+ var t = useTranslation().t;
35
+ var _b = useAppSelector(authSelector), data = _b.data, loading = _b.loading, error = _b.error;
36
+ var settingsStore = useAppSelector(settingsSelector);
37
+ var methods = useForm({
38
+ resolver: yupResolver(NIDValidationSchema),
39
+ defaultValues: {
40
+ nid: data.nid,
41
+ termAndConditionChecked: data.termAndConditionChecked
42
+ },
43
+ mode: 'onChange'
44
+ });
45
+ React.useEffect(function () {
46
+ handleClearError();
47
+ }, [methods.formState.isValid]);
48
+ var onSubmit = function (data) {
49
+ var termAndConditionChecked = data.termAndConditionChecked;
50
+ dispatch(storeTerms({ termAndConditionChecked: termAndConditionChecked }));
51
+ dispatch(handleNextScreenStep());
52
+ };
53
+ var handleClearError = function () {
54
+ if (error)
55
+ dispatch(clearError());
56
+ };
57
+ var disabled = !methods.formState.isValid || !!error;
58
+ return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(IDNumber, {}), _jsx(TAC, {}), _jsx(Button, __assign({ loading: loading, isAr: isAr, disableBack: true, disabled: disabled || settingsStore.loading, error: t(error || '') }, { children: t('next') }))] })) })) }));
59
+ };
60
+ export default React.memo(NID);
@@ -0,0 +1,3 @@
1
+ import * as React from 'react';
2
+ declare const _default: React.MemoExoticComponent<() => JSX.Element>;
3
+ export default _default;
@@ -0,0 +1,79 @@
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 { useTranslation } from 'react-i18next';
15
+ import { useController, useFormContext } from 'react-hook-form';
16
+ import Box from '@mui/material/Box';
17
+ import { styled, alpha } from '@mui/material/styles';
18
+ import Link from '@mui/material/Link';
19
+ import CheckBox from '../../../../components/CheckBox';
20
+ import { ScreenContainer } from '../../../shared/Containers';
21
+ import Text from '../../../../components/Text';
22
+ import Warning from '../../../../components/Warning';
23
+ import { useLanguage } from '../../../../hooks';
24
+ import Collapse from '../../../../components/Collapse';
25
+ import { EXTERNAL_LINKS } from '../../../../constants';
26
+ var TACContainerStyled = styled(Box)(function (_a) {
27
+ var theme = _a.theme;
28
+ return ({
29
+ display: 'flex',
30
+ flexDirection: 'row',
31
+ alignItems: 'center',
32
+ paddingInlineStart: theme.spacing(2.5)
33
+ });
34
+ });
35
+ var TextStyled = styled(Text)(function (_a) {
36
+ var theme = _a.theme;
37
+ return (__assign({ color: alpha(theme.palette.text.primary, 0.4), fontWeight: theme.typography.fontWeightLight, whiteSpace: 'pre-line', height: 'fit-content' }, theme.typography.body2));
38
+ });
39
+ var LinkStyled = styled(Link)(function (_a) {
40
+ var theme = _a.theme;
41
+ return ({
42
+ color: theme.palette.primary.main,
43
+ fontWeight: theme.typography.fontWeightMedium,
44
+ letterSpacing: theme.spacing(0)
45
+ });
46
+ });
47
+ var CheckboxStyled = styled(CheckBox)(function (_a) {
48
+ var theme = _a.theme;
49
+ return ({
50
+ margin: theme.spacing(0),
51
+ padding: theme.spacing(0),
52
+ marginInlineEnd: theme.spacing(1.5),
53
+ color: theme.palette.primary.main,
54
+ '& .MuiSvgIcon-root': {
55
+ fontSize: theme.spacing(3.75)
56
+ },
57
+ '&.Mui-checked': {
58
+ color: theme.palette.text.primary,
59
+ borderRadius: theme.spacing(2.5)
60
+ }
61
+ });
62
+ });
63
+ var CollapseStyled = styled(Collapse)(function () { return ({
64
+ width: '100%'
65
+ }); });
66
+ var TAC = function () {
67
+ var _a;
68
+ var t = useTranslation().t;
69
+ var isAr = useLanguage().isAr;
70
+ var control = useFormContext().control;
71
+ var tacControl = useController({ control: control, name: 'termAndConditionChecked' });
72
+ var tacChecked = tacControl.field.value;
73
+ var warningMessage = (_a = tacControl.fieldState.error) === null || _a === void 0 ? void 0 : _a.message;
74
+ var handleTACCheckedChange = function (event, checked) {
75
+ tacControl.field.onChange(checked);
76
+ };
77
+ return (_jsxs(ScreenContainer, __assign({ sx: { mt: 3, mb: 1.625 } }, { children: [_jsxs(TACContainerStyled, { children: [_jsx(CheckboxStyled, { disableRipple: true, disableFocusRipple: true, focusRipple: false, checked: tacChecked, onChange: handleTACCheckedChange }), _jsxs(TextStyled, { children: [t('read_agree_terms_and_conditions_message'), _jsx(LinkStyled, __assign({ href: isAr ? EXTERNAL_LINKS.TOS_AR : EXTERNAL_LINKS.TOS_EN, target: '_blank', underline: 'always' }, { children: t('terms_and_conditions_link_title') }))] })] }), _jsx(CollapseStyled, __assign({ in: !!warningMessage }, { children: _jsx(Warning, __assign({ warningType: 'alert' }, { children: warningMessage && t(warningMessage) })) }))] })));
78
+ };
79
+ export default React.memo(TAC);
@@ -0,0 +1,3 @@
1
+ import NID, { NIDProps } from './NID';
2
+ export type { NIDProps };
3
+ export default NID;
@@ -0,0 +1,2 @@
1
+ import NID from './NID';
2
+ export default NID;
@@ -0,0 +1,11 @@
1
+ import * as yup from 'yup';
2
+ export declare const NIDValidationSchema: yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
3
+ nid: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
4
+ termAndConditionChecked: yup.BooleanSchema<boolean | undefined, import("yup/lib/types").AnyObject, true>;
5
+ }>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
6
+ nid: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
7
+ termAndConditionChecked: yup.BooleanSchema<boolean | undefined, import("yup/lib/types").AnyObject, true>;
8
+ }>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
9
+ nid: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
10
+ termAndConditionChecked: yup.BooleanSchema<boolean | undefined, import("yup/lib/types").AnyObject, true>;
11
+ }>>>;
@@ -0,0 +1,9 @@
1
+ import * as yup from 'yup';
2
+ export var NIDValidationSchema = yup.object().shape({
3
+ nid: yup
4
+ .string()
5
+ .matches(/^(1|2)([0-9]{1,})$/g, 'signup_invalid_national_id_format')
6
+ .min(10, 'signup_invalid_national_id')
7
+ .required('signup_invalid_national_id'),
8
+ termAndConditionChecked: yup.boolean().required().isTrue('check_terms_cond')
9
+ });
@@ -67,6 +67,6 @@ var OTP = function () {
67
67
  };
68
68
  var disabled = !methods.formState.isValid || !!error;
69
69
  var phone = data.mobileNumber;
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'), !loading && _jsx("span", __assign({ dir: 'ltr' }, { children: maskPhone(phone) }))] }) }), _jsx(OTPInput, {}), _jsx(Button, __assign({ disabled: disabled, disableBack: true, isAr: isAr, loading: loading, error: t(error || '') }, { children: t('confirm') }))] })) })) }));
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('opt_nid_sent_title', { provider: 'ABSHER' }), !loading && _jsx("span", __assign({ dir: 'ltr' }, { children: maskPhone(phone) }))] }) }), _jsx(OTPInput, {}), _jsx(Button, __assign({ disabled: disabled, disableBack: true, isAr: isAr, loading: loading, error: t(error || '') }, { children: t('confirm') }))] })) })) }));
71
71
  };
72
72
  export default React.memo(OTP);
@@ -48,6 +48,7 @@ import EntitySuccessPage from './entity/screens/Success';
48
48
  import EntitySuccessWithFlowPage from './entity/screens/SuccessWithFlowButtons';
49
49
  import EntityResetPasswordSuccessPage from './entity/screens/ResetPasswordSuccess';
50
50
  import OtpVerifyPage from '../features/otp/screens/OTPVerify';
51
+ import AuthNIDPage from './auth/screens/NID';
51
52
  import AuthVerifyPage from './auth/screens/OTP';
52
53
  export var connectFeatureScreens = [
53
54
  {
@@ -244,6 +245,10 @@ export var otpFeatureScreens = [
244
245
  }
245
246
  ];
246
247
  export var authFeatureScreens = [
248
+ {
249
+ name: 'AUTH_NID_STEP',
250
+ element: AuthNIDPage
251
+ },
247
252
  {
248
253
  name: 'AUTH_VERIFY_STEP',
249
254
  element: AuthVerifyPage
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tap-payments/auth-jsconnect",
3
- "version": "2.0.81-test",
3
+ "version": "2.0.83-test",
4
4
  "description": "connect library, auth",
5
5
  "private": false,
6
6
  "main": "build/index.js",