@tap-payments/auth-jsconnect 1.0.23 → 1.0.26

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 (33) hide show
  1. package/build/@types/app.d.ts +16 -0
  2. package/build/api/axios.js +20 -1
  3. package/build/api/lead.d.ts +1 -0
  4. package/build/app/settings.d.ts +4 -2
  5. package/build/app/settings.js +30 -2
  6. package/build/components/Button/Button.js +1 -0
  7. package/build/constants/app.d.ts +1 -0
  8. package/build/constants/app.js +1 -0
  9. package/build/constants/dummy.d.ts +1 -0
  10. package/build/constants/dummy.js +1 -0
  11. package/build/features/app/connect/connectStore.d.ts +1 -2
  12. package/build/features/app/connect/connectStore.js +85 -61
  13. package/build/features/connect/Connect.d.ts +2 -4
  14. package/build/features/connect/Connect.js +4 -4
  15. package/build/features/connect/screens/Individual/Email.js +1 -3
  16. package/build/features/connect/screens/Individual/Individual.js +4 -6
  17. package/build/features/connect/screens/Merchant/BrandName.js +7 -4
  18. package/build/features/connect/screens/Merchant/Merchant.js +5 -4
  19. package/build/features/connect/screens/Mobile/BusinessCountry.d.ts +0 -5
  20. package/build/features/connect/screens/Mobile/BusinessCountry.js +3 -24
  21. package/build/features/connect/screens/Mobile/Mobile.js +15 -5
  22. package/build/features/shared/Button/Button.js +25 -24
  23. package/build/hooks/index.d.ts +1 -0
  24. package/build/hooks/index.js +1 -0
  25. package/build/hooks/useAppConfig.d.ts +3 -5
  26. package/build/hooks/useAppConfig.js +29 -2
  27. package/build/hooks/useErrorListener.d.ts +1 -0
  28. package/build/hooks/useErrorListener.js +19 -0
  29. package/build/utils/index.d.ts +1 -0
  30. package/build/utils/index.js +1 -0
  31. package/build/utils/rsa.d.ts +2 -0
  32. package/build/utils/rsa.js +19 -0
  33. package/package.json +3 -2
@@ -1,4 +1,5 @@
1
1
  /// <reference types="react" />
