@tap-payments/auth-jsconnect 2.0.94-test → 2.0.96-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.
@@ -62,9 +62,12 @@ export declare type CreatePasswordBody = {
62
62
  encryption_contract: Array<string>;
63
63
  };
64
64
  export declare type VerifyAuthKitOTPBody = {
65
- lead_id: string;
66
- verify_token?: string;
65
+ auth_token?: string;
67
66
  data: string;
67
+ auth_type: number;
68
+ service_name: string;
69
+ sign_in: boolean;
70
+ device_token: string;
68
71
  post_url: string;
69
72
  scopes?: Array<string>;
70
73
  terms: Array<string>;
@@ -77,5 +80,6 @@ declare const authService: {
77
80
  verifyAuthKitOTP: (data: VerifyAuthKitOTPBody) => Promise<any>;
78
81
  getVerifyAuth: (token: string, config?: AxiosRequestConfig) => Promise<any>;
79
82
  getTokenVerify: (token: string, config?: AxiosRequestConfig) => Promise<any>;
83
+ createAuthKitNID: (data: CreateAuthBody) => Promise<any>;
80
84
  };
81
85
  export { authService };
package/build/api/auth.js CHANGED
@@ -32,17 +32,25 @@ var getTokenVerify = function (token, config) {
32
32
  };
33
33
  var verifyAuthKitOTP = function (data) {
34
34
  return httpClient({
35
- method: 'post',
35
+ method: 'put',
36
36
  url: "".concat(ENDPOINT_PATHS.VERIFY_AUTH_OTP),
37
37
  data: data
38
38
  });
39
39
  };
40
+ var createAuthKitNID = function (data) {
41
+ return httpClient({
42
+ method: 'post',
43
+ url: "".concat(ENDPOINT_PATHS.CREATE_AUTH_NID),
44
+ data: data
45
+ });
46
+ };
40
47
  var authService = {
41
48
  createAuth: createAuth,
42
49
  verifyAuth: verifyAuth,
43
50
  createPassword: createPassword,
44
51
  verifyAuthKitOTP: verifyAuthKitOTP,
45
52
  getVerifyAuth: getVerifyAuth,
46
- getTokenVerify: getTokenVerify
53
+ getTokenVerify: getTokenVerify,
54
+ createAuthKitNID: createAuthKitNID
47
55
  };
48
56
  export { authService };
@@ -27,6 +27,7 @@ declare const API: {
27
27
  verifyAuthKitOTP: (data: VerifyAuthKitOTPBody) => Promise<any>;
28
28
  getVerifyAuth: (token: string, config?: import("axios").AxiosRequestConfig<any> | undefined) => Promise<any>;
29
29
  getTokenVerify: (token: string, config?: import("axios").AxiosRequestConfig<any> | undefined) => Promise<any>;
30
+ createAuthKitNID: (data: CreateAuthBody) => Promise<any>;
30
31
  };
31
32
  leadService: {
32
33
  createLead: (data: CreateLeadBody, config?: import("axios").AxiosRequestConfig<any> | undefined) => Promise<import("axios").AxiosResponse<any, any>>;
@@ -75,9 +75,11 @@ export declare type CreateLeadBody = {
75
75
  };
76
76
  export declare type LeadIdentityUpdateBody = {
77
77
  id: string;
78
- country_code: string;
79
- identification_id: string;
80
- identification_id_type?: string;
78
+ identification: {
79
+ id: string;
80
+ issued_country_code: string;
81
+ type: string;
82
+ };
81
83
  date_of_birth?: string;
82
84
  step_name?: string;
83
85
  encryption_contract: Array<string>;
@@ -36,4 +36,5 @@ export declare const ENDPOINT_PATHS: {
36
36
  VERIFY_AUTH_OTP: string;
37
37
  RETRIEVE_ACTIVITIES_LIST_PATH: string;
38
38
  DOCUMENT: string;
39
+ CREATE_AUTH_NID: string;
39
40
  };
@@ -34,7 +34,8 @@ var TOKEN_VERIFY_PATH = '/token/verify';
34
34
  var RETRIEVE_USER_INFO_PATH = '/user';
35
35
  var BOARD_PATH = '/board';
36
36
  var CONNECT_PATH = '/connect';
37
- var VERIFY_AUTH_OTP_PATH = "".concat(CONNECT_PATH, "/lead/verify");
37
+ var CREATE_AUTH_NID_PATH = "".concat(CONNECT_PATH, "/auth");
38
+ var VERIFY_AUTH_OTP_PATH = "".concat(CONNECT_PATH, "/auth");
38
39
  var DOCUMENT_PATH = '/document';
39
40
  export var ENDPOINT_PATHS = {
40
41
  SANDBOX_BASE_URL: SANDBOX_BASE_URL,
@@ -73,5 +74,6 @@ export var ENDPOINT_PATHS = {
73
74
  BRAND_SALES_CHANNELS: BRAND_SALES_CHANNELS,
74
75
  VERIFY_AUTH_OTP: VERIFY_AUTH_OTP_PATH,
75
76
  RETRIEVE_ACTIVITIES_LIST_PATH: RETRIEVE_ACTIVITIES_LIST_PATH,
76
- DOCUMENT: DOCUMENT_PATH
77
+ DOCUMENT: DOCUMENT_PATH,
78
+ CREATE_AUTH_NID: CREATE_AUTH_NID_PATH
77
79
  };
@@ -63,8 +63,8 @@ export var ICONS_NAMES = {
63
63
  GMAIL_White_ICON: 'https://dash.b-cdn.net/icons/menu/Gmail-white.svg',
64
64
  outlook_Filled_ICON: 'https://dash.b-cdn.net/icons/menu/Outlook-filled.svg',
65
65
  outlook_White_ICON: 'https://dash.b-cdn.net/icons/menu/Outlook-white.svg',
66
- Apple_Filled_ICON: 'https://dash.b-cdn.net/icons/menu/Apple-filled.svg',
67
- apple_white_icon: 'https://dash.b-cdn.net/icons/menu/Apple-white.svg',
66
+ Apple_Filled_ICON: 'https://dash.b-cdn.net/icons/menu/Apple-mail-filled.svg',
67
+ apple_white_icon: 'https://dash.b-cdn.net/icons/menu/Apple-mail-white.svg',
68
68
  Mail_Filled_icon: 'https://dash.b-cdn.net/icons/menu/Mail-filled.svg',
69
69
  Mail_white_icon: 'https://dash.b-cdn.net/icons/menu/Mail-white.svg',
70
70
  tax_filled_icon: 'https://dash.b-cdn.net/icons/menu/tax-filled-blue.svg',
@@ -5,6 +5,10 @@ export declare const verifyAuthOTP: import("@reduxjs/toolkit").AsyncThunk<{
5
5
  response: any;
6
6
  formData: OTPFormValues;
7
7
  }, OTPFormValues, {}>;
8
+ export declare const createAuth: import("@reduxjs/toolkit").AsyncThunk<{
9
+ data: any;
10
+ formData: IDFormValues;
11
+ }, IDFormValues, {}>;
8
12
  export declare const resendOTP: import("@reduxjs/toolkit").AsyncThunk<any, void, {}>;
9
13
  export interface AuthData extends ResponseData {
10
14
  verifyToken: string | undefined;
@@ -13,6 +17,7 @@ export interface AuthData extends ResponseData {
13
17
  otp: string;
14
18
  nid: string;
15
19
  termAndConditionChecked: boolean;
20
+ device_token?: string;
16
21
  dob: string;
17
22
  type: string;
18
23
  countryISOCode: string;
@@ -30,13 +35,12 @@ export declare const authSlice: import("@reduxjs/toolkit").Slice<AuthState, {
30
35
  storePostUrl: (state: AuthState, action: ActionState<{
31
36
  postUrl: string;
32
37
  }>) => void;
33
- storeData: (state: AuthState, action: ActionState<IDFormValues>) => void;
34
38
  }, "auth/store">;
35
39
  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<{
36
40
  leadId: string;
37
41
  }, string>, storePostUrl: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
38
42
  postUrl: string;
39
- }, string>, storeData: import("@reduxjs/toolkit").ActionCreatorWithPayload<IDFormValues, string>;
43
+ }, string>;
40
44
  declare const _default: import("redux").Reducer<AuthState, import("redux").AnyAction>;
41
45
  export default _default;
42
46
  export declare const authSelector: (state: RootState) => AuthState;
@@ -36,9 +36,10 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
36
36
  };
37
37
  var _a;
38
38
  import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
39
- import { handleOpen } from '../../../app/settings';
39
+ import { handleNextScreenStep, handleOpen } from '../../../app/settings';
40
40
  import API from '../../../api';
41
41
  import { getEighteenYearsAgo } from '../../../utils';
42
+ import { IDENTIFICATION_TYPE } from '../../../constants';
42
43
  export var retrieveLead = createAsyncThunk('retrieveLeadAuthKit', function (leadId) { return __awaiter(void 0, void 0, void 0, function () {
43
44
  var data;
44
45
  return __generator(this, function (_a) {
@@ -51,18 +52,22 @@ export var retrieveLead = createAsyncThunk('retrieveLeadAuthKit', function (lead
51
52
  });
52
53
  }); });
53
54
  export var verifyAuthOTP = createAsyncThunk('verifyAuthOTPKit', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
54
- var _a, settings, auth, _b, leadId, postUrl, verifyToken, payload, data;
55
+ var _a, settings, auth, _b, postUrl, verifyToken, device_token, payload, data;
55
56
  var _c, _d, _e, _f;
56
57
  return __generator(this, function (_g) {
57
58
  switch (_g.label) {
58
59
  case 0:
59
60
  _a = thunkApi.getState(), settings = _a.settings, auth = _a.auth;
60
- _b = auth.data, leadId = _b.leadId, postUrl = _b.postUrl, verifyToken = _b.verifyToken;
61
+ _b = auth.data, postUrl = _b.postUrl, verifyToken = _b.verifyToken, device_token = _b.device_token;
61
62
  payload = {
62
- lead_id: leadId,
63
- verify_token: verifyToken,
63
+ auth_token: verifyToken,
64
64
  data: params.otp,
65
65
  post_url: postUrl,
66
+ auth_type: 2,
67
+ device_token: device_token || '',
68
+ service_name: 'absher',
69
+ sign_in: false,
70
+ scopes: settings.data.appConfig.scope || [],
66
71
  terms: auth.data.termAndConditionChecked ? ['general'] : [],
67
72
  encryption_contract: ['data']
68
73
  };
@@ -76,24 +81,72 @@ export var verifyAuthOTP = createAsyncThunk('verifyAuthOTPKit', function (params
76
81
  }
77
82
  });
78
83
  }); });
79
- export var resendOTP = createAsyncThunk('authResendOTP', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
80
- var auth, _a, nid, dob, type, countryISOCode, leadId, requestBody, data;
81
- return __generator(this, function (_b) {
82
- switch (_b.label) {
84
+ export var createAuth = createAsyncThunk('authCreateAuth', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
85
+ var _a, auth, settings, _b, type, countryISOCode, nid, dob, identification_id_type, requestBody, data;
86
+ return __generator(this, function (_c) {
87
+ switch (_c.label) {
83
88
  case 0:
84
- auth = thunkApi.getState().auth;
85
- _a = auth.data || {}, nid = _a.nid, dob = _a.dob, type = _a.type, countryISOCode = _a.countryISOCode, leadId = _a.leadId;
89
+ _a = thunkApi.getState(), auth = _a.auth, settings = _a.settings;
90
+ _b = auth.data, type = _b.type, countryISOCode = _b.countryISOCode;
91
+ nid = params.nid, dob = params.dob;
92
+ identification_id_type = type
93
+ ? type
94
+ : params.nid.startsWith('1')
95
+ ? IDENTIFICATION_TYPE.NID
96
+ : IDENTIFICATION_TYPE.IQAMA;
86
97
  requestBody = {
87
- id: leadId,
88
- identification_id: nid,
89
- identification_id_type: type,
90
- date_of_birth: dob,
91
- country_code: countryISOCode,
92
- encryption_contract: ['country_code', 'identification_id', 'identification_id_type', 'date_of_birth']
98
+ lang: settings.data.language,
99
+ user_credentail: {
100
+ identification_id: nid,
101
+ identification_id_type: identification_id_type,
102
+ date_of_birth: dob,
103
+ country_code: countryISOCode || settings.data.businessCountry.iso2
104
+ },
105
+ sign_in: false,
106
+ is_lead: false,
107
+ encryption_contract: [
108
+ 'user_credentail.country_code',
109
+ 'user_credentail.identification_id',
110
+ 'user_credentail.identification_id_type',
111
+ 'user_credentail.date_of_birth'
112
+ ]
93
113
  };
94
- return [4, API.leadService.updateLead(requestBody)];
114
+ return [4, API.authService.createAuthKitNID(requestBody)];
95
115
  case 1:
96
- data = _b.sent();
116
+ data = _c.sent();
117
+ thunkApi.dispatch(handleNextScreenStep());
118
+ return [2, { data: data, formData: params }];
119
+ }
120
+ });
121
+ }); });
122
+ export var resendOTP = createAsyncThunk('authResendOTP', function (_, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
123
+ var _a, auth, settings, _b, nid, dob, type, countryISOCode, identification_id_type, requestBody, data;
124
+ return __generator(this, function (_c) {
125
+ switch (_c.label) {
126
+ case 0:
127
+ _a = thunkApi.getState(), auth = _a.auth, settings = _a.settings;
128
+ _b = auth.data, nid = _b.nid, dob = _b.dob, type = _b.type, countryISOCode = _b.countryISOCode;
129
+ identification_id_type = type ? type : nid.startsWith('1') ? IDENTIFICATION_TYPE.NID : IDENTIFICATION_TYPE.IQAMA;
130
+ requestBody = {
131
+ lang: settings.data.language,
132
+ user_credentail: {
133
+ identification_id: nid,
134
+ identification_id_type: identification_id_type,
135
+ date_of_birth: dob,
136
+ country_code: countryISOCode || settings.data.businessCountry.iso2
137
+ },
138
+ sign_in: false,
139
+ is_lead: false,
140
+ encryption_contract: [
141
+ 'user_credentail.country_code',
142
+ 'user_credentail.identification_id',
143
+ 'user_credentail.identification_id_type',
144
+ 'user_credentail.date_of_birth'
145
+ ]
146
+ };
147
+ return [4, API.authService.createAuthKitNID(requestBody)];
148
+ case 1:
149
+ data = _c.sent();
97
150
  return [2, data];
98
151
  }
99
152
  });
@@ -134,12 +187,6 @@ export var authSlice = createSlice({
134
187
  storePostUrl: function (state, action) {
135
188
  var postUrl = action.payload.postUrl;
136
189
  state.data.postUrl = postUrl;
137
- },
138
- storeData: function (state, action) {
139
- var _a = action.payload, termAndConditionChecked = _a.termAndConditionChecked, nid = _a.nid, dob = _a.dob;
140
- state.data.termAndConditionChecked = termAndConditionChecked;
141
- state.data.nid = nid;
142
- state.data.dob = dob;
143
190
  }
144
191
  },
145
192
  extraReducers: function (builder) {
@@ -149,7 +196,7 @@ export var authSlice = createSlice({
149
196
  state.error = null;
150
197
  })
151
198
  .addCase(retrieveLead.fulfilled, function (state, action) {
152
- var _a;
199
+ var _a, _b, _c, _d;
153
200
  state.customLoading = false;
154
201
  state.error = null;
155
202
  var data = action.payload;
@@ -158,15 +205,33 @@ export var authSlice = createSlice({
158
205
  state.error = description;
159
206
  return;
160
207
  }
161
- state.data.nid = data === null || data === void 0 ? void 0 : data.identification_id;
208
+ state.data.nid = (_b = data === null || data === void 0 ? void 0 : data.identification) === null || _b === void 0 ? void 0 : _b.id;
162
209
  state.data.dob = data === null || data === void 0 ? void 0 : data.date_of_birth;
163
- state.data.type = data === null || data === void 0 ? void 0 : data.identification_id_type;
164
- state.data.countryISOCode = data === null || data === void 0 ? void 0 : data.country_code;
210
+ state.data.type = (_c = data === null || data === void 0 ? void 0 : data.identification) === null || _c === void 0 ? void 0 : _c.type;
211
+ state.data.countryISOCode = ((_d = data === null || data === void 0 ? void 0 : data.identification) === null || _d === void 0 ? void 0 : _d.issued_country_code) || (data === null || data === void 0 ? void 0 : data.country_code);
165
212
  state.data.responseBody = data;
166
213
  })
167
214
  .addCase(retrieveLead.rejected, function (state, action) {
168
215
  state.loading = false;
169
216
  state.error = action.error.message;
217
+ })
218
+ .addCase(createAuth.pending, function (state) {
219
+ state.loading = true;
220
+ state.error = null;
221
+ })
222
+ .addCase(createAuth.fulfilled, function (state, action) {
223
+ state.loading = false;
224
+ state.error = null;
225
+ var _a = action.payload, data = _a.data, formData = _a.formData;
226
+ state.data.verifyToken = data === null || data === void 0 ? void 0 : data.auth_token;
227
+ state.data.dob = formData.dob;
228
+ state.data.nid = formData.nid;
229
+ state.data.termAndConditionChecked = formData.termAndConditionChecked;
230
+ state.data.device_token = data === null || data === void 0 ? void 0 : data.device_token;
231
+ })
232
+ .addCase(createAuth.rejected, function (state, action) {
233
+ state.loading = false;
234
+ state.error = action.error.message;
170
235
  })
171
236
  .addCase(verifyAuthOTP.pending, function (state) {
172
237
  state.loading = true;
@@ -186,13 +251,13 @@ export var authSlice = createSlice({
186
251
  .addCase(resendOTP.fulfilled, function (state, action) {
187
252
  state.error = null;
188
253
  var data = action.payload;
189
- state.data.verifyToken = data === null || data === void 0 ? void 0 : data.verify_token;
254
+ state.data.verifyToken = data === null || data === void 0 ? void 0 : data.auth_token;
190
255
  })
191
256
  .addCase(resendOTP.rejected, function (state, action) {
192
257
  state.error = action.error.message;
193
258
  });
194
259
  }
195
260
  });
196
- export var clearError = (_a = authSlice.actions, _a.clearError), stopLoader = _a.stopLoader, resetOTPScreen = _a.resetOTPScreen, storeLeadId = _a.storeLeadId, storePostUrl = _a.storePostUrl, storeData = _a.storeData;
261
+ export var clearError = (_a = authSlice.actions, _a.clearError), stopLoader = _a.stopLoader, resetOTPScreen = _a.resetOTPScreen, storeLeadId = _a.storeLeadId, storePostUrl = _a.storePostUrl;
197
262
  export default authSlice.reducer;
198
263
  export var authSelector = function (state) { return state.auth; };
@@ -61,7 +61,7 @@ import API from '../../../api';
61
61
  import { BusinessType, FlowsTypes } from '../../../@types';
62
62
  import { BUSINESS_FLOW_SUCCESS, BUSINESS_STEP_NAMES, IDENTIFICATION_TYPE, OTHER_CR_LICENSE, OTHER_FL_LICENSE } from '../../../constants';
63
63
  import { convertNumbers2English, getEighteenYearsAgo, hasKey, sleep, isKW, isSA } from '../../../utils';
64
- import { handleNextScreenStep } from '../../../app/settings';
64
+ import { handleNextScreenStep, handleSetCountryByIso2 } from '../../../app/settings';
65
65
  export var verifyLeadToken = createAsyncThunk('businessVerifyLeadToken', function (token, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
66
66
  var payload, data, leadResponse, brandInfo, boardResponse, countryIso2, steps, brandID, hasBusinessCompleted, hasBusinessCRInfoCompleted, hasBusinessCRActivitiesCompleted, hasBusinessCustomersCompleted, entity_activities, data_1, board_id, board_info_id;
67
67
  var _a, _b, _c, _d, _e, _f, _g;
@@ -84,6 +84,7 @@ export var verifyLeadToken = createAsyncThunk('businessVerifyLeadToken', functio
84
84
  case 2:
85
85
  leadResponse = _h.sent();
86
86
  countryIso2 = (_a = leadResponse === null || leadResponse === void 0 ? void 0 : leadResponse.data) === null || _a === void 0 ? void 0 : _a.country_code;
87
+ thunkApi.dispatch(handleSetCountryByIso2(countryIso2));
87
88
  if (data.step_name === BUSINESS_STEP_NAMES.IDENTITY_AUTH && isKW(countryIso2)) {
88
89
  thunkApi.dispatch(handleNextScreenStep('BUSINESS_CIVIL_ID_STEP'));
89
90
  }
@@ -210,6 +211,7 @@ export var verifyLeadOTP = createAsyncThunk('verifyLeadOTP', function (params, t
210
211
  _b = (leadResponse === null || leadResponse === void 0 ? void 0 : leadResponse.data) || {}, brand = _b.brand, country_code = _b.country_code, steps = _b.steps, board_id = _b.board_id, board_info_id = _b.board_info_id;
211
212
  brandID = brand === null || brand === void 0 ? void 0 : brand.id;
212
213
  countryIso2 = country_code;
214
+ thunkApi.dispatch(handleSetCountryByIso2(countryIso2));
213
215
  (_h = (_g = settings.data.appConfig).onStepCompleted) === null || _h === void 0 ? void 0 : _h.call(_g, settings.data.activeScreen.name, { otp: params.otp });
214
216
  hasBusinessCompleted = hasKey(steps, BUSINESS_STEP_NAMES.BUSINESS_SUCCESS);
215
217
  hasBusinessCRInfoCompleted = hasKey(steps, BUSINESS_STEP_NAMES.BUSINESS_CR_INFO) && hasKey(steps, BUSINESS_STEP_NAMES.BUSINESS_INFO_CONFIRM);
@@ -325,80 +327,96 @@ export var verifyPACI = createAsyncThunk('businessVerifyPACI', function (params,
325
327
  });
326
328
  }); });
327
329
  export var createCivilIdAuth = createAsyncThunk('createCivilIdAuth', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
328
- var _a, settings, business, stepName, _b, lead_id, country_code, requestBody, data;
329
- var _c, _d;
330
- return __generator(this, function (_e) {
331
- switch (_e.label) {
330
+ var _a, settings, business, stepName, lead_id, requestBody, data;
331
+ var _b, _c;
332
+ return __generator(this, function (_d) {
333
+ switch (_d.label) {
332
334
  case 0:
333
335
  _a = thunkApi.getState(), settings = _a.settings, business = _a.business;
334
336
  stepName = BUSINESS_STEP_NAMES.CREATE_AUTH_CIVIL_ID;
335
- _b = business.data.verify.responseBody || {}, lead_id = _b.lead_id, country_code = _b.country_code;
337
+ lead_id = (business.data.verify.responseBody || {}).lead_id;
336
338
  requestBody = {
337
339
  id: lead_id || '',
338
- identification_id: params.civilId,
339
- country_code: country_code || settings.data.businessCountry.iso2,
340
+ identification: {
341
+ id: params.civilId,
342
+ issued_country_code: settings.data.businessCountry.iso2,
343
+ type: 'civil_id'
344
+ },
340
345
  step_name: stepName,
341
- identification_id_type: 'civil_id',
342
- encryption_contract: ['identification_id']
346
+ encryption_contract: ['identification.id', 'identification.issued_country_code', 'identification.type']
343
347
  };
344
348
  return [4, API.leadService.updateLead(requestBody)];
345
349
  case 1:
346
- data = _e.sent();
350
+ data = _d.sent();
347
351
  thunkApi.dispatch(handleNextScreenStep());
348
- (_d = (_c = settings.data.appConfig).onStepCompleted) === null || _d === void 0 ? void 0 : _d.call(_c, settings.data.activeScreen.name, requestBody);
352
+ (_c = (_b = settings.data.appConfig).onStepCompleted) === null || _c === void 0 ? void 0 : _c.call(_b, settings.data.activeScreen.name, requestBody);
349
353
  return [2, { response: data, formData: params }];
350
354
  }
351
355
  });
352
356
  }); });
353
357
  export var updateLeadIdentity = createAsyncThunk('updateLeadIdentity', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
354
- var _a, settings, business, identification_id_type, stepName, _b, lead_id, country_code, requestBody, data;
355
- var _c, _d;
356
- return __generator(this, function (_e) {
357
- switch (_e.label) {
358
+ var _a, settings, business, identification_id_type, stepName, lead_id, requestBody, data;
359
+ var _b, _c;
360
+ return __generator(this, function (_d) {
361
+ switch (_d.label) {
358
362
  case 0:
359
363
  _a = thunkApi.getState(), settings = _a.settings, business = _a.business;
360
364
  identification_id_type = params.nid.startsWith('1') ? IDENTIFICATION_TYPE.NID : IDENTIFICATION_TYPE.IQAMA;
361
365
  stepName = BUSINESS_STEP_NAMES.IDENTITY_AUTH;
362
- _b = business.data.verify.responseBody || {}, lead_id = _b.lead_id, country_code = _b.country_code;
366
+ lead_id = (business.data.verify.responseBody || {}).lead_id;
363
367
  requestBody = {
364
368
  id: lead_id || '',
365
- identification_id: params.nid,
366
- identification_id_type: identification_id_type,
369
+ identification: {
370
+ id: params.nid,
371
+ issued_country_code: settings.data.businessCountry.iso2,
372
+ type: identification_id_type
373
+ },
367
374
  date_of_birth: params.dob,
368
- country_code: country_code || settings.data.businessCountry.iso2,
369
375
  step_name: stepName,
370
- encryption_contract: ['country_code', 'identification_id', 'identification_id_type', 'date_of_birth']
376
+ encryption_contract: [
377
+ 'identification.issued_country_code',
378
+ 'identification.id',
379
+ 'identification.type',
380
+ 'date_of_birth'
381
+ ]
371
382
  };
372
383
  return [4, API.leadService.updateLead(requestBody)];
373
384
  case 1:
374
- data = _e.sent();
385
+ data = _d.sent();
375
386
  thunkApi.dispatch(handleNextScreenStep());
376
- (_d = (_c = settings.data.appConfig).onStepCompleted) === null || _d === void 0 ? void 0 : _d.call(_c, settings.data.activeScreen.name, requestBody);
387
+ (_c = (_b = settings.data.appConfig).onStepCompleted) === null || _c === void 0 ? void 0 : _c.call(_b, settings.data.activeScreen.name, requestBody);
377
388
  return [2, { data: data, formData: __assign(__assign({}, params), { type: identification_id_type }) }];
378
389
  }
379
390
  });
380
391
  }); });
381
392
  export var resendOTPLeadIdentity = createAsyncThunk('resendOTPLeadIdentity', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
382
- var _a, settings, business, _b, nid, dob, type, stepName, _c, lead_id, country_code, requestBody, data;
383
- return __generator(this, function (_d) {
384
- switch (_d.label) {
393
+ var _a, settings, business, _b, nid, dob, type, stepName, lead_id, requestBody, data;
394
+ return __generator(this, function (_c) {
395
+ switch (_c.label) {
385
396
  case 0:
386
397
  _a = thunkApi.getState(), settings = _a.settings, business = _a.business;
387
398
  _b = business.data.nidData, nid = _b.nid, dob = _b.dob, type = _b.type;
388
399
  stepName = BUSINESS_STEP_NAMES.IDENTITY_AUTH;
389
- _c = business.data.verify.responseBody || {}, lead_id = _c.lead_id, country_code = _c.country_code;
400
+ lead_id = (business.data.verify.responseBody || {}).lead_id;
390
401
  requestBody = {
391
402
  id: lead_id || '',
392
- identification_id: nid,
393
- identification_id_type: type,
403
+ identification: {
404
+ id: nid,
405
+ issued_country_code: settings.data.businessCountry.iso2,
406
+ type: type
407
+ },
394
408
  date_of_birth: dob,
395
- country_code: country_code || settings.data.businessCountry.iso2,
396
409
  step_name: stepName,
397
- encryption_contract: ['country_code', 'identification_id', 'identification_id_type', 'date_of_birth']
410
+ encryption_contract: [
411
+ 'identification.issued_country_code',
412
+ 'identification.id',
413
+ 'identification.type',
414
+ 'date_of_birth'
415
+ ]
398
416
  };
399
417
  return [4, API.leadService.updateLead(requestBody)];
400
418
  case 1:
401
- data = _d.sent();
419
+ data = _c.sent();
402
420
  return [2, data];
403
421
  }
404
422
  });
@@ -548,18 +566,17 @@ export var updateActivitiesInfo = createAsyncThunk('updateActivitiesInfo', funct
548
566
  });
549
567
  }); });
550
568
  export var retrieveDataList = createAsyncThunk('businessRetrieveDataList', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
551
- var _a, settings, business, country_code, dataBody, salesDataBody, _b, customerBases, expectedSales, expectedCustomerSales;
552
- return __generator(this, function (_c) {
553
- switch (_c.label) {
569
+ var settings, dataBody, salesDataBody, _a, customerBases, expectedSales, expectedCustomerSales;
570
+ return __generator(this, function (_b) {
571
+ switch (_b.label) {
554
572
  case 0:
555
- _a = thunkApi.getState(), settings = _a.settings, business = _a.business;
556
- country_code = (business.data.verify.responseBody || {}).country_code;
573
+ settings = thunkApi.getState().settings;
557
574
  dataBody = {
558
575
  page: 0
559
576
  };
560
577
  salesDataBody = {
561
578
  page: 0,
562
- country_code: [country_code || settings.data.businessCountry.iso2]
579
+ country_code: [settings.data.businessCountry.iso2]
563
580
  };
564
581
  return [4, Promise.all([
565
582
  API.dataService.getCustomerBases(dataBody),
@@ -567,7 +584,7 @@ export var retrieveDataList = createAsyncThunk('businessRetrieveDataList', funct
567
584
  API.dataService.getExpectedCustomerSales(dataBody)
568
585
  ])];
569
586
  case 1:
570
- _b = _c.sent(), customerBases = _b[0], expectedSales = _b[1], expectedCustomerSales = _b[2];
587
+ _a = _b.sent(), customerBases = _a[0], expectedSales = _a[1], expectedCustomerSales = _a[2];
571
588
  return [2, {
572
589
  customerBases: customerBases,
573
590
  expectedSales: expectedSales,
@@ -37,13 +37,13 @@ var InputLabelStyled = styled(Text)(function (_a) {
37
37
  return (__assign(__assign({ color: alpha(theme.palette.text.primary, 0.6), fontWeight: theme.typography.fontWeightMedium }, theme.typography.caption), { lineHeight: theme.spacing(2.5) }));
38
38
  });
39
39
  var IDNumber = React.forwardRef(function (_a, ref) {
40
- var _b;
40
+ var _b, _c;
41
41
  var t = useTranslation().t;
42
- var _c = useFormContext(), control = _c.control, setValue = _c.setValue;
42
+ var _d = useFormContext(), control = _d.control, setValue = _d.setValue;
43
43
  var nidControl = useController({ control: control, name: 'nid' });
44
44
  var data = useAppSelector(authSelector).data;
45
45
  var responseBody = data.responseBody;
46
- var defaultNid = responseBody === null || responseBody === void 0 ? void 0 : responseBody.identification_id;
46
+ var defaultNid = (_b = responseBody === null || responseBody === void 0 ? void 0 : responseBody.identification) === null || _b === void 0 ? void 0 : _b.id;
47
47
  React.useEffect(function () {
48
48
  if (nidControl.field.value)
49
49
  setValue('nid', nidControl.field.value, { shouldValidate: true });
@@ -57,7 +57,7 @@ var IDNumber = React.forwardRef(function (_a, ref) {
57
57
  nidControl.field.onChange('');
58
58
  };
59
59
  var nidValue = nidControl.field.value;
60
- var error = (_b = nidControl.fieldState.error) === null || _b === void 0 ? void 0 : _b.message;
60
+ var error = (_c = nidControl.fieldState.error) === null || _c === void 0 ? void 0 : _c.message;
61
61
  var readOnly = !!defaultNid;
62
62
  return (_jsxs(ScreenContainer, __assign({ ref: ref }, { children: [_jsx(LabelContainerStyled, { children: _jsx(InputLabelStyled, { children: t('enter_national_id') }) }), _jsx(Input, { dir: 'ltr', type: 'tel', readOnly: readOnly, inputProps: { maxLength: ID_NUMBER_LENGTH }, value: nidValue, onChange: handleIdChange, endAdornment: !error && nidValue ? _jsx(CheckIcon, {}) : readOnly ? _jsx(_Fragment, {}) : nidValue && _jsx(ClearIcon, { onClick: clearIdNumber }), placeholder: t('national_id_placeholder'), warningType: 'alert', warningMessage: error && t(error, { number: '1' }), required: true })] })));
63
63
  });
@@ -17,8 +17,8 @@ import { useForm, FormProvider } from 'react-hook-form';
17
17
  import { yupResolver } from '@hookform/resolvers/yup';
18
18
  import { NIDValidationSchema, NIDDOBValidationSchema } from './validation';
19
19
  import { useAppDispatch, useLanguage, useAppSelector } from '../../../../hooks';
20
- import { handleNextScreenStep, settingsSelector } from '../../../../app/settings';
21
- import { clearError, authSelector, storeData } from '../../../app/auth/authStore';
20
+ import { settingsSelector } from '../../../../app/settings';
21
+ import { clearError, authSelector, createAuth } from '../../../app/auth/authStore';
22
22
  import Form from '../../../../components/Form';
23
23
  import Button from '../../../shared/Button';
24
24
  import { ScreenContainer } from '../../../shared/Containers';
@@ -52,8 +52,7 @@ var NID = function (_a) {
52
52
  handleClearError();
53
53
  }, [methods.formState.isValid]);
54
54
  var onSubmit = function (data) {
55
- dispatch(storeData(data));
56
- dispatch(handleNextScreenStep());
55
+ dispatch(createAuth(data));
57
56
  };
58
57
  var handleCollapseOpenClose = function (flag) {
59
58
  setCollapse(flag);
@@ -44,12 +44,12 @@ var ButtonGroupStyled = styled(Box)(function (_a) {
44
44
  });
45
45
  });
46
46
  var SuccessWithFlowButtons = function () {
47
- var _a, _b, _c;
47
+ var _a, _b, _c, _d;
48
48
  var t = useTranslation().t;
49
49
  var isAr = useLanguage().isAr;
50
50
  var data = useAppSelector(businessSelector).data;
51
- var _d = data.verify.responseBody || {}, flows = _d.flows, nameObj = _d.name, entity = _d.entity, brand = _d.brand, bank = _d.bank_account, merchant = _d.merchant, identification_id = _d.identification_id;
52
- var _e = useState([]), buttons = _e[0], setButtons = _e[1];
51
+ var _e = data.verify.responseBody || {}, flows = _e.flows, nameObj = _e.name, entity = _e.entity, brand = _e.brand, bank = _e.bank_account, merchant = _e.merchant, identification = _e.identification;
52
+ var _f = useState([]), buttons = _f[0], setButtons = _f[1];
53
53
  var username = ((nameObj === null || nameObj === void 0 ? void 0 : nameObj.first) || '') + ' ' + ((nameObj === null || nameObj === void 0 ? void 0 : nameObj.last) || '');
54
54
  var licenseNumber = ((_a = entity === null || entity === void 0 ? void 0 : entity.license) === null || _a === void 0 ? void 0 : _a.number) || '';
55
55
  var bankName = (bank === null || bank === void 0 ? void 0 : bank.bank_name) || t('bank');
@@ -58,9 +58,9 @@ var SuccessWithFlowButtons = function () {
58
58
  var brandName = (isAr ? (_b = brand === null || brand === void 0 ? void 0 : brand.name) === null || _b === void 0 ? void 0 : _b.ar : (_c = brand === null || brand === void 0 ? void 0 : brand.name) === null || _c === void 0 ? void 0 : _c.en) || '';
59
59
  var isAcceptance = merchant === null || merchant === void 0 ? void 0 : merchant.is_acceptance_allowed;
60
60
  var isPayout = merchant === null || merchant === void 0 ? void 0 : merchant.is_payout_allowed;
61
- var maskedId = !!identification_id ? " ".concat(t('masking_symbols')).concat(identification_id === null || identification_id === void 0 ? void 0 : identification_id.slice(-2)) : '';
61
+ var maskedId = !!(identification === null || identification === void 0 ? void 0 : identification.id) ? " ".concat(t('masking_symbols')).concat((_d = identification === null || identification === void 0 ? void 0 : identification.id) === null || _d === void 0 ? void 0 : _d.slice(-2)) : '';
62
62
  var settings = useAppSelector(settingsSelector);
63
- var _f = data.verify.responseBody || { contact: {}, board_id: '' }, contact = _f.contact, board_id = _f.board_id, board_info_id = _f.board_info_id;
63
+ var _g = data.verify.responseBody || { contact: {}, board_id: '' }, contact = _g.contact, board_id = _g.board_id, board_info_id = _g.board_info_id;
64
64
  var email = (contact || { email: '' }).email;
65
65
  var url = getResetFlowUrl('/password', settings.data.language, PASSWORD_OPERATION_TYPE.RESET_PASSWORD, board_id, board_info_id);
66
66
  var reMapFlowData = function (flows) {
@@ -104,9 +104,8 @@ var BrandName = function (_a) {
104
104
  var _c = React.useState(false), isHovered = _c[0], setIsHovered = _c[1];
105
105
  var t = useTranslation().t;
106
106
  var data = useAppSelector(connectSelector).data;
107
- var _d = useFormContext(), control = _d.control, watch = _d.watch, setValue = _d.setValue;
107
+ var control = useFormContext().control;
108
108
  var brandControl = useController({ control: control, name: 'brandName' });
109
- var salesChannels = watch('salesChannels');
110
109
  var brandNameValue = brandControl.field.value;
111
110
  var error = (_b = brandControl.fieldState.error) === null || _b === void 0 ? void 0 : _b.message;
112
111
  var checkBrand = debounce(function (value) { return __awaiter(void 0, void 0, void 0, function () {
@@ -121,26 +120,10 @@ var BrandName = function (_a) {
121
120
  return [2];
122
121
  });
123
122
  }); }, 500);
124
- var updateSalesChannelsWebsiteUrl = function (value) {
125
- if (!value)
126
- return;
127
- if (!salesChannels.length)
128
- return;
129
- var brandValue = value.replaceAll(' ', '-').toLowerCase();
130
- var address = (brandValue[brandValue.length - 1] === '-' ? brandValue.slice(0, -1) : brandValue) + '.com';
131
- var updatedSalesChannels = salesChannels.map(function (channel) {
132
- if (channel.code.toLowerCase() === 'website') {
133
- return __assign(__assign({}, channel), { address: address });
134
- }
135
- return channel;
136
- });
137
- setValue('salesChannels', updatedSalesChannels, { shouldValidate: true });
138
- };
139
123
  var handleBrandNameChange = function (_a) {
140
124
  var target = _a.target;
141
125
  var value = removeAllOtherThanCharsNumbersAndSpace(target.value);
142
126
  brandControl.field.onChange(value);
143
- updateSalesChannelsWebsiteUrl(value);
144
127
  };
145
128
  React.useEffect(function () {
146
129
  var _a, _b, _c;
@@ -10,6 +10,7 @@ var __assign = (this && this.__assign) || function () {
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
12
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import React from 'react';
13
14
  import Button from '../../../components/Button';
14
15
  import { styled } from '@mui/material/styles';
15
16
  import Box from '@mui/material/Box';
@@ -61,5 +62,6 @@ export default function EmailProvidersButtons(_a) {
61
62
  var _b;
62
63
  var gmail = _a.gmail, outlook = _a.outlook, apple = _a.apple, mail = _a.mail;
63
64
  var os = getBrowserInfo().os;
64
- return (_jsxs(ButtonBoxStyled, { children: [_jsx(Link, __assign({ href: gmail.href, underline: 'none', target: '_blank' }, { children: _jsx(GMailButtonStyled, __assign({ variant: 'outlined', startIcon: _jsx(Image, { src: ICONS_NAMES.GMAIL_Filled_ICON, alt: gmail.title }), type: 'button' }, { children: gmail.title })) })), ((_b = os === null || os === void 0 ? void 0 : os.name) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === 'windows' ? (_jsx(Link, __assign({ href: mail.href, underline: 'none', target: '_blank' }, { children: _jsx(OutlookButtonStyled, __assign({ variant: 'outlined', startIcon: _jsx(Image, { src: ICONS_NAMES.Mail_Filled_icon, alt: outlook.title }), type: 'button' }, { children: mail.title })) }))) : (_jsx(Link, __assign({ href: apple.href, underline: 'none', target: '_blank' }, { children: _jsx(AppleButtonStyled, __assign({ variant: 'outlined', startIcon: _jsx(Image, { src: ICONS_NAMES.Apple_Filled_ICON, alt: apple.title }), type: 'button' }, { children: apple.title })) }))), _jsx(Link, __assign({ href: outlook.href, underline: 'none', target: '_blank' }, { children: _jsx(OutlookButtonStyled, __assign({ variant: 'outlined', startIcon: _jsx(Image, { src: ICONS_NAMES.outlook_Filled_ICON, alt: outlook.title }), type: 'button' }, { children: outlook.title })) }))] }));
65
+ var _c = React.useState(false), hoverApple = _c[0], setHoverApple = _c[1];
66
+ return (_jsxs(ButtonBoxStyled, { children: [_jsx(Link, __assign({ href: gmail.href, underline: 'none', target: '_blank' }, { children: _jsx(GMailButtonStyled, __assign({ variant: 'outlined', startIcon: _jsx(Image, { src: ICONS_NAMES.GMAIL_Filled_ICON, alt: gmail.title }), type: 'button' }, { children: gmail.title })) })), ((_b = os === null || os === void 0 ? void 0 : os.name) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === 'windows' ? (_jsx(Link, __assign({ href: mail.href, underline: 'none', target: '_blank' }, { children: _jsx(OutlookButtonStyled, __assign({ variant: 'outlined', onMouseDown: function () { return setHoverApple(true); }, onMouseUp: function () { return setHoverApple(false); }, startIcon: _jsx(Image, { src: ICONS_NAMES.Mail_Filled_icon, alt: outlook.title }), type: 'button' }, { children: mail.title })) }))) : (_jsx(Link, __assign({ href: apple.href, underline: 'none', target: '_blank' }, { children: _jsx(AppleButtonStyled, __assign({ variant: 'outlined', onMouseEnter: function () { return setHoverApple(true); }, onMouseLeave: function () { return setHoverApple(false); }, startIcon: _jsx(Image, { src: hoverApple ? ICONS_NAMES.apple_white_icon : ICONS_NAMES.Apple_Filled_ICON, alt: apple.title }), type: 'button' }, { children: apple.title })) }))), _jsx(Link, __assign({ href: outlook.href, underline: 'none', target: '_blank' }, { children: _jsx(OutlookButtonStyled, __assign({ variant: 'outlined', startIcon: _jsx(Image, { src: ICONS_NAMES.outlook_Filled_ICON, alt: outlook.title }), type: 'button' }, { children: outlook.title })) }))] }));
65
67
  }
@@ -56,6 +56,6 @@ var ThankYou = function (_a) {
56
56
  var title = _a.title, description = _a.description, showEmailProviders = _a.showEmailProviders, onSuccess = _a.onSuccess, successTitle = _a.successTitle, loading = _a.loading, error = _a.error;
57
57
  var t = useTranslation().t;
58
58
  var isAr = useLanguage().isAr;
59
- return (_jsxs(ContainerStyled, { children: [_jsx(IconStyled, { src: ICONS_NAMES.SUCCESS_GIF, alt: 'loading...' }), _jsxs(TitleStyled, { children: [title, " "] }), _jsx(DescriptionStyled, { children: description }), showEmailProviders && (_jsx(MailBoxStyled, { children: _jsx(EmailProvidersButton, { gmail: { title: t('gmail_btn_open_title'), href: 'https://mail.google.com/mail/u/0/#inbox' }, outlook: { title: t('outlook_btn_open_title'), href: 'https://outlook.live.com/mail/0/' }, apple: { title: t('apple_btn_open_title'), href: 'https://www.icloud.com/mail/' }, mail: { title: t('mail_btn_open_title'), href: 'mailto:' } }) })), onSuccess && !showEmailProviders && (_jsx(MailBoxStyled, { children: _jsx(SuccessButton, __assign({ onClick: onSuccess, disableBack: true, disableNextIcon: true, disabled: loading, isAr: isAr, loading: loading, error: t(error || '') }, { children: t(successTitle || '') })) }))] }));
59
+ return (_jsxs(ContainerStyled, { children: [_jsx(IconStyled, { src: ICONS_NAMES.SUCCESS_GIF, alt: 'loading...' }), _jsxs(TitleStyled, { children: [title, " "] }), _jsx(DescriptionStyled, { children: description }), showEmailProviders && (_jsx(MailBoxStyled, { children: _jsx(EmailProvidersButton, { gmail: { title: t('gmail_btn_open_title'), href: 'https://mail.google.com/mail/u/0/#inbox' }, outlook: { title: t('outlook_btn_open_title'), href: 'https://outlook.live.com/mail/0/' }, apple: { title: t('apple_btn_open_title'), href: 'mailto:' }, mail: { title: t('mail_btn_open_title'), href: 'mailto:' } }) })), onSuccess && !showEmailProviders && (_jsx(MailBoxStyled, { children: _jsx(SuccessButton, __assign({ onClick: onSuccess, disableBack: true, disableNextIcon: true, disabled: loading, isAr: isAr, loading: loading, error: t(error || '') }, { children: t(successTitle || '') })) }))] }));
60
60
  };
61
61
  export default React.memo(ThankYou);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tap-payments/auth-jsconnect",
3
- "version": "2.0.94-test",
3
+ "version": "2.0.96-test",
4
4
  "description": "connect library, auth",
5
5
  "private": false,
6
6
  "main": "build/index.js",