@tap-payments/auth-jsconnect 2.0.123-test → 2.0.124-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.
@@ -8,10 +8,10 @@ export declare type EmailCredential = {
8
8
  email: string;
9
9
  };
10
10
  export declare type IDCredential = {
11
- country_code: string;
11
+ country_code?: string;
12
12
  identification_id: string;
13
- identification_id_type: string;
14
- date_of_birth: string;
13
+ identification_id_type?: string;
14
+ date_of_birth?: string;
15
15
  };
16
16
  export declare type CivilID = {
17
17
  identification_id: string;
@@ -26,6 +26,7 @@ export declare type CreateAuthBody = {
26
26
  step_name?: string;
27
27
  encryption_contract: Array<string>;
28
28
  lang?: LanguageMode;
29
+ lead_id?: string;
29
30
  };
30
31
  export declare type VerifyAuthBody = {
31
32
  auth_token: string;
@@ -5,6 +5,8 @@ export declare const VAT_ID_LENGTH = 15;
5
5
  export declare const MAX_IBAN_VALUE = 34;
6
6
  export declare const FL_NUMBER_LENGTH = 8;
7
7
  export declare const CR_NUMBER_LENGTH = 10;
8
+ export declare const FL_MIN_LICENSE_LENGTH = 5;
9
+ export declare const CR_MIN_LICENSE_LENGTH = 5;
8
10
  export declare const KW_MIN_LICENSE_LENGTH = 3;
9
11
  export declare const KW_MAX_LICENSE_LENGTH = 50;
10
12
  export declare const SAUDI_NUMBER_LENGTH = 9;
@@ -5,6 +5,8 @@ export var VAT_ID_LENGTH = 15;
5
5
  export var MAX_IBAN_VALUE = 34;
6
6
  export var FL_NUMBER_LENGTH = 8;
7
7
  export var CR_NUMBER_LENGTH = 10;
8
+ export var FL_MIN_LICENSE_LENGTH = 5;
9
+ export var CR_MIN_LICENSE_LENGTH = 5;
8
10
  export var KW_MIN_LICENSE_LENGTH = 3;
9
11
  export var KW_MAX_LICENSE_LENGTH = 50;
10
12
  export var SAUDI_NUMBER_LENGTH = 9;
@@ -20,7 +20,6 @@ export interface AuthData extends ResponseData {
20
20
  device_token?: string;
21
21
  service_name?: string;
22
22
  dob: string;
23
- type: string;
24
23
  countryISOCode: string;
25
24
  }
26
25
  export interface AuthState extends SharedState<AuthData> {
@@ -83,30 +83,30 @@ export var verifyAuthOTP = createAsyncThunk('verifyAuthOTPKit', function (params
83
83
  });
84
84
  }); });
