@tap-payments/auth-jsconnect 1.0.34 → 1.0.35

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.
@@ -73,7 +73,9 @@ export interface BusinessData {
73
73
  verify: ResponseData & VerifyData;
74
74
  businessCountry: CountryCode;
75
75
  countries: CountryCode[];
76
- otpData: OTPFormValues & ResponseData;
76
+ otpData: OTPFormValues & ResponseData & {
77
+ isNID: boolean;
78
+ };
77
79
  nidData: NIDFormValues & ResponseData & {
78
80
  type: string;
79
81
  };
@@ -100,14 +100,14 @@ export var verifyLeadToken = createAsyncThunk('verifyLeadToken', function (token
100
100
  });
101
101
  }); });
102
102
  export var verifyLeadOTP = createAsyncThunk('verifyLeadOTP', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
103
- var _a, business, settings, responseBody, isNID, payload, data;
103
+ var _a, business, settings, isNID, responseBody, payload, data;
104
104
  var _b, _c, _d;
105
105
  return __generator(this, function (_e) {
106
106
  switch (_e.label) {
107
107
  case 0:
108
108
  _a = thunkApi.getState(), business = _a.business, settings = _a.settings;
109
- responseBody = business.data.verify.responseBody;
110
- isNID = settings.data.activeScreen.name === 'BUSINESS_IDBOD_STEP';
109
+ isNID = business.data.otpData.isNID;
110
+ responseBody = (isNID ? business.data.nidData : business.data.verify).responseBody;
111
111
  payload = {
112
112
  data: params.otp,
113
113
  service_name: (_b = responseBody === null || responseBody === void 0 ? void 0 : responseBody.verification_by) === null || _b === void 0 ? void 0 : _b.service_name,
@@ -139,13 +139,17 @@ export var verifyLeadOTP = createAsyncThunk('verifyLeadOTP', function (params, t
139
139
  });
140
140
  }); });
141
141
  export var updateLeadIdentity = createAsyncThunk('updateLeadIdentity', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
142
- var _a, settings, business, identification_id_type, requestBody, data;
143
- var _b, _c;
144
- return __generator(this, function (_d) {
145
- switch (_d.label) {
142
+ var _a, settings, business, identification_id_type, headers, requestBody, data;
143
+ var _b, _c, _d, _e, _f;
144
+ return __generator(this, function (_g) {
145
+ switch (_g.label) {
146
146
  case 0:
147
147
  _a = thunkApi.getState(), settings = _a.settings, business = _a.business;
148
148
  identification_id_type = params.nid.startsWith('1') ? IDENTIFICATION_TYPE.NID : IDENTIFICATION_TYPE.IQAMA;
149
+ headers = {
150
+ lead_id: ((_b = business.data.otpData.responseBody) === null || _b === void 0 ? void 0 : _b.id) || '',
151
+ device_identifier: (_d = (_c = settings.data.deviceInfo) === null || _c === void 0 ? void 0 : _c.browser) === null || _d === void 0 ? void 0 : _d.browser_id
152
+ };
149
153
  requestBody = {
150
154
  identification_id: params.nid,
151
155
  identification_id_type: identification_id_type,
@@ -154,12 +158,12 @@ export var updateLeadIdentity = createAsyncThunk('updateLeadIdentity', function
154
158
  step_name: BUSINESS_STEP_NAMES.IDENTITY_AUTH,
155
159
  encryption_contract: ['country_code', 'identification_id', 'identification_id_type', 'date_of_birth']
156
160
  };
157
- return [4, API.leadService.updateLeadIdentity(requestBody)];
161
+ return [4, API.leadService.updateLeadIdentity(requestBody, { headers: headers })];
158
162
  case 1:
159
- data = (_d.sent()).data;
163
+ data = (_g.sent()).data;
160
164
  if (!data.errors && !params.isResend) {
161
165
  thunkApi.dispatch(handleNextScreenStep());
162
- (_c = (_b = settings.data.appConfig).onStepCompleted) === null || _c === void 0 ? void 0 : _c.call(_b, settings.data.activeScreen.name, requestBody);
166
+ (_f = (_e = settings.data.appConfig).onStepCompleted) === null || _f === void 0 ? void 0 : _f.call(_e, settings.data.activeScreen.name, requestBody);
163
167
  }
164
168
  return [2, { data: data, formData: __assign(__assign({}, params), { type: identification_id_type }) }];
165
169
  }
@@ -342,7 +346,8 @@ var initialState = {
342
346
  token: ''
343
347
  },
344
348
  otpData: {
345
- otp: ''
349
+ otp: '',
350
+ isNID: false
346
351
  },
347
352
  nidData: {
348
353
  nid: '',
@@ -414,6 +419,7 @@ export var businessSlice = createSlice({
414
419
  }
415
420
  state.data.verify.responseBody = __assign(__assign({}, data), leadData);
416
421
  state.data.verify.token = token;
422
+ state.data.otpData.isNID = false;
417
423
  })
418
424
  .addCase(verifyLeadToken.rejected, function (state, action) {
419
425
  state.error = action.error.message;
@@ -455,6 +461,8 @@ export var businessSlice = createSlice({
455
461
  }
456
462
  state.data.nidData = formData;
457
463
  state.data.nidData.responseBody = data;
464
+ state.data.otpData.otp = '';
465
+ state.data.otpData.isNID = true;
458
466
  })
459
467
  .addCase(updateLeadIdentity.rejected, function (state, action) {
460
468
  state.loading = false;
@@ -55,6 +55,6 @@ var IDBOD = function (_a) {
55
55
  dispatch(handlePrevScreenStep());
56
56
  };
57
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(Collapse, __assign({ in: !collapse }, { children: _jsx(ID, {}) })), _jsx(DOB, { onDateClicked: handleCollapseOpenClose }), _jsx(Collapse, __assign({ in: !collapse }, { children: _jsx(Button, __assign({ loading: loading, sx: { mt: 6 }, isAr: isAr, disabled: disabled, onBackClicked: function () { return onBack(); }, error: t(error || '') }, { children: t('next') })) }))] })) })) }));
58
+ return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(Collapse, __assign({ in: !collapse }, { children: _jsx(ID, {}) })), _jsx(DOB, { onDateClicked: handleCollapseOpenClose }), _jsx(Collapse, __assign({ in: !collapse }, { children: _jsx(Button, __assign({ loading: loading, disableBack: true, isAr: isAr, disabled: disabled, onBackClicked: function () { return onBack(); }, error: t(error || '') }, { children: t('next') })) }))] })) })) }));
59
59
  };
60
60
  export default React.memo(IDBOD);
@@ -3,8 +3,7 @@ export var NIDValidationSchema = yup.object().shape({
3
3
  dob: yup.string().min(5).required('enter_valid_birth_date'),
4
4
  nid: yup
5
5
  .string()
6
- .matches(/^(1)([0-9]{1,})$/g, 'signup_invalid_national_id_format')
7
- .min(8, 'signup_invalid_national_id_format')
8
- .max(10, 'signup_invalid_national_id_format')
6
+ .matches(/^(1|2)([0-9]{1,})$/g, 'signup_invalid_national_id_format')
7
+ .min(10, 'signup_invalid_national_id')
9
8
  .required('signup_invalid_national_id')
10
9
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tap-payments/auth-jsconnect",
3
- "version": "1.0.34",
3
+ "version": "1.0.35",
4
4
  "description": "connect library, auth",
5
5
  "private": false,
6
6
  "main": "build/index.js",