2
+ import { LanguageMode } from './theme';
2
3
  export interface CountryCode {
3
4
  created: number;
4
5
  updated: number;
@@ -108,6 +109,21 @@ export interface SourceOfIncome {
108
109
  }
109
110
  export interface AppInfo {
110
111
  name: string;
112
+ identifier?: string;
113
+ version?: string;
114
+ }
115
+ interface LibCallbacks {
116
+ onFlowCompleted: (res: object) => void;
117
+ onError: (err: any) => void;
118
+ onStepCompleted?: (name: string, info: any) => void;
119
+ onReady?: () => void;
120
+ }
121
+ export interface LibConfig extends LibCallbacks {
122
+ publicKey: string;
123
+ language: LanguageMode;
124
+ appInfo: AppInfo;
125
+ businessCountryCode: string;
126
+ scope?: string[];
111
127
  }
112
128
  export interface OSDetails {
113
129
  name: string;
@@ -1,5 +1,7 @@
1
1
  import axios from 'axios';
2
+ import { get, set } from 'lodash-es';
2
3
  import { ENDPOINT_PATHS } from '../constants';
4
+ import { encryptString } from '../utils';
3
5
  export var ENCRYPTION_FLAG = 'encryption_contract';
4
6
  export var BACKEND_ENCRYPTION_FLAG = 'backend_encryption_contract';
5
7
  var instance = axios.create({
@@ -10,9 +12,26 @@ var instance = axios.create({
10
12
  }
11
13
  });
12
14
  instance.interceptors.request.use(function (config) {
13
- return config;
15
+ return encryptionContractTransformer(config);
14
16
  }, function (error) { return Promise.reject(error); });
15
17
  instance.interceptors.response.use(function (response) { return response; }, function (error) {
16
18
  return Promise.reject(error);
17
19
  });
20
+ var encryptionContractTransformer = function (config) {
21
+ var _a;
22
+ var data = config.data;
23
+ if ((_a = data === null || data === void 0 ? void 0 : data[ENCRYPTION_FLAG]) === null || _a === void 0 ? void 0 : _a.length) {
24
+ data[ENCRYPTION_FLAG].forEach(function (key) {
25
+ var value = get(data, key);
26
+ if (value && typeof value !== 'string') {
27
+ value = value.toString();
28
+ }
29
+ if (value)
30
+ set(data, key, _encrypt(value));
31
+ });
32
+ config.data = data;
33
+ }
34
+ return config;
35
+ };
36
+ var _encrypt = function (value) { return encryptString(value); };
18
37
  export default instance;
@@ -55,6 +55,7 @@ export declare type UpdateLeadBody = {
55
55
  cr_number?: string;
56
56
  is_acknowledged?: boolean;
57
57
  terms_conditions_accepted?: boolean;
58
+ email_url?: string;
58
59
  };
59
60
  declare const leadService: {
60
61
  updateLead: (data: UpdateLeadBody, config?: AxiosRequestConfig) => Promise<import("axios").AxiosResponse<any, any>>;
@@ -1,5 +1,5 @@
1
1
  import { RootState } from './store';
2
- import { ActionState, LanguageMode, SharedState, ThemeMode, ScreenStepNavigation, DeviceInfo, AppInfo } from '../@types';
2
+ import { ActionState, LanguageMode, SharedState, ThemeMode, ScreenStepNavigation, DeviceInfo, AppInfo, LibConfig } from '../@types';
3
3
  import { ValidateOperatorBody } from '../api';
4
4
  export declare const getClientIp: import("@reduxjs/toolkit").AsyncThunk<any, void, {}>;
5
5
  export declare const getBrowserFingerPrint: import("@reduxjs/toolkit").AsyncThunk<{
@@ -16,6 +16,7 @@ export interface SettingsData {
16
16
  activeScreen: ScreenStepNavigation;
17
17
  featureScreensNavigation: Array<ScreenStepNavigation>;
18
18
  deviceInfo: DeviceInfo;
19
+ appConfig: LibConfig;
19
20
  }
20
21
  export interface SettingsState extends SharedState<SettingsData> {
21
22
  }
@@ -26,8 +27,9 @@ export declare const settingsSlice: import("@reduxjs/toolkit").Slice<SettingsSta
26
27
  handleCurrentActiveScreen: (state: SettingsState, action: ActionState<string>) => void;
27
28
  handlePrevScreenStep: (state: SettingsState, action: ActionState<string | undefined>) => void;
28
29
  handleActiveFlowScreens: (state: SettingsState, action: ActionState<Array<ScreenStepNavigation>>) => void;
30
+ handleSetAppConfig: (state: SettingsState, action: ActionState<LibConfig>) => void;
29
31
  }, "settings">;
30
- export declare const handleSkin: import("@reduxjs/toolkit").ActionCreatorWithPayload<ThemeMode, string>, handleLanguage: import("@reduxjs/toolkit").ActionCreatorWithPayload<LanguageMode, string>, handleActiveFlowScreens: import("@reduxjs/toolkit").ActionCreatorWithPayload<ScreenStepNavigation[], string>, handleNextScreenStep: import("@reduxjs/toolkit").ActionCreatorWithOptionalPayload<string | undefined, string>, handlePrevScreenStep: import("@reduxjs/toolkit").ActionCreatorWithOptionalPayload<string | undefined, string>, handleCurrentActiveScreen: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, string>;
32
+ export declare const handleSkin: import("@reduxjs/toolkit").ActionCreatorWithPayload<ThemeMode, string>, handleLanguage: import("@reduxjs/toolkit").ActionCreatorWithPayload<LanguageMode, string>, handleActiveFlowScreens: import("@reduxjs/toolkit").ActionCreatorWithPayload<ScreenStepNavigation[], string>, handleNextScreenStep: import("@reduxjs/toolkit").ActionCreatorWithOptionalPayload<string | undefined, string>, handlePrevScreenStep: import("@reduxjs/toolkit").ActionCreatorWithOptionalPayload<string | undefined, string>, handleCurrentActiveScreen: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, string>, handleSetAppConfig: import("@reduxjs/toolkit").ActionCreatorWithPayload<LibConfig, string>;
31
33
  declare const _default: import("redux").Reducer<SettingsState, import("redux").AnyAction>;
32
34
  export default _default;
33
35
  export declare const settingsSelector: (state: RootState) => SettingsState;
@@ -1,3 +1,14 @@
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
+ };
1
12
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
13
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
14
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -83,7 +94,8 @@ var initialState = {
83
94
  language: getStoredData(LOCAL_STORAGE_KEYS.languageMode) || 'en',
84
95
  featureScreensNavigation: [],
85
96
  activeScreen: {},
86
- deviceInfo: DefaultDeviceInfo
97
+ deviceInfo: DefaultDeviceInfo,
98
+ appConfig: {}
87
99
  }
88
100
  };
89
101
  export var settingsSlice = createSlice({
@@ -142,6 +154,22 @@ export var settingsSlice = createSlice({
142
154
  handleActiveFlowScreens: function (state, action) {
143
155
  state.data.featureScreensNavigation = action.payload;
144
156
  state.data.activeScreen = action.payload[0];
157
+ },
158
+ handleSetAppConfig: function (state, action) {
159
+ var _a = action.payload, appInfo = _a.appInfo, businessCountryCode = _a.businessCountryCode, language = _a.language, onError = _a.onError, onFlowCompleted = _a.onFlowCompleted, publicKey = _a.publicKey;
160
+ if (!appInfo.name)
161
+ throw new Error('App name is required');
162
+ if (!businessCountryCode)
163
+ throw new Error('Business country is required');
164
+ if (!language)
165
+ throw new Error('Language is required');
166
+ if (!publicKey)
167
+ throw new Error('Public key is required');
168
+ if (!onError)
169
+ throw new Error('On error function is required');
170
+ if (!onFlowCompleted)
171
+ throw new Error('On flow completed function is required');
172
+ state.data.appConfig = __assign(__assign({}, action.payload), { appInfo: __assign(__assign({}, appInfo), { identifier: 'auth-js-connect', version: '1.0.22' }) });
145
173
  }
146
174
  },
147
175
  extraReducers: function (builder) {
@@ -193,6 +221,6 @@ export var settingsSlice = createSlice({
193
221
  });
194
222
  }
195
223
  });
196
- export var handleSkin = (_a = settingsSlice.actions, _a.handleSkin), handleLanguage = _a.handleLanguage, handleActiveFlowScreens = _a.handleActiveFlowScreens, handleNextScreenStep = _a.handleNextScreenStep, handlePrevScreenStep = _a.handlePrevScreenStep, handleCurrentActiveScreen = _a.handleCurrentActiveScreen;
224
+ export var handleSkin = (_a = settingsSlice.actions, _a.handleSkin), handleLanguage = _a.handleLanguage, handleActiveFlowScreens = _a.handleActiveFlowScreens, handleNextScreenStep = _a.handleNextScreenStep, handlePrevScreenStep = _a.handlePrevScreenStep, handleCurrentActiveScreen = _a.handleCurrentActiveScreen, handleSetAppConfig = _a.handleSetAppConfig;
197
225
  export default settingsSlice.reducer;
198
226
  export var settingsSelector = function (state) { return state.settings; };
@@ -44,6 +44,7 @@ var ButtonStyled = styled(Button)(function (_a) {
44
44
  },
45
45
  ':disabled': {
46
46
  backgroundColor: alpha(theme.palette.primary.main, 0.3),
47
+ borderColor: alpha(theme.palette.primary.main, 0.2),
47
48
  color: theme.palette.common.white
48
49
  },
49
50
  '& .MuiButton-endIcon': {
@@ -83,3 +83,4 @@ export declare const BUSINESS_STEP_NAMES: {
83
83
  VERIFY_LEAD_IDENTITY: string;
84
84
  UPDATE_LEAD_BUSINESS_TYPE: string;
85
85
  };
86
+ export declare const RSA_FRONTEND_MW_PUBLIC_KEY = "-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCgC9kH1SQvjbXAUXd0PbrDUG8P\nLhRig9pJNBmdQBZjihuaxfkzYu6ToMbIMAfmYgVgQw338/y7aQ8X3m03CXNIlkxo\nOwxKCA8ymKsZQptXJn9IxlPO7yjoFgTFBrpmTgvcC4XO1uoUYTAPq3szK8kj4zgT\nucWG1hSKsOdRU7sl/wIDAQAB\n-----END PUBLIC KEY-----";
@@ -232,3 +232,4 @@ export var BUSINESS_STEP_NAMES = {
232
232
  VERIFY_LEAD_IDENTITY: 'business_verify_lead_identity',
233
233
  UPDATE_LEAD_BUSINESS_TYPE: 'business_update_lead_business_type'
234
234
  };
235
+ export var RSA_FRONTEND_MW_PUBLIC_KEY = "-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCgC9kH1SQvjbXAUXd0PbrDUG8P\nLhRig9pJNBmdQBZjihuaxfkzYu6ToMbIMAfmYgVgQw338/y7aQ8X3m03CXNIlkxo\nOwxKCA8ymKsZQptXJn9IxlPO7yjoFgTFBrpmTgvcC4XO1uoUYTAPq3szK8kj4zgT\nucWG1hSKsOdRU7sl/wIDAQAB\n-----END PUBLIC KEY-----";
@@ -341,3 +341,4 @@ export declare const SOURCE_OF_INCOME: {
341
341
  name: string;
342
342
  nameEn: string;
343
343
  }[];
344
+ export declare const EMAIL_PATH = "http://localhost:3000";
@@ -6432,3 +6432,4 @@ export var SOURCE_OF_INCOME = [
6432
6432
  { id: 5, name: 'تجارة', nameEn: 'Trading' },
6433
6433
  { id: 6, name: 'غير ذلك', nameEn: 'Other' }
6434
6434
  ];
6435
+ export var EMAIL_PATH = 'http://localhost:3000';
@@ -1,7 +1,7 @@
1
1
  import { RootState } from '../../../app/store';
2
2
  import { ResponseData, CountryCode, MobileFormValues, NIDFormValues, OTPFormValues, IndividualFormValues, SharedState, BrandFormValues, PasswordFormValues } from '../../../@types';
3
3
  export declare const getCountries: import("@reduxjs/toolkit").AsyncThunk<{
4
- businessCountries: any;
4
+ businessCountry: any;
5
5
  countries: any;
6
6
  }, void, {}>;
7
7
  export declare const createMobileAuth: import("@reduxjs/toolkit").AsyncThunk<{
@@ -53,7 +53,6 @@ export declare const updateLeadSuccess: import("@reduxjs/toolkit").AsyncThunk<{
53
53
  }, void, {}>;
54
54
  export interface ConnectData {
55
55
  countries: Array<CountryCode>;
56
- businessCountries: Array<CountryCode>;
57
56
  mobileData: MobileFormValues & ResponseData;
58
57
  nidData: NIDFormValues & ResponseData & {
59
58
  type: string;
@@ -47,29 +47,27 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
47
47
  };
48
48
  var _a;
49
49
  import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
50
- import moment from 'moment-hijri';
51
50
  import { handleNextScreenStep } from '../../../app/settings';
52
51
  import API from '../../../api';
53
52
  import { CONNECT_STEP_NAMES, IDENTIFICATION_TYPE } from '../../../constants';
54
- import { defaultCountry } from '../../../constants/dummy';
55
- import { convertNumbers2English, getIndividualName } from '../../../utils';
56
- export var getCountries = createAsyncThunk('getCountries', function () { return __awaiter(void 0, void 0, void 0, function () {
57
- var countriesBody, BusinessCountries, list, countries, filterBusinessCountries;
53
+ import { defaultCountry, EMAIL_PATH } from '../../../constants/dummy';
54
+ import { getIndividualName } from '../../../utils';
55
+ export var getCountries = createAsyncThunk('getCountries', function (_, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
56
+ var settings, countriesBody, list, businessCountry;
58
57
  return __generator(this, function (_a) {
59
58
  switch (_a.label) {
60
- case 0: return [4, API.countryService.getAllCountries()];
59
+ case 0:
60
+ settings = thunkApi.getState().settings;
61
+ return [4, API.countryService.getAllCountries()];
61
62
  case 1:
62
63
  countriesBody = (_a.sent()).data;
63
- return [4, API.countryService.getBusinessCountries()];
64
- case 2:
65
- BusinessCountries = (_a.sent()).data;
66
64
  list = countriesBody.list;
67
- countries = BusinessCountries.countries;
68
- filterBusinessCountries = (list || []).filter(function (item) {
69
- return (countries || []).some(function (obj) { return obj.code === item.iso2; });
65
+ businessCountry = list.find(function (item) {
66
+ return [item.iso2, item.iso3].includes(settings.data.appConfig.businessCountryCode.toUpperCase());
70
67
  });
68
+ console.log('businessCountry', businessCountry);
71
69
  return [2, {
72
- businessCountries: filterBusinessCountries,
70
+ businessCountry: businessCountry,
73
71
  countries: list || []
74
72
  }];
75
73
  }
@@ -77,8 +75,9 @@ export var getCountries = createAsyncThunk('getCountries', function () { return
77
75
  }); });
78
76
  export var createMobileAuth = createAsyncThunk('createMobileAuth', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
79
77
  var settings, requestBody, data;
80
- return __generator(this, function (_a) {
81
- switch (_a.label) {
78
+ var _a, _b;
79
+ return __generator(this, function (_c) {
80
+ switch (_c.label) {
82
81
  case 0:
83
82
  settings = thunkApi.getState().settings;
84
83
  requestBody = {
@@ -89,55 +88,62 @@ export var createMobileAuth = createAsyncThunk('createMobileAuth', function (par
89
88
  device_info: settings.data.deviceInfo,
90
89
  sign_in: false,
91
90
  step_name: CONNECT_STEP_NAMES.CREATE_AUTH_MOBILE,
92
- encryption_contract: []
91
+ encryption_contract: ['user_credentail.phone', 'user_credentail.code']
93
92
  };
94
93
  return [4, API.authService.createAuth(requestBody)];
95
94
  case 1:
96
- data = (_a.sent()).data;
97
- if (!data.errors && !params.isResend)
95
+ data = (_c.sent()).data;
96
+ if (!data.errors && !params.isResend) {
98
97
  thunkApi.dispatch(handleNextScreenStep());
98
+ (_b = (_a = settings.data.appConfig).onStepCompleted) === null || _b === void 0 ? void 0 : _b.call(_a, settings.data.activeScreen.name, requestBody.user_credentail);
99
+ }
99
100
  return [2, { response: data, formData: params }];
100
101
  }
101
102
  });
102
103
  }); });
103
104
  export var createNIDAuth = createAsyncThunk('createNIDAuth', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
104
- var _a, settings, connect, identification_id_type, birthDate, requestBody, data;
105
- return __generator(this, function (_b) {
106
- switch (_b.label) {
105
+ var _a, settings, connect, identification_id_type, requestBody, data;
106
+ var _b, _c;
107
+ return __generator(this, function (_d) {
108
+ switch (_d.label) {
107
109
  case 0:
108
110
  _a = thunkApi.getState(), settings = _a.settings, connect = _a.connect;
109
111
  identification_id_type = params.nid.startsWith('1') ? IDENTIFICATION_TYPE.NID : IDENTIFICATION_TYPE.IQAMA;
110
- birthDate = params.dob;
111
- if (identification_id_type === IDENTIFICATION_TYPE.NID) {
112
- birthDate = convertNumbers2English(moment(birthDate, 'YYYY-MM-DD').format('iYYYY/iMM/iDD')).split('/').join('-');
113
- }
114
112
  requestBody = {
115
113
  user_credentail: {
116
114
  identification_id: params.nid,
117
115
  identification_id_type: identification_id_type,
118
- date_of_birth: birthDate,
116
+ date_of_birth: params.dob,
119
117
  country_code: connect.data.mobileData.businessCountry.iso2
120
118
  },
121
119
  device_info: settings.data.deviceInfo,
122
120
  sign_in: false,
123
121
  step_name: CONNECT_STEP_NAMES.CREATE_AUTH_NID,
124
- encryption_contract: []
122
+ encryption_contract: [
123
+ 'user_credentail.country_code',
124
+ 'user_credentail.identification_id',
125
+ 'user_credentail.identification_id_type',
126
+ 'user_credentail.date_of_birth'
127
+ ]
125
128
  };
126
129
  return [4, API.authService.createAuth(requestBody)];
127
130
  case 1:
128
- data = (_b.sent()).data;
129
- if (!data.errors && !params.isResend)
131
+ data = (_d.sent()).data;
132
+ if (!data.errors && !params.isResend) {
130
133
  thunkApi.dispatch(handleNextScreenStep());
134
+ (_c = (_b = settings.data.appConfig).onStepCompleted) === null || _c === void 0 ? void 0 : _c.call(_b, settings.data.activeScreen.name, requestBody.user_credentail);
135
+ }
131
136
  return [2, { response: data, formData: __assign(__assign({}, params), { type: identification_id_type }) }];
132
137
  }
133
138
  });
134
139
  }); });
135
140
  export var verifyAuth = createAsyncThunk('verifyAuth', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
136
- var connect, isAbsher, responseBody, payload, data;
137
- return __generator(this, function (_a) {
138
- switch (_a.label) {
141
+ var _a, connect, settings, isAbsher, responseBody, payload, data;
142
+ var _b, _c;
143
+ return __generator(this, function (_d) {
144
+ switch (_d.label) {
139
145
  case 0:
140
- connect = thunkApi.getState().connect;
146
+ _a = thunkApi.getState(), connect = _a.connect, settings = _a.settings;
141
147
  isAbsher = connect.data.otpData.isAbsher;
142
148
  responseBody = (isAbsher ? connect.data.nidData : connect.data.mobileData).responseBody;
143
149
  payload = {
@@ -151,12 +157,13 @@ export var verifyAuth = createAsyncThunk('verifyAuth', function (params, thunkAp
151
157
  remember_me: responseBody === null || responseBody === void 0 ? void 0 : responseBody.remember_me,
152
158
  scopes: responseBody === null || responseBody === void 0 ? void 0 : responseBody.scopes,
153
159
  step_name: isAbsher ? CONNECT_STEP_NAMES.VERIFY_AUTH_NID : CONNECT_STEP_NAMES.VERIFY_AUTH_MOBILE,
154
- encryption_contract: []
160
+ encryption_contract: ['data']
155
161
  };
156
162
  return [4, API.authService.verifyAuth(payload)];
157
163
  case 1:
158
- data = (_a.sent()).data;
164
+ data = (_d.sent()).data;
159
165
  if (!data.errors) {
166
+ (_c = (_b = settings.data.appConfig).onStepCompleted) === null || _c === void 0 ? void 0 : _c.call(_b, settings.data.activeScreen.name, { otp: params.otp });
160
167
  if (responseBody === null || responseBody === void 0 ? void 0 : responseBody.new_user) {
161
168
  thunkApi.dispatch(handleNextScreenStep('CONNECT_INDIVIDUAL_STEP'));
162
169
  }
@@ -169,11 +176,12 @@ export var verifyAuth = createAsyncThunk('verifyAuth', function (params, thunkAp
169
176
  });
170
177
  }); });
171
178
  export var verifyAuthPassword = createAsyncThunk('verifyAuthPassword', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
172
- var connect, isAbsher, responseBody, payload, data;
173
- return __generator(this, function (_a) {
174
- switch (_a.label) {
179
+ var _a, connect, settings, isAbsher, responseBody, payload, data;
180
+ var _b, _c;
181
+ return __generator(this, function (_d) {
182
+ switch (_d.label) {
175
183
  case 0:
176
- connect = thunkApi.getState().connect;
184
+ _a = thunkApi.getState(), connect = _a.connect, settings = _a.settings;
177
185
  isAbsher = connect.data.otpData.isAbsher;
178
186
  responseBody = (isAbsher ? connect.data.nidData : connect.data.mobileData).responseBody;
179
187
  payload = {
@@ -187,22 +195,24 @@ export var verifyAuthPassword = createAsyncThunk('verifyAuthPassword', function
187
195
  remember_me: responseBody === null || responseBody === void 0 ? void 0 : responseBody.remember_me,
188
196
  scopes: responseBody === null || responseBody === void 0 ? void 0 : responseBody.scopes,
189
197
  step_name: CONNECT_STEP_NAMES.VERIFY_AUTH_PASSWORD,
190
- encryption_contract: []
198
+ encryption_contract: ['data']
191
199
  };
192
200
  return [4, API.authService.verifyAuth(payload)];
193
201
  case 1:
194
- data = (_a.sent()).data;
195
- if (!data.errors)
202
+ data = (_d.sent()).data;
203
+ if (!data.errors) {
196
204
  thunkApi.dispatch(handleNextScreenStep());
205
+ (_c = (_b = settings.data.appConfig).onStepCompleted) === null || _c === void 0 ? void 0 : _c.call(_b, settings.data.activeScreen.name, { password: params.password });
206
+ }
197
207
  return [2, { response: data, formData: params }];
198
208
  }
199
209
  });
200
210
  }); });
201
211
  export var updateLeadIndividual = createAsyncThunk('updateLeadIndividual', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
202
212
  var _a, settings, connect, isAbsher, headers, payload, data;
203
- var _b, _c, _d;
204
- return __generator(this, function (_e) {
205
- switch (_e.label) {
213
+ var _b, _c, _d, _e, _f;
214
+ return __generator(this, function (_g) {
215
+ switch (_g.label) {
206
216
  case 0:
207
217
  _a = thunkApi.getState(), settings = _a.settings, connect = _a.connect;
208
218
  isAbsher = connect.data.otpData.isAbsher;
@@ -222,22 +232,31 @@ export var updateLeadIndividual = createAsyncThunk('updateLeadIndividual', funct
222
232
  : undefined
223
233
  },
224
234
  step_name: CONNECT_STEP_NAMES.UPDATE_LEAD_INDIVIDUAL,
225
- encryption_contract: []
235
+ encryption_contract: [
236
+ 'name.first',
237
+ 'name.middle',
238
+ 'name.last',
239
+ 'contact.email',
240
+ 'contact.phone.country_code',
241
+ 'contact.phone.number'
242
+ ]
226
243
  };
227
244
  return [4, API.leadService.updateLead(payload, { headers: headers })];
228
245
  case 1:
229
- data = (_e.sent()).data;
230
- if (!data.errors)
246
+ data = (_g.sent()).data;
247
+ if (!data.errors) {
231
248
  thunkApi.dispatch(handleNextScreenStep());
249
+ (_f = (_e = settings.data.appConfig).onStepCompleted) === null || _f === void 0 ? void 0 : _f.call(_e, settings.data.activeScreen.name, params);
250
+ }
232
251
  return [2, { response: data, formData: params }];
233
252
  }
234
253
  });
235
254
  }); });
236
255
  export var updateLeadBrand = createAsyncThunk('updateLeadBrand', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
237
256
  var _a, settings, connect, headers, payload, data;
238
- var _b, _c, _d, _e, _f, _g;
239
- return __generator(this, function (_h) {
240
- switch (_h.label) {
257
+ var _b, _c, _d, _e, _f, _g, _h, _j;
258
+ return __generator(this, function (_k) {
259
+ switch (_k.label) {
241
260
  case 0:
242
261
  _a = thunkApi.getState(), settings = _a.settings, connect = _a.connect;
243
262
  headers = {
@@ -256,13 +275,15 @@ export var updateLeadBrand = createAsyncThunk('updateLeadBrand', function (param
256
275
  },
257
276
  terms_conditions_accepted: params.termAndConditionChecked,
258
277
  step_name: CONNECT_STEP_NAMES.UPDATE_LEAD_MERCHANT,
259
- encryption_contract: []
278
+ encryption_contract: ['brand.name.en', 'brand.name.ar', 'brand.name.zh']
260
279
  };
261
280
  return [4, API.leadService.updateLead(payload, { headers: headers })];
262
281
  case 1:
263
- data = (_h.sent()).data;
264
- if (!data.errors)
282
+ data = (_k.sent()).data;
283
+ if (!data.errors) {
265
284
  thunkApi.dispatch(handleNextScreenStep());
285
+ (_j = (_h = settings.data.appConfig).onStepCompleted) === null || _j === void 0 ? void 0 : _j.call(_h, settings.data.activeScreen.name, params);
286
+ }
266
287
  return [2, { response: data, formData: params }];
267
288
  }
268
289
  });
@@ -315,9 +336,9 @@ export var checkBrandNameAvailability = createAsyncThunk('checkBrandNameAvailabi
315
336
  }); });
316
337
  export var updateLeadSuccess = createAsyncThunk('updateLeadSuccess', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
317
338
  var _a, settings, connect, headers, payload, data;
318
- var _b, _c, _d;
319
- return __generator(this, function (_e) {
320
- switch (_e.label) {
339
+ var _b, _c, _d, _e, _f, _g, _h;
340
+ return __generator(this, function (_j) {
341
+ switch (_j.label) {
321
342
  case 0:
322
343
  _a = thunkApi.getState(), settings = _a.settings, connect = _a.connect;
323
344
  headers = {
@@ -326,11 +347,14 @@ export var updateLeadSuccess = createAsyncThunk('updateLeadSuccess', function (p
326
347
  };
327
348
  payload = {
328
349
  step_name: CONNECT_STEP_NAMES.CONNECT_SUCCESS,
350
+ email_url: EMAIL_PATH,
329
351
  encryption_contract: []
330
352
  };
331
353
  return [4, API.leadService.updateLead(payload, { headers: headers })];
332
354
  case 1:
333
- data = (_e.sent()).data;
355
+ data = (_j.sent()).data;
356
+ (_f = (_e = settings.data.appConfig).onStepCompleted) === null || _f === void 0 ? void 0 : _f.call(_e, settings.data.activeScreen.name, params);
357
+ (_h = (_g = settings.data.appConfig).onFlowCompleted) === null || _h === void 0 ? void 0 : _h.call(_g, { data: data });
334
358
  return [2, { response: data, formData: params }];
335
359
  }
336
360
  });
@@ -341,7 +365,6 @@ var initialState = {
341
365
  searchActive: false,
342
366
  data: {
343
367
  countries: [],
344
- businessCountries: [],
345
368
  mobileData: {
346
369
  countryCode: defaultCountry,
347
370
  businessCountry: defaultCountry,
@@ -391,9 +414,10 @@ export var connectSlice = createSlice({
391
414
  builder
392
415
  .addCase(getCountries.fulfilled, function (state, action) {
393
416
  state.error = null;
394
- var _a = action.payload, businessCountries = _a.businessCountries, countries = _a.countries;
395
- state.data.businessCountries = businessCountries;
417
+ var _a = action.payload, countries = _a.countries, businessCountry = _a.businessCountry;
396
418
  state.data.countries = countries;
419
+ state.data.mobileData.businessCountry = businessCountry || defaultCountry;
420
+ state.data.mobileData.countryCode = businessCountry || defaultCountry;
397
421
  })
398
422
  .addCase(getCountries.pending, function (state) {
399
423
  state.error = null;
@@ -1,8 +1,6 @@
1
1
  /// <reference types="react" />
2
- import { AppInfo } from '../../@types';
3
- export interface ConnectLibProps {
4
- appInfo: AppInfo;
5
- publicKey: string;
2
+ import { LibConfig } from '../../@types';
3
+ export interface ConnectLibProps extends LibConfig {
6
4
  }
7
5
  export declare function ConnectLib(props: ConnectLibProps): JSX.Element;
8
6
  export declare function renderConnectLib(config: ConnectLibProps, elementId: string): void;
@@ -12,7 +12,7 @@ var __assign = (this && this.__assign) || function () {
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
13
  import React, { memo, useEffect } from 'react';
14
14
  import { FeatureContainer } from '../shared/Containers';
15
- import { useAppTheme, useAppDispatch, useAppSelector, useAppConfig } from '../../hooks';
15
+ import { useAppTheme, useAppDispatch, useAppSelector, useAppConfig, useErrorListener } from '../../hooks';
16
16
  import { settingsSelector } from '../../app/settings';
17
17
  import AnimationFlow from '../../components/AnimationFlow';
18
18
  import { store } from '../../app/store';
@@ -23,13 +23,13 @@ import { reactElement } from '../../utils';
23
23
  import { CONNECT_SCREENS_NAVIGATION } from '../../constants';
24
24
  import { connectFeatureScreens } from '../featuresScreens';
25
25
  import CustomFooter from '../shared/Footer';
26
- var Connect = memo(function (_a) {
27
- var appInfo = _a.appInfo, publicKey = _a.publicKey;
26
+ var Connect = memo(function (props) {
28
27
  var open = React.useState(true)[0];
29
28
  var theme = useAppTheme().theme;
30
29
  var dispatch = useAppDispatch();
31
30
  var data = useAppSelector(settingsSelector).data;
32
- useAppConfig({ appInfo: appInfo, navigation: CONNECT_SCREENS_NAVIGATION, publicKey: publicKey });
31
+ useAppConfig(__assign({ navigation: CONNECT_SCREENS_NAVIGATION }, props));
32
+ useErrorListener();
33
33
  var activeScreen = data.activeScreen;
34
34
  useEffect(function () {
35
35
  dispatch(getCountries());
@@ -14,7 +14,6 @@ import * as React from 'react';
14
14
  import { useTranslation } from 'react-i18next';
15
15
  import { ScreenContainer } from '../../../shared/Containers';
16
16
  import Input from '../../../shared/Input';
17
- import { keepEmailCharacters } from '../../../../utils';
18
17
  import { useController, useFormContext } from 'react-hook-form';
19
18
  import ClearIcon from '../../../shared/ClearIcon';
20
19
  import CheckIcon from '../../../shared/CheckIcon';
@@ -35,8 +34,7 @@ var Email = function (_a) {
35
34
  dispatch(checkEmailAvailability(value));
36
35
  }, 500);
37
36
  var handleEmailChange = function (event) {
38
- var value = keepEmailCharacters(event.target.value);
39
- emailControl.field.onChange(value);
37
+ emailControl.field.onChange(event.target.value);
40
38
  };
41
39
  React.useEffect(function () {
42
40
  var isValid = emailValue && !error && emailValue.length > 3;
@@ -57,16 +57,14 @@ var Individual = function (_a) {
57
57
  if (error)
58
58
  dispatch(clearError());
59
59
  }, [methods.formState.isValid]);
60
+ var handleMenuListClick = function () {
61
+ listActive ? setListActive(false) : setListActive(true);
62
+ };
60
63
  React.useEffect(function () {
61
64
  var _a, _b;
62
65
  if (((_b = (_a = data.individualData) === null || _a === void 0 ? void 0 : _a.responseBody) === null || _b === void 0 ? void 0 : _b.is_available) === false)
63
66
  methods.setError('email', { message: 'tap_js_email_already_exist' });
64
- if (searchActive)
65
- methods.setError('email', { message: 'checking...' });
66
- }, [(_d = data.individualData) === null || _d === void 0 ? void 0 : _d.responseBody, searchActive]);
67
- var handleMenuListClick = function () {
68
- listActive ? setListActive(false) : setListActive(true);
69
- };
67
+ }, [(_d = data.individualData) === null || _d === void 0 ? void 0 : _d.responseBody]);
70
68
  var emailErrChecks = !methods.formState.isValid || !!methods.formState.errors.email || !!error;
71
69
  var disabled = emailErrChecks || searchActive || !((_e = data.individualData.responseBody) === null || _e === void 0 ? void 0 : _e.is_available);
72
70
  return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(Name, { show: !listActive }), _jsx(MobileNumber, { setMobileLength: setMobileLength, show: isAbsher, onListOpen: function () { return handleMenuListClick(); }, onListClose: function () { return handleMenuListClick(); }, countries: countriesCode }), _jsx(Email, { show: !listActive }), _jsx(Collapse, __assign({ in: !listActive }, { children: _jsx(Button, __assign({ onBackClicked: function () { return onBack(); }, disabled: disabled, isAr: isAr, loading: loading, error: t(error || '') }, { children: t('next') })) }))] })) })) }));
@@ -64,6 +64,8 @@ var BrandName = function (_a) {
64
64
  var t = useTranslation().t;
65
65
  var control = useFormContext().control;
66
66
  var brandControl = useController({ control: control, name: 'brandName' });
67
+ var brandNameValue = brandControl.field.value;
68
+ var error = (_b = brandControl.fieldState.error) === null || _b === void 0 ? void 0 : _b.message;
67
69
  var checkBrand = debounce(function (value) {
68
70
  dispatch(checkBrandNameAvailability(value));
69
71
  }, 500);
@@ -71,14 +73,15 @@ var BrandName = function (_a) {
71
73
  var target = _a.target;
72
74
  var value = removeAllOtherThanCharsNumbersAndSpace(target.value);
73
75
  brandControl.field.onChange(value);
74
- if (!!value)
75
- checkBrand(value);
76
76
  };
77
+ React.useEffect(function () {
78
+ var isValid = brandNameValue && !error && brandNameValue.length > 2;
79
+ if (isValid)
80
+ checkBrand(brandNameValue);
81
+ }, [brandNameValue, error]);
77
82
  var clearBrandName = function () {
78
83
  brandControl.field.onChange('');
79
84
  };
80
- var brandNameValue = brandControl.field.value;
81
- var error = (_b = brandControl.fieldState.error) === null || _b === void 0 ? void 0 : _b.message;
82
85
  return (_jsxs(ScreenContainer, __assign({ sx: { mt: 2.5, mb: 3 } }, { children: [_jsxs(LabelContainerStyled, { children: [_jsx(InputLabelStyled, { children: t('signup_brand_name_label') }), _jsx(Tooltip, __assign({ title: t('brand_name_hint'), onMouseOver: function () { return setIsHovered(true); }, onMouseLeave: function () { return setIsHovered(false); } }, { children: isHovered ? _jsx(InfoIconStyled, {}) : _jsx(InfoOutlinedIconStyled, {}) }))] }), _jsx(Input, { onChange: handleBrandNameChange, value: brandNameValue, placeholder: t('signup_brand_name_placeholder'), warningType: 'alert', warningMessage: error && t(error), endAdornment: !error && brandNameValue ? _jsx(CheckIcon, {}) : brandNameValue && _jsx(ClearIcon, { onClick: clearBrandName }) })] })));
83
86
  };
84
87
  export default React.memo(BrandName);
@@ -27,8 +27,8 @@ import BrandName from './BrandName';
27
27
  import SocialMedia from './SocialMedia';
28
28
  import TAC from './TAC';
29
29
  var Merchant = function (_a) {
30
- var _b;
31
- var _c = useSelector(connectSelector), data = _c.data, loading = _c.loading, error = _c.error, searchActive = _c.searchActive;
30
+ var _b, _c, _d;
31
+ var _e = useSelector(connectSelector), data = _e.data, loading = _e.loading, error = _e.error, searchActive = _e.searchActive;
32
32
  var methods = useForm({
33
33
  resolver: yupResolver(MerchantValidationSchema),
34
34
  defaultValues: data.brandData,
@@ -49,10 +49,11 @@ var Merchant = function (_a) {
49
49
  }, [methods.formState.isValid]);
50
50
  React.useEffect(function () {
51
51
  var _a, _b;
52
- if (((_b = (_a = data.brandData) === null || _a === void 0 ? void 0 : _a.responseBody) === null || _b === void 0 ? void 0 : _b.response_code) == '5')
52
+ if (((_b = (_a = data.brandData) === null || _a === void 0 ? void 0 : _a.responseBody) === null || _b === void 0 ? void 0 : _b.response_code) === '5')
53
53
  methods.setError('brandName', { message: 'Profile Name already exists' });
54
54
  }, [(_b = data.brandData) === null || _b === void 0 ? void 0 : _b.responseBody]);
55
- var disabled = !methods.formState.isValid || !!methods.formState.errors.brandName || !!error || searchActive;
55
+ var brandErrChecks = !methods.formState.isValid || !!methods.formState.errors.brandName || !!error;
56
+ var disabled = brandErrChecks || searchActive || ((_d = (_c = data.brandData) === null || _c === void 0 ? void 0 : _c.responseBody) === null || _d === void 0 ? void 0 : _d.response_code) === '5';
56
57
  return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(Form, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(BrandName, {}), _jsx(SocialMedia, {}), _jsx(TAC, {}), _jsx(Button, __assign({ onBackClicked: function () { return onBack(); }, disabled: disabled, isAr: isAr, error: t(error || ''), loading: loading }, { children: t('next') }))] })) })) }));
57
58
  };
58
59
  export default React.memo(Merchant);
@@ -1,11 +1,6 @@
1
1
  import * as React from 'react';
2
- import { CountryCode } from '../../../../@types';
3
2
  interface BusinessCountryProps {
4
- countries: Array<CountryCode>;
5
3
  show: boolean;
6
- setMobileLength?: (length: number) => void;
7
- onListOpen?: () => void;
8
- onListClose?: () => void;
9
4
  }
10
5
  declare const _default: React.MemoExoticComponent<React.ForwardRefExoticComponent<BusinessCountryProps & React.RefAttributes<unknown>>>;
11
6
  export default _default;
@@ -20,7 +20,7 @@ var __rest = (this && this.__rest) || function (s, e) {
20
20
  }
21
21
  return t;
22
22
  };
23
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
23
+ import { jsx as _jsx } from "react/jsx-runtime";
24
24
  import * as React from 'react';
25
25
  import Box from '@mui/material/Box';
26
26
  import { styled } from '@mui/material/styles';
@@ -32,7 +32,6 @@ import CheckIcon from '@mui/icons-material/Check';
32
32
  import ScreenContainer from '../../../shared/Containers/ScreenContainer';
33
33
  import Icon from '../../../../components/Icon';
34
34
  import Input from '../../../shared/Input';
35
- import SimpleList from '../../../../components/SimpleList';
36
35
  import { useLanguage } from '../../../../hooks';
37
36
  var CountryItemContainer = styled(Box)(function () { return ({
38
37
  display: 'flex'
@@ -62,32 +61,12 @@ var CountryIconStyled = styled(Icon)(function (_a) {
62
61
  });
63
62
  var BusinessCountry = React.forwardRef(function (_a, ref) {
64
63
  var _b, _c;
65
- var countries = _a.countries, rest = __rest(_a, ["countries"]);
66
- var _d = React.useState(countries), businessCountries = _d[0], setBusinessCountries = _d[1];
67
- var _e = React.useState(null), anchorEl = _e[0], setAnchorEl = _e[1];
64
+ var rest = __rest(_a, []);
68
65
  var t = useTranslation().t;
69
66
  var isAr = useLanguage().isAr;
70
67
  var control = useFormContext().control;
71
68
  var businessCountryControl = useController({ control: control, name: 'businessCountry' });
72
- var onOpenCountrySelect = function (event) {
73
- };
74
- var onCloseCountrySelect = function () {
75
- var _a;
76
- setAnchorEl(null);
77
- (_a = rest.onListClose) === null || _a === void 0 ? void 0 : _a.call(rest);
78
- };
79
- var onSelectItem = function (country) {
80
- onCloseCountrySelect();
81
- businessCountryControl.field.onChange(country);
82
- };
83
- React.useEffect(function () {
84
- if (businessCountries.length === 0) {
85
- setBusinessCountries(countries);
86
- }
87
- }, [countries]);
88
69
  var businessCountry = businessCountryControl.field.value;
89
- return (_jsx(Collapse, __assign({ in: rest.show }, { children: _jsxs(ScreenContainer, __assign({ ref: ref, sx: { marginBottom: '25px' } }, { children: [_jsx(Input, { label: t('signup_select_country'), readOnly: true, onClick: !!anchorEl ? onCloseCountrySelect : onOpenCountrySelect, startAdornment: _jsx(CountrySpanStyled, { children: _jsx(CountryIconStyled, { src: (businessCountry === null || businessCountry === void 0 ? void 0 : businessCountry.logo) || '' }) }), placeholder: t('ide_mobile_placeholder'), value: (isAr ? (_b = businessCountry === null || businessCountry === void 0 ? void 0 : businessCountry.name) === null || _b === void 0 ? void 0 : _b.arabic : (_c = businessCountry === null || businessCountry === void 0 ? void 0 : businessCountry.name) === null || _c === void 0 ? void 0 : _c.english) || '' }), _jsx(Collapse, __assign({ in: !!anchorEl }, { children: _jsx(SimpleList, { searchKeyPath: 'name.english', list: businessCountries, onSelectItem: onSelectItem, renderItem: function (item) {
90
- return (_jsxs(_Fragment, { children: [_jsxs(CountryItemContainer, { children: [_jsx(CountryIconStyled, { src: item.logo, alt: item.iso3 }), _jsx(CountryNameText, __assign({ isSelected: (item === null || item === void 0 ? void 0 : item.idd_prefix) === (businessCountry === null || businessCountry === void 0 ? void 0 : businessCountry.idd_prefix) }, { children: isAr ? item.name.arabic : item.name.english }))] }), item.idd_prefix === (businessCountry === null || businessCountry === void 0 ? void 0 : businessCountry.idd_prefix) && _jsx(CheckIconStyled, {})] }));
91
- } }) }))] })) })));
70
+ return (_jsx(Collapse, __assign({ in: rest.show }, { children: _jsx(ScreenContainer, __assign({ ref: ref, sx: { marginBottom: '25px' } }, { children: _jsx(Input, { sx: { cursor: 'auto' }, label: t('signup_select_country'), readOnly: true, startAdornment: _jsx(CountrySpanStyled, { children: _jsx(CountryIconStyled, { src: (businessCountry === null || businessCountry === void 0 ? void 0 : businessCountry.logo) || '' }) }), placeholder: t('ide_mobile_placeholder'), value: (isAr ? (_b = businessCountry === null || businessCountry === void 0 ? void 0 : businessCountry.name) === null || _b === void 0 ? void 0 : _b.arabic : (_c = businessCountry === null || businessCountry === void 0 ? void 0 : businessCountry.name) === null || _c === void 0 ? void 0 : _c.english) || '' }) })) })));
92
71
  });
93
72
  export default React.memo(BusinessCountry);
@@ -74,10 +74,9 @@ var ListType;
74
74
  ListType["CountryCodeList"] = "CountryCodeList";
75
75
  })(ListType || (ListType = {}));
76
76
  var Mobile = function (_a) {
77
- var _b, _c;
78
- var _d = useSelector(connectSelector), data = _d.data, loading = _d.loading, error = _d.error;
79
- var _e = React.useState((_c = (_b = data.mobileData) === null || _b === void 0 ? void 0 : _b.countryCode) === null || _c === void 0 ? void 0 : _c.digits), mobileLength = _e[0], setMobileLength = _e[1];
80
- var _f = React.useState(), listType = _f[0], setListType = _f[1];
77
+ var _b = useSelector(connectSelector), data = _b.data, loading = _b.loading, error = _b.error;
78
+ var _c = React.useState(data.mobileData.countryCode.digits), mobileLength = _c[0], setMobileLength = _c[1];
79
+ var _d = React.useState(), listType = _d[0], setListType = _d[1];
81
80
  var dispatch = useAppDispatch();
82
81
  var methods = useForm({
83
82
  resolver: yupResolver(PhoneValidationSchema(mobileLength)),
@@ -90,6 +89,17 @@ var Mobile = function (_a) {
90
89
  var handleMenuListClick = function (flag) {
91
90
  setListType(flag);
92
91
  };
92
+ React.useEffect(function () {
93
+ if (data.mobileData.countryCode.digits) {
94
+ setMobileLength(data.mobileData.countryCode.digits);
95
+ }
96
+ if (data.mobileData.countryCode) {
97
+ methods.setValue('countryCode', data.mobileData.countryCode);
98
+ }
99
+ if (data.mobileData.businessCountry) {
100
+ methods.setValue('businessCountry', data.mobileData.businessCountry);
101
+ }
102
+ }, [data.mobileData]);
93
103
  React.useEffect(function () {
94
104
  if (error)
95
105
  dispatch(clearError());
@@ -105,6 +115,6 @@ var Mobile = function (_a) {
105
115
  var listActive = isBusinessListActive || isCountryListActive;
106
116
  var isLoading = settingsStore.loading || loading;
107
117
  var disabled = !methods.formState.isValid || !!error;
108
- return (_jsxs(ScreenContainer, { children: [_jsx(MIDTitle, { show: !listActive, title: t('join_our_community'), description: t('ide_terms_and_conditions_description') }), _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsxs(InputsContainerStyled, { children: [_jsx(BusinessCountry, { show: !isCountryListActive, setMobileLength: setMobileLength, countries: data.businessCountries, onListOpen: function () { return handleMenuListClick(ListType.BusinessList); }, onListClose: function () { return handleMenuListClick(); } }), _jsx(MobileNumber, { show: !isBusinessListActive, setMobileLength: setMobileLength, countries: data.countries, onListOpen: function () { return handleMenuListClick(ListType.CountryCodeList); }, onListClose: function () { return handleMenuListClick(); } })] }), _jsxs(Collapse, __assign({ in: !listActive }, { children: [_jsx(Button, __assign({ isAr: isAr, disabled: disabled, disableBack: true, loading: isLoading, error: t(error || '') }, { children: t('next') })), _jsxs(OrBoxStyled, { children: [_jsx(DividerStyled, {}), _jsx(TextStyled, { children: t('or') }), _jsx(DividerStyled, {})] }), _jsx(AbsherButton, __assign({ isAr: isAr, onClick: onAbsherButtonClicked }, { children: t('absher_button_label') }))] }))] })) }))] }));
118
+ return (_jsxs(ScreenContainer, { children: [_jsx(MIDTitle, { show: !listActive, title: t('join_our_community'), description: t('ide_terms_and_conditions_description') }), _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsxs(InputsContainerStyled, { children: [_jsx(BusinessCountry, { show: !isCountryListActive }), _jsx(MobileNumber, { show: !isBusinessListActive, setMobileLength: setMobileLength, countries: data.countries, onListOpen: function () { return handleMenuListClick(ListType.CountryCodeList); }, onListClose: function () { return handleMenuListClick(); } })] }), _jsxs(Collapse, __assign({ in: !listActive }, { children: [_jsx(Button, __assign({ isAr: isAr, disabled: disabled, disableBack: true, loading: isLoading, error: t(error || '') }, { children: t('next') })), _jsxs(OrBoxStyled, { children: [_jsx(DividerStyled, {}), _jsx(TextStyled, { children: t('or') }), _jsx(DividerStyled, {})] }), _jsx(AbsherButton, __assign({ disabled: loading, isAr: isAr, onClick: onAbsherButtonClicked }, { children: t('absher_button_label') }))] }))] })) }))] }));
109
119
  };
110
120
  export default React.memo(Mobile);
@@ -27,16 +27,17 @@ import Icon from '../../../components/Icon';
27
27
  import { styled } from '@mui/material/styles';
28
28
  import Loader from '../../../components/Loader';
29
29
  import { ICONS_NAMES } from '../../../constants';
30
- import ButtonGroup from '@mui/material/ButtonGroup';
31
30
  import Warning from '../../../components/Warning';
32
31
  import Collapse from '../../../components/Collapse';
32
+ import Box from '@mui/material/Box';
33
+ import Text from '../../../components/Text';
33
34
  var IconStyled = styled(Icon, { shouldForwardProp: function (prop) { return prop !== 'isAr'; } })(function (_a) {
34
35
  var theme = _a.theme, isAr = _a.isAr;
35
36
  return ({
36
37
  width: theme.spacing(3),
37
38
  height: theme.spacing(3),
38
39
  transform: isAr ? 'scaleX(-1)' : 'scaleX(1)',
39
- marginInlineEnd: theme.spacing(-0.75)
40
+ marginInlineEnd: theme.spacing(0.5)
40
41
  });
41
42
  });
42
43
  var BackIconStyled = styled(Icon, { shouldForwardProp: function (prop) { return prop !== 'isAr'; } })(function (_a) {
@@ -45,39 +46,39 @@ var BackIconStyled = styled(Icon, { shouldForwardProp: function (prop) { return
45
46
  width: theme.spacing(3),
46
47
  height: theme.spacing(3),
47
48
  transform: isAr ? 'scaleX(1)' : 'scaleX(-1)',
48
- marginInlineStart: theme.spacing(0.5)
49
+ marginInlineStart: theme.spacing(-1)
49
50
  });
50
51
  });
51
- var ButtonBoxStyled = styled(ButtonGroup, { shouldForwardProp: function (prop) { return prop !== 'isAr'; } })(function (_a) {
52
- var theme = _a.theme, isAr = _a.isAr;
52
+ var ButtonBoxStyled = styled(Box)(function (_a) {
53
+ var theme = _a.theme;
53
54
  return ({
54
- width: '100%',
55
55
  margin: theme.spacing(0, 2.5, 2.5, 2.5),
56
- paddingInlineEnd: theme.spacing(5),
57
- '& .MuiButtonGroup-grouped:not(:first-of-type)': {
58
- borderTopRightRadius: theme.spacing(4.1),
59
- borderBottomRightRadius: theme.spacing(4.1),
60
- borderTopLeftRadius: 0,
61
- borderBottomLeftRadius: 0
62
- },
63
- '& .MuiButtonGroup-grouped:not(:last-of-type)': {
64
- borderTopRightRadius: 0,
65
- borderBottomRightRadius: 0,
66
- borderTopLeftRadius: theme.spacing(4.1),
67
- borderBottomLeftRadius: theme.spacing(4.1)
68
- }
56
+ marginBlockStart: theme.spacing(5),
57
+ display: 'flex'
69
58
  });
70
59
  });
71
- var ButtonStyled = styled(Button)(function (_a) {
72
- var theme = _a.theme;
60
+ var ButtonStyled = styled(Button, { shouldForwardProp: function (prop) { return prop !== 'isBack'; } })(function (_a) {
61
+ var theme = _a.theme, isBack = _a.isBack;
62
+ return ({
63
+ paddingInlineStart: theme.spacing(2.5),
64
+ marginInlineStart: isBack ? theme.spacing(-5) : theme.spacing(0)
65
+ });
66
+ });
67
+ var BackButtonStyled = styled(Button, { shouldForwardProp: function (prop) { return prop !== 'isAr'; } })(function (_a) {
68
+ var theme = _a.theme, isAr = _a.isAr;
73
69
  return ({
74
- paddingInlineStart: theme.spacing(0.75)
70
+ minWidth: theme.spacing(5),
71
+ paddingInlineStart: theme.spacing(2.5),
72
+ width: '10%',
73
+ zIndex: 1,
74
+ borderRadius: isAr ? theme.spacing(0, 4.75, 4.75, 0) : theme.spacing(4.75, 0, 0, 4.75)
75
75
  });
76
76
  });
77
77
  export default function CustomButton(_a) {
78
78
  var children = _a.children, disabled = _a.disabled, isAr = _a.isAr, loading = _a.loading, disableBack = _a.disableBack, onBackClicked = _a.onBackClicked, error = _a.error, props = __rest(_a, ["children", "disabled", "isAr", "loading", "disableBack", "onBackClicked", "error"]);
79
- return (_jsxs(Fragment, { children: [_jsx(Collapse, __assign({ in: !!error }, { children: _jsx(Warning, __assign({ sx: { mb: 1 }, warningType: 'error' }, { children: error })) })), _jsxs(ButtonBoxStyled, __assign({ sx: { mt: 5 }, isAr: isAr, disableElevation: true, disableRipple: true, disableFocusRipple: true }, { children: [!disableBack && !loading && (_jsx(ButtonStyled, __assign({ onClick: function () { return onBackClicked === null || onBackClicked === void 0 ? void 0 : onBackClicked(); }, sx: { width: '10%' }, type: 'reset', startIcon: _jsx(BackIconStyled, { isAr: isAr, src: ICONS_NAMES.WHITE_ARROW }) }, props))), _jsx(ButtonStyled, __assign({ disabled: disabled || loading, type: 'submit', endIcon: _jsx(IconStyled, { isAr: isAr, src: ICONS_NAMES.WHITE_ARROW }), startIcon: _jsx(Loader, { style: {
79
+ var isBackEnabled = !disableBack && !loading;
80
+ return (_jsxs(Fragment, { children: [_jsx(Collapse, __assign({ in: !!error }, { children: _jsx(Warning, __assign({ sx: { mb: 1 }, warningType: 'error' }, { children: error })) })), _jsxs(ButtonBoxStyled, { children: [isBackEnabled && (_jsx(BackButtonStyled, __assign({ onClick: function () { return onBackClicked === null || onBackClicked === void 0 ? void 0 : onBackClicked(); }, isAr: isAr, type: 'reset', startIcon: _jsx(BackIconStyled, { isAr: isAr, src: ICONS_NAMES.WHITE_ARROW }) }, props))), _jsx(ButtonStyled, __assign({ disabled: disabled || loading, type: 'submit', isBack: isBackEnabled, endIcon: _jsx(IconStyled, { isAr: isAr, src: ICONS_NAMES.WHITE_ARROW }), startIcon: _jsx(Loader, { style: {
80
81
  visibility: disableBack && !loading ? 'hidden' : loading ? 'visible' : 'hidden',
81
82
  display: !disableBack && !loading ? 'none' : 'block'
82
- }, innerColor: 'white', outerColor: 'white', size: 30, toggleAnimation: !!loading }) }, props, { children: children }))] }))] }));
83
+ }, innerColor: 'white', outerColor: 'white', size: 30, toggleAnimation: !!loading }) }, props, { children: _jsxs(Text, __assign({ sx: { marginInlineEnd: isBackEnabled ? '-24px' : '20px' } }, { children: [" ", children] })) }))] })] }));
83
84
  }
@@ -7,3 +7,4 @@ export * from './useEventListener';
7
7
  export * from './useLanguage';
8
8
  export * from './useContainerDimensions';
9
9
  export * from './useAppConfig';
10
+ export * from './useErrorListener';
@@ -7,3 +7,4 @@ export * from './useEventListener';
7
7
  export * from './useLanguage';
8
8
  export * from './useContainerDimensions';
9
9
  export * from './useAppConfig';
10
+ export * from './useErrorListener';
@@ -1,10 +1,8 @@
1
- import { AppInfo, ScreenStepNavigation } from '../@types';
2
- interface AppConfigProps {
3
- appInfo: AppInfo;
1
+ import { LibConfig, ScreenStepNavigation } from '../@types';
2
+ interface AppConfigProps extends LibConfig {
4
3
  navigation: ScreenStepNavigation[];
5
- publicKey?: string;
6
4
  }
7
- export declare const useAppConfig: ({ appInfo, navigation, publicKey }: AppConfigProps) => {
5
+ export declare const useAppConfig: ({ appInfo, navigation, publicKey, ...rest }: AppConfigProps) => {
8
6
  loading: boolean;
9
7
  error: string | null;
10
8
  };
@@ -1,9 +1,31 @@
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
+ var __rest = (this && this.__rest) || function (s, e) {
13
+ var t = {};
14
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
+ t[p] = s[p];
16
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
+ t[p[i]] = s[p[i]];
20
+ }
21
+ return t;
22
+ };
1
23
  import { useEffect } from 'react';
2
- import { handleActiveFlowScreens, settingsSelector, getClientIp, getBrowserFingerPrint, getOperator } from '../app/settings';
24
+ import { handleActiveFlowScreens, settingsSelector, getClientIp, getBrowserFingerPrint, getOperator, handleSetAppConfig, handleLanguage } from '../app/settings';
3
25
  import { useAppDispatch } from './useAppDispatch';
4
26
  import { useAppSelector } from './useAppSelector';
5
27
  export var useAppConfig = function (_a) {
6
- var appInfo = _a.appInfo, navigation = _a.navigation, publicKey = _a.publicKey;
28
+ var appInfo = _a.appInfo, navigation = _a.navigation, publicKey = _a.publicKey, rest = __rest(_a, ["appInfo", "navigation", "publicKey"]);
7
29
  var dispatch = useAppDispatch();
8
30
  var _b = useAppSelector(settingsSelector), data = _b.data, error = _b.error, loading = _b.loading;
9
31
  var deviceInfo = data.deviceInfo, language = data.language;
@@ -12,6 +34,7 @@ export var useAppConfig = function (_a) {
12
34
  dispatch(handleActiveFlowScreens(navigation));
13
35
  dispatch(getClientIp());
14
36
  dispatch(getBrowserFingerPrint(appInfo));
37
+ dispatch(handleSetAppConfig(__assign({ appInfo: appInfo, publicKey: publicKey }, rest)));
15
38
  }, []);
16
39
  var handleGetOperator = function () {
17
40
  var _a, _b;
@@ -25,6 +48,10 @@ export var useAppConfig = function (_a) {
25
48
  };
26
49
  dispatch(getOperator(payload));
27
50
  };
51
+ useEffect(function () {
52
+ if (data.appConfig.language)
53
+ dispatch(handleLanguage(data.appConfig.language));
54
+ }, [data.appConfig.language]);
28
55
  useEffect(function () {
29
56
  if (device.os.name && browser.name && publicKey) {
30
57
  handleGetOperator();
@@ -0,0 +1 @@
1
+ export declare const useErrorListener: () => void;
@@ -0,0 +1,19 @@
1
+ import { useEffect } from 'react';
2
+ import { settingsSelector } from '../app/settings';
3
+ import { useAppSelector } from './useAppSelector';
4
+ import { connectSelector } from '../features/app/connect/connectStore';
5
+ export var useErrorListener = function () {
6
+ var settings = useAppSelector(settingsSelector);
7
+ var connect = useAppSelector(connectSelector);
8
+ useEffect(function () {
9
+ var _a, _b;
10
+ if (connect.error || settings.error) {
11
+ (_b = (_a = settings.data.appConfig) === null || _a === void 0 ? void 0 : _a.onError) === null || _b === void 0 ? void 0 : _b.call(_a, settings.error || connect.error);
12
+ }
13
+ }, [connect.error, settings.error]);
14
+ useEffect(function () {
15
+ var _a, _b;
16
+ if (!settings.error)
17
+ (_b = (_a = settings.data.appConfig).onReady) === null || _b === void 0 ? void 0 : _b.call(_a);
18
+ }, [settings.error]);
19
+ };
@@ -6,3 +6,4 @@ export * from './html';
6
6
  export * from './validation';
7
7
  export * from './string';
8
8
  export * from './device';
9
+ export * from './rsa';
@@ -6,3 +6,4 @@ export * from './html';
6
6
  export * from './validation';
7
7
  export * from './string';
8
8
  export * from './device';
9
+ export * from './rsa';
@@ -0,0 +1,2 @@
1
+ export declare const encryptObject: (data: unknown) => string | false;
2
+ export declare const encryptString: (string: string) => string;
@@ -0,0 +1,19 @@
1
+ import { JSEncrypt } from 'jsencrypt';
2
+ import { RSA_FRONTEND_MW_PUBLIC_KEY } from '../constants';
3
+ var rsa = new JSEncrypt();
4
+ rsa.setPublicKey(RSA_FRONTEND_MW_PUBLIC_KEY);
5
+ export var encryptObject = function (data) {
6
+ if (typeof data !== 'object')
7
+ throw new Error('data should be from type object');
8
+ var obj2Str = JSON.stringify(data);
9
+ var encrypted = rsa.encrypt(obj2Str);
10
+ return encrypted;
11
+ };
12
+ export var encryptString = function (string) {
13
+ if (typeof string !== 'string')
14
+ throw new Error('string should be from type string');
15
+ var encrypted = rsa.encrypt(string);
16
+ if (!encrypted)
17
+ throw new Error('encryption data reached max allowed length');
18
+ return encrypted;
19
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tap-payments/auth-jsconnect",
3
- "version": "1.0.23",
3
+ "version": "1.0.26",
4
4
  "description": "connect library, auth",
5
5
  "private": false,
6
6
  "main": "build/index.js",
@@ -35,6 +35,7 @@
35
35
  "@babel/preset-react": "^7.18.6",
36
36
  "@babel/preset-typescript": "^7.18.6",
37
37
  "@types/lodash-es": "^4.17.6",
38
+ "@types/moment-hijri": "^2.1.0",
38
39
  "@types/react": "^18.0.15",
39
40
  "@types/react-calendar": "~3.5.1",
40
41
  "@types/react-dom": "^18.0.6",
@@ -58,7 +59,6 @@
58
59
  "fork-ts-checker-webpack-plugin": "^7.2.12",
59
60
  "html-loader": "^3.1.2",
60
61
  "html-webpack-plugin": "^5.5.0",
61
- "@types/moment-hijri": "^2.1.0",
62
62
  "husky": "^8.0.1",
63
63
  "lint-staged": "^13.0.3",
64
64
  "mini-css-extract-plugin": "^2.6.1",
@@ -87,6 +87,7 @@
87
87
  "i18next": "^21.8.14",
88
88
  "i18next-browser-languagedetector": "^6.1.4",
89
89
  "i18next-http-backend": "^1.4.1",
90
+ "jsencrypt": "^3.2.1",
90
91
  "lodash-es": "^4.17.21",
91
92
  "moment-hijri": "~2.1.2",
92
93
  "react": "^18.2.0",