85
85
  export var createAuth = createAsyncThunk('authCreateAuth', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
86
- var _a, auth, settings, _b, type, countryISOCode, nid, dob, identification_id_type, requestBody, data;
87
- return __generator(this, function (_c) {
88
- switch (_c.label) {
86
+ var _a, auth, settings, _b, responseBody, leadId, nid, dob, identification_id_type, requestBody, data;
87
+ var _c;
88
+ return __generator(this, function (_d) {
89
+ switch (_d.label) {
89
90
  case 0:
90
91
  _a = thunkApi.getState(), auth = _a.auth, settings = _a.settings;
91
- _b = auth.data, type = _b.type, countryISOCode = _b.countryISOCode;
92
+ _b = auth.data, responseBody = _b.responseBody, leadId = _b.leadId;
92
93
  nid = params.nid, dob = params.dob;
93
- identification_id_type = type
94
- ? type
94
+ identification_id_type = ((_c = responseBody === null || responseBody === void 0 ? void 0 : responseBody.identification) === null || _c === void 0 ? void 0 : _c.id)
95
+ ? undefined
95
96
  : params.nid.startsWith('1')
96
97
  ? IDENTIFICATION_TYPE.NID
97
98
  : IDENTIFICATION_TYPE.IQAMA;
98
99
  requestBody = {
99
100
  lang: settings.data.language,
101
+ lead_id: leadId,
100
102
  user_credentail: {
101
103
  identification_id: nid,
102
104
  identification_id_type: identification_id_type,
103
- date_of_birth: dob,
104
- country_code: countryISOCode || settings.data.businessCountry.iso2
105
+ date_of_birth: !(responseBody === null || responseBody === void 0 ? void 0 : responseBody.date_of_birth) ? dob : undefined
105
106
  },
106
107
  sign_in: false,
107
108
  is_lead: false,
108
109
  encryption_contract: [
109
- 'user_credentail.country_code',
110
110
  'user_credentail.identification_id',
111
111
  'user_credentail.identification_id_type',
112
112
  'user_credentail.date_of_birth'
@@ -114,32 +114,36 @@ export var createAuth = createAsyncThunk('authCreateAuth', function (params, thu
114
114
  };
115
115
  return [4, API.authService.createAuthKitNID(requestBody)];
116
116
  case 1:
117
- data = _c.sent();
117
+ data = _d.sent();
118
118
  thunkApi.dispatch(handleNextScreenStep());
119
119
  return [2, { data: data, formData: params }];
120
120
  }
121
121
  });
122
122
  }); });
123
123
  export var resendOTP = createAsyncThunk('authResendOTP', function (_, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
124
- var _a, auth, settings, _b, nid, dob, type, countryISOCode, identification_id_type, requestBody, data;
125
- return __generator(this, function (_c) {
126
- switch (_c.label) {
124
+ var _a, auth, settings, _b, nid, dob, responseBody, leadId, identification_id_type, requestBody, data;
125
+ var _c;
126
+ return __generator(this, function (_d) {
127
+ switch (_d.label) {
127
128
  case 0:
128
129
  _a = thunkApi.getState(), auth = _a.auth, settings = _a.settings;
129
- _b = auth.data, nid = _b.nid, dob = _b.dob, type = _b.type, countryISOCode = _b.countryISOCode;
130
- identification_id_type = type ? type : nid.startsWith('1') ? IDENTIFICATION_TYPE.NID : IDENTIFICATION_TYPE.IQAMA;
130
+ _b = auth.data, nid = _b.nid, dob = _b.dob, responseBody = _b.responseBody, leadId = _b.leadId;
131
+ identification_id_type = ((_c = responseBody === null || responseBody === void 0 ? void 0 : responseBody.identification) === null || _c === void 0 ? void 0 : _c.id)
132
+ ? undefined
133
+ : nid.startsWith('1')
134
+ ? IDENTIFICATION_TYPE.NID
135
+ : IDENTIFICATION_TYPE.IQAMA;
131
136
  requestBody = {
132
137
  lang: settings.data.language,
138
+ lead_id: leadId,
133
139
  user_credentail: {
134
140
  identification_id: nid,
135
141
  identification_id_type: identification_id_type,
136
- date_of_birth: dob,
137
- country_code: countryISOCode || settings.data.businessCountry.iso2
142
+ date_of_birth: !(responseBody === null || responseBody === void 0 ? void 0 : responseBody.date_of_birth) ? dob : undefined
138
143
  },
139
144
  sign_in: false,
140
145
  is_lead: false,
141
146
  encryption_contract: [
142
- 'user_credentail.country_code',
143
147
  'user_credentail.identification_id',
144
148
  'user_credentail.identification_id_type',
145
149
  'user_credentail.date_of_birth'
@@ -147,7 +151,7 @@ export var resendOTP = createAsyncThunk('authResendOTP', function (_, thunkApi)
147
151
  };
148
152
  return [4, API.authService.createAuthKitNID(requestBody)];
149
153
  case 1:
150
- data = _c.sent();
154
+ data = _d.sent();
151
155
  return [2, data];
152
156
  }
153
157
  });
@@ -164,7 +168,6 @@ var initialState = {
164
168
  nid: '',
165
169
  termAndConditionChecked: false,
166
170
  dob: getEighteenYearsAgo(),
167
- type: '',
168
171
  countryISOCode: ''
169
172
  }
170
173
  };
@@ -197,14 +200,12 @@ export var authSlice = createSlice({
197
200
  state.error = null;
198
201
  })
199
202
  .addCase(retrieveLead.fulfilled, function (state, action) {
200
- var _a, _b, _c;
203
+ var _a;
201
204
  state.customLoading = false;
202
205
  state.error = null;
203
206
  var data = action.payload;
204
207
  state.data.nid = (_a = data === null || data === void 0 ? void 0 : data.identification) === null || _a === void 0 ? void 0 : _a.id;
205
- state.data.dob = data === null || data === void 0 ? void 0 : data.date_of_birth;
206
- state.data.type = (_b = data === null || data === void 0 ? void 0 : data.identification) === null || _b === void 0 ? void 0 : _b.type;
207
- state.data.countryISOCode = ((_c = data === null || data === void 0 ? void 0 : data.identification) === null || _c === void 0 ? void 0 : _c.issued_country_code) || (data === null || data === void 0 ? void 0 : data.country_code);
208
+ state.data.countryISOCode = data === null || data === void 0 ? void 0 : data.country_code;
208
209
  state.data.responseBody = data;
209
210
  })
210
211
  .addCase(retrieveLead.rejected, function (state, action) {
@@ -846,7 +846,7 @@ export var businessSlice = createSlice({
846
846
  var _a;
847
847
  return (_a = brandInfo === null || brandInfo === void 0 ? void 0 : brandInfo.activities) === null || _a === void 0 ? void 0 : _a.find(function (value) { return value.id === activity.id; });
848
848
  });
849
- var defaultActivities = (activities === null || activities === void 0 ? void 0 : activities.length) ? [activities[0]] : [];
849
+ var defaultActivities = (activities === null || activities === void 0 ? void 0 : activities[0]) ? [activities === null || activities === void 0 ? void 0 : activities[0]] : [];
850
850
  state.data.activitiesData.activities = (selectedActivity === null || selectedActivity === void 0 ? void 0 : selectedActivity.length) > 0 ? selectedActivity : defaultActivities;
851
851
  state.data.businessTypeData.responseBody = __assign(__assign({}, state.data.businessTypeData.responseBody), { entity_id: entity === null || entity === void 0 ? void 0 : entity.id, activities: activities });
852
852
  state.data.businessTypeData.entityLegalName = (business_name === null || business_name === void 0 ? void 0 : business_name.en) || '';
@@ -38,9 +38,9 @@ var NID = function (_a) {
38
38
  var _c = useAppSelector(authSelector), data = _c.data, loading = _c.loading, error = _c.error;
39
39
  var settingsStore = useAppSelector(settingsSelector);
40
40
  var nid = data.nid, dob = data.dob, termAndConditionChecked = data.termAndConditionChecked, responseBody = data.responseBody;
41
- var defaultDob = responseBody === null || responseBody === void 0 ? void 0 : responseBody.date_of_birth;
41
+ var isDobAvailable = responseBody === null || responseBody === void 0 ? void 0 : responseBody.date_of_birth;
42
42
  var methods = useForm({
43
- resolver: yupResolver(!defaultDob ? NIDDOBValidationSchema : NIDValidationSchema),
43
+ resolver: yupResolver(!isDobAvailable ? NIDDOBValidationSchema : NIDValidationSchema),
44
44
  defaultValues: {
45
45
  nid: nid,
46
46
  dob: dob,
@@ -63,6 +63,6 @@ var NID = function (_a) {
63
63
  dispatch(clearError());
64
64
  };
65
65
  var disabled = !methods.formState.isValid || !!error;
66
- return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(Collapse, __assign({ in: !collapse }, { children: _jsx(IDNumber, {}) })), _jsx(DOB, { show: !defaultDob, onDateClicked: handleCollapseOpenClose }), _jsxs(Collapse, __assign({ in: !collapse }, { children: [_jsx(TAC, {}), _jsx(Button, __assign({ loading: loading, isAr: isAr, disableBack: true, disabled: disabled || settingsStore.loading, error: t(error || '') }, { children: t('next') }))] }))] })) })) }));
66
+ return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(Collapse, __assign({ in: !collapse }, { children: _jsx(IDNumber, {}) })), _jsx(DOB, { show: !isDobAvailable, onDateClicked: handleCollapseOpenClose }), _jsxs(Collapse, __assign({ in: !collapse }, { children: [_jsx(TAC, {}), _jsx(Button, __assign({ loading: loading, isAr: isAr, disableBack: true, disabled: disabled || settingsStore.loading, error: t(error || '') }, { children: t('next') }))] }))] })) })) }));
67
67
  };
68
68
  export default React.memo(NID);
@@ -1,5 +1,5 @@
1
1
  import * as yup from 'yup';
2
- import { FL_NUMBER_LENGTH, CR_NUMBER_LENGTH, REGEX_BRAND_NAME, KW_MIN_LICENSE_LENGTH, MAX_FILE_SIZE, VALID_FILE_FORMATS } from '../../../../constants';
2
+ import { REGEX_BRAND_NAME, KW_MIN_LICENSE_LENGTH, MAX_FILE_SIZE, VALID_FILE_FORMATS, FL_MIN_LICENSE_LENGTH, CR_MIN_LICENSE_LENGTH } from '../../../../constants';
3
3
  import { BusinessType } from '../../../../@types';
4
4
  var objectElements = {
5
5
  legal_name: yup.object().shape({
@@ -23,9 +23,9 @@ export var LicenseValidationSchema = yup.object().shape({
23
23
  if (length === 0)
24
24
  return true;
25
25
  if (isCR) {
26
- return length === CR_NUMBER_LENGTH ? true : this.createError({ message: 'cr_max_length' });
26
+ return length > CR_MIN_LICENSE_LENGTH ? true : this.createError({ message: 'cr_max_length' });
27
27
  }
28
- return length === FL_NUMBER_LENGTH ? true : this.createError({ message: 'fl_max_length' });
28
+ return length > FL_MIN_LICENSE_LENGTH ? true : this.createError({ message: 'fl_max_length' });
29
29
  }
30
30
  })
31
31
  .required('')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tap-payments/auth-jsconnect",
3
- "version": "2.0.123-test",
3
+ "version": "2.0.124-test",
4
4
  "description": "connect library, auth",
5
5
  "private": false,
6
6
  "main": "build/index.js",