@tap-payments/auth-jsconnect 2.9.1-development → 2.9.3-development

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.
@@ -47,6 +47,20 @@ export type CreateNafathAuthBody = {
47
47
  board_id?: string;
48
48
  user_id?: string;
49
49
  };
50
+ export type CreateKYCAuthBody = {
51
+ country: string;
52
+ scope: string;
53
+ auth_type?: number;
54
+ email_url?: string;
55
+ sign_in?: boolean;
56
+ is_lead?: boolean;
57
+ step_name?: string;
58
+ encryption_contract: Array<string>;
59
+ lang?: LanguageMode;
60
+ lead_id?: string;
61
+ board_id?: string;
62
+ user_id?: string;
63
+ };
50
64
  export type VerifyAuthBody = {
51
65
  auth_token: string;
52
66
  auth_type: number;
@@ -104,7 +118,7 @@ export type getExpressTokenVerifyParams = {
104
118
  };
105
119
  export type ConfigBody = Pick<ConfigInfo, 'scope' | 'data' | 'lead' | 'board' | 'interface' | 'redirect' | 'post'>;
106
120
  declare const authService: {
107
- createAuth: (data: CreateAuthBody, config?: AxiosRequestConfig) => Promise<any>;
121
+ createAuth: (data: CreateAuthBody | CreateKYCAuthBody, config?: AxiosRequestConfig) => Promise<any>;
108
122
  verifyAuth: (data: VerifyAuthBody | VerifyOperationAuthBody, config?: AxiosRequestConfig) => Promise<import("axios").AxiosResponse<any, any>>;
109
123
  createPassword: (data: CreatePasswordBody) => Promise<any>;
110
124
  verifyExpressAuth: (data: VerifyAuthExpressOTPBody) => Promise<any>;
@@ -1,6 +1,6 @@
1
1
  import axiosInstance, { setAxiosGlobalHeaders, removeAxiosGlobalHeaders, getAxiosHeaders } from './axios';
2
2
  import { ValidateOperatorBody, ConfirmBody } from './operator';
3
- import { CreateAuthBody, VerifyAuthBody, CreatePasswordBody, VerifyOperationAuthBody, ResetPasswordVerifyAuthBody, VerifyAuthExpressOTPBody, ConfigBody, CreateNafathAuthBody } from './auth';
3
+ import { CreateAuthBody, VerifyAuthBody, CreatePasswordBody, VerifyOperationAuthBody, ResetPasswordVerifyAuthBody, VerifyAuthExpressOTPBody, ConfigBody, CreateNafathAuthBody, CreateKYCAuthBody } from './auth';
4
4
  import { UpdateLeadBody, LeadVerifyBody, CreateLeadBody, LeadOTPVerifyBody, LeadIdentityUpdateBody, ExpressLeadVerifyBody } from './lead';
5
5
  import { CheckEmailBody, CheckBrandBody } from './availabilityServices';
6
6
  import { EntityInfoBody, EntityBankUpdateBody, BankDocumentInfo, UpdateEntityBody, UpdateEntityActivityBody, UpdateEntityCapitalBody, UpdateEntityAOAFileBody, RemoveEntityActivity, MerchantListBody, CreateEntityBody } from './entity';
@@ -30,7 +30,7 @@ declare const API: {
30
30
  getCurrency: (countryCode: string) => Promise<any>;
31
31
  };
32
32
  authService: {
33
- createAuth: (data: CreateAuthBody, config?: import("axios").AxiosRequestConfig<any> | undefined) => Promise<any>;
33
+ createAuth: (data: CreateAuthBody | CreateKYCAuthBody, config?: import("axios").AxiosRequestConfig<any> | undefined) => Promise<any>;
34
34
  verifyAuth: (data: VerifyAuthBody | VerifyOperationAuthBody, config?: import("axios").AxiosRequestConfig<any> | undefined) => Promise<import("axios").AxiosResponse<any, any>>;
35
35
  createPassword: (data: CreatePasswordBody) => Promise<any>;
36
36
  verifyExpressAuth: (data: VerifyAuthExpressOTPBody) => Promise<any>;
@@ -164,6 +164,6 @@ declare const API: {
164
164
  getInitialData: (body: InitBody) => Promise<any>;
165
165
  };
166
166
  };
167
- export type { ValidateOperatorBody, CreateAuthBody, ExpressCreateAccountBody, VerifyAuthBody, CreateLeadBody, UpdateLeadBody, LeadVerifyBody, LeadOTPVerifyBody, CheckEmailBody, CheckBrandBody, LeadIdentityUpdateBody, EntityInfoBody, CreateAccountBody, EntityBankUpdateBody, CreatePasswordBody, BrandListBody, VerifyOperationAuthBody, ResetPasswordVerifyAuthBody, UpdateBoardBody, UpdateBrandBody, DataElementBody, UploadFileBody, UpdateEntityBody, DocumentUpdateBody, DocumentInfo, VerifyAuthExpressOTPBody, UpdateIndividualBody, UpdateEntityActivityBody, UpdateEntityCapitalBody, BankDocumentInfo, GetUserListBody, GetIndividualListBody, RequestEmailBody, DocumentBody, UpdateEntityAOAFileBody, InitBody, RemoveBrandActivity, RemoveEntityActivity, UpdateIndividualWithTypeBody, UpdateMultipleIndividualBody, ExpressLeadVerifyBody, ConfirmBody, ConfigBody, MerchantListBody, CreateEntityBody, CreateNafathAuthBody, GetUserListSegmentBody };
167
+ export type { ValidateOperatorBody, CreateAuthBody, ExpressCreateAccountBody, VerifyAuthBody, CreateLeadBody, UpdateLeadBody, LeadVerifyBody, LeadOTPVerifyBody, CheckEmailBody, CheckBrandBody, LeadIdentityUpdateBody, EntityInfoBody, CreateAccountBody, EntityBankUpdateBody, CreatePasswordBody, BrandListBody, VerifyOperationAuthBody, ResetPasswordVerifyAuthBody, UpdateBoardBody, UpdateBrandBody, DataElementBody, UploadFileBody, UpdateEntityBody, DocumentUpdateBody, DocumentInfo, VerifyAuthExpressOTPBody, UpdateIndividualBody, UpdateEntityActivityBody, UpdateEntityCapitalBody, BankDocumentInfo, GetUserListBody, GetIndividualListBody, RequestEmailBody, DocumentBody, UpdateEntityAOAFileBody, InitBody, RemoveBrandActivity, RemoveEntityActivity, UpdateIndividualWithTypeBody, UpdateMultipleIndividualBody, ExpressLeadVerifyBody, ConfirmBody, ConfigBody, MerchantListBody, CreateEntityBody, CreateNafathAuthBody, GetUserListSegmentBody, CreateKYCAuthBody };
168
168
  export { setAxiosGlobalHeaders, removeAxiosGlobalHeaders, axiosInstance, getAxiosHeaders };
169
169
  export default API;
@@ -372,6 +372,7 @@
372
372
  "kyc_terms_description": "يجب على الممثل المعتمد للشركة قراءة الوثائق القانونية والموافقة عليها",
373
373
  "kyc_terms_description_single_user": "يجب على الشخص المخول الذي يحمل الهوية {{id_number}} قراءة المستندات القانونية والموافقة عليها",
374
374
  "kyc_terms_title": "وثائق قانونية",
375
+ "kyc_token_invalid": "الرجاء مراجعة رابط المرسل اليك",
375
376
  "kyc_users_description": "يرجى اختيار رقم هوية الممثل المعتمد للموافقة عليه مع {{provider}}",
376
377
  "language": "English",
377
378
  "license_info": "معلومات الترخيص",
@@ -385,6 +385,7 @@
385
385
  "kyc_terms_description": "An authorized representative of the company must read and approve the legal documents",
386
386
  "kyc_terms_description_single_user": "The authorized person with the ID {{id_number}} must read and approve the legal documents",
387
387
  "kyc_terms_title": "Legal documents",
388
+ "kyc_token_invalid": "May you please verify link of which you are trying to open.",
388
389
  "kyc_users_description": "Please select an authorized registered ID to approve with {{provider}}",
389
390
  "kyc_verification": "Know Your Customer (KYC)",
390
391
  "language": "العربية",
@@ -404,6 +404,12 @@ export var KYC_SCREENS_NAVIGATION = [
404
404
  prev: '',
405
405
  order: 1
406
406
  },
407
+ {
408
+ name: CONNECT_FLOWS.kyc.tokenError,
409
+ next: '',
410
+ prev: '',
411
+ order: 1
412
+ },
407
413
  {
408
414
  name: CONNECT_FLOWS.kyc.users,
409
415
  next: [CONNECT_FLOWS.kyc.verifyNafath, CONNECT_FLOWS.kyc.verifyPACI],
@@ -1,5 +1,6 @@
1
1
  export declare enum KYC_FLOWS {
2
2
  loadingData = "KYC_LOADING_DATA_STEP",
3
+ tokenError = "TOKEN_ERROR_STEP",
3
4
  verify = "KYC_VERIFY_STEP",
4
5
  terms = "KYC_TERMS_STEP",
5
6
  users = "KYC_USERS_STEP",
@@ -11,6 +12,7 @@ export declare enum KYC_FLOWS {
11
12
  export declare const CONNECT_FLOWS: {
12
13
  kyc: {
13
14
  loadingData: KYC_FLOWS;
15
+ tokenError: KYC_FLOWS;
14
16
  verify: KYC_FLOWS;
15
17
  terms: KYC_FLOWS;
16
18
  users: KYC_FLOWS;
@@ -1,6 +1,7 @@
1
1
  export var KYC_FLOWS;
2
2
  (function (KYC_FLOWS) {
3
3
  KYC_FLOWS["loadingData"] = "KYC_LOADING_DATA_STEP";
4
+ KYC_FLOWS["tokenError"] = "TOKEN_ERROR_STEP";
4
5
  KYC_FLOWS["verify"] = "KYC_VERIFY_STEP";
5
6
  KYC_FLOWS["terms"] = "KYC_TERMS_STEP";
6
7
  KYC_FLOWS["users"] = "KYC_USERS_STEP";
@@ -12,6 +13,7 @@ export var KYC_FLOWS;
12
13
  export var CONNECT_FLOWS = {
13
14
  kyc: {
14
15
  loadingData: KYC_FLOWS.loadingData,
16
+ tokenError: KYC_FLOWS.tokenError,
15
17
  verify: KYC_FLOWS.verify,
16
18
  terms: KYC_FLOWS.terms,
17
19
  users: KYC_FLOWS.users,
@@ -49,7 +49,7 @@ var _a;
49
49
  import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
50
50
  import { handlePublicKey, handleSetCountryByIso2 } from '../../../app/settings';
51
51
  import { FlowsTypes } from '../../../@types';
52
- import { CONNECT_FLOWS, IDENTIFICATION_TYPE, KYC_STEP_NAMES } from '../../../constants';
52
+ import { CONNECT_FLOWS, KYC_STEP_NAMES } from '../../../constants';
53
53
  import API from '../../../api';
54
54
  import { sendCustomEventToGTM, sleep } from '../../../utils';
55
55
  export var verifyTokenApi = createAsyncThunk('kyc/verifyTokenApi', function (_a, thunkApi) {
@@ -98,65 +98,56 @@ export var verifyTokenApi = createAsyncThunk('kyc/verifyTokenApi', function (_a,
98
98
  });
99
99
  });
100
100
  export var createPaciAuth = createAsyncThunk('kyc/createPaciAuth', function (user, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
101
- var _a, settings, kyc, verifyTokenData, _b, id, identification, requestBody, data, nextScreen;
102
- var _c, _d;
103
- return __generator(this, function (_e) {
104
- switch (_e.label) {
101
+ var _a, settings, kyc, verifyTokenData, id, requestBody, data, nextScreen;
102
+ var _b, _c;
103
+ return __generator(this, function (_d) {
104
+ switch (_d.label) {
105
105
  case 0:
106
106
  _a = thunkApi.getState(), settings = _a.settings, kyc = _a.kyc;
107
107
  verifyTokenData = (kyc.data.responseData || {}).verifyTokenData;
108
- _b = user || {}, id = _b.id, identification = _b.identification;
108
+ id = (user || {}).id;
109
109
  requestBody = {
110
110
  country: settings.data.businessCountry.iso2,
111
111
  lang: settings.data.language,
112
- user_credentail: {
113
- identification_id: identification === null || identification === void 0 ? void 0 : identification.id,
114
- country_code: 'KW'
115
- },
116
112
  is_lead: false,
117
113
  scope: 'auth',
118
114
  board_id: verifyTokenData === null || verifyTokenData === void 0 ? void 0 : verifyTokenData.boardId,
119
115
  user_id: id,
120
116
  step_name: KYC_STEP_NAMES.KYC_CREATE_PACI,
121
- encryption_contract: ['user_credentail.identification_id']
117
+ encryption_contract: []
122
118
  };
123
119
  return [4, API.authService.createAuth(requestBody)];
124
120
  case 1:
125
- data = _e.sent();
126
- (_d = (_c = settings.data.appConfig).onStepCompleted) === null || _d === void 0 ? void 0 : _d.call(_c, settings.data.activeScreen.name, requestBody.user_credentail);
121
+ data = _d.sent();
122
+ (_c = (_b = settings.data.appConfig).onStepCompleted) === null || _c === void 0 ? void 0 : _c.call(_b, settings.data.activeScreen.name, { id: id });
127
123
  nextScreen = CONNECT_FLOWS.kyc.verifyPACI;
128
124
  return [2, { data: data, nextScreen: nextScreen }];
129
125
  }
130
126
  });
131
127
  }); });
132
128
  export var createNafathAuth = createAsyncThunk('kyc/createNafathAuth', function (user, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
133
- var _a, settings, kyc, verifyTokenData, _b, id, identification, requestBody, data, nextScreen;
134
- var _c, _d;
135
- return __generator(this, function (_e) {
136
- switch (_e.label) {
129
+ var _a, settings, kyc, verifyTokenData, id, requestBody, data, nextScreen;
130
+ var _b, _c;
131
+ return __generator(this, function (_d) {
132
+ switch (_d.label) {
137
133
  case 0:
138
134
  _a = thunkApi.getState(), settings = _a.settings, kyc = _a.kyc;
139
135
  verifyTokenData = (kyc.data.responseData || {}).verifyTokenData;
140
- _b = user || {}, id = _b.id, identification = _b.identification;
136
+ id = (user || {}).id;
141
137
  requestBody = {
142
138
  country: settings.data.businessCountry.iso2,
143
139
  lang: settings.data.language,
144
- user_credentail: {
145
- identification_id: identification === null || identification === void 0 ? void 0 : identification.id,
146
- identification_id_type: IDENTIFICATION_TYPE.NAFATH,
147
- country_code: settings.data.businessCountry.iso2
148
- },
149
140
  is_lead: false,
150
141
  scope: 'auth',
151
142
  board_id: verifyTokenData === null || verifyTokenData === void 0 ? void 0 : verifyTokenData.boardId,
152
143
  user_id: id,
153
144
  step_name: KYC_STEP_NAMES.KYC_CREATE_NAFATH,
154
- encryption_contract: ['user_credentail.country_code', 'user_credentail.identification_id', 'user_credentail.identification_id_type']
145
+ encryption_contract: []
155
146
  };
156
- return [4, API.authService.createAuthKitNID(requestBody)];
147
+ return [4, API.authService.createAuth(requestBody)];
157
148
  case 1:
158
- data = _e.sent();
159
- (_d = (_c = settings.data.appConfig).onStepCompleted) === null || _d === void 0 ? void 0 : _d.call(_c, settings.data.activeScreen.name, requestBody);
149
+ data = _d.sent();
150
+ (_c = (_b = settings.data.appConfig).onStepCompleted) === null || _c === void 0 ? void 0 : _c.call(_b, settings.data.activeScreen.name, requestBody);
160
151
  nextScreen = CONNECT_FLOWS.kyc.verifyNafath;
161
152
  return [2, { data: data, nextScreen: nextScreen }];
162
153
  }
@@ -128,6 +128,7 @@ import BoardResetPasswordSuccessPage from './board/screens/ResetPasswordSuccess'
128
128
  import BoardDataLoadingPage from './board/screens/PrepareDataLoading';
129
129
  import BoardOperatorError from './board/screens/OperatorError';
130
130
  import KycLoadingPage from './kyc/screens/Loading';
131
+ import KycTokenErrorPage from './kyc/screens/TokenError';
131
132
  import KycVerifyNafathPage from './kyc/screens/VerifyNafath';
132
133
  import KycVerifyPaciPage from './kyc/screens/VerifyPaci';
133
134
  import KycOperatorErrorPage from './kyc/screens/OperatorError';
@@ -645,6 +646,10 @@ export var kycFeatureScreens = [
645
646
  name: CONNECT_FLOWS.kyc.loadingData,
646
647
  element: KycLoadingPage
647
648
  },
649
+ {
650
+ name: CONNECT_FLOWS.kyc.tokenError,
651
+ element: KycTokenErrorPage
652
+ },
648
653
  {
649
654
  name: CONNECT_FLOWS.kyc.terms,
650
655
  element: KycTermsPage
@@ -56,7 +56,11 @@ var KYC = memo(function (_a) {
56
56
  var nextScreen = _a.nextScreen;
57
57
  dispatch(handleCurrentActiveScreen(nextScreen));
58
58
  })
59
- .catch(function () { });
59
+ .catch(function (error) {
60
+ if (error.message.toLowerCase() === 'failed to decrypt verify_token') {
61
+ dispatch(handleCurrentActiveScreen(CONNECT_FLOWS.kyc.tokenError));
62
+ }
63
+ });
60
64
  };
61
65
  };
62
66
  useVerifyToken({
@@ -0,0 +1,5 @@
1
+ import * as React from 'react';
2
+ export interface TokenErrorProps {
3
+ }
4
+ declare const _default: React.MemoExoticComponent<({}: TokenErrorProps) => import("react/jsx-runtime").JSX.Element>;
5
+ export default _default;
@@ -0,0 +1,9 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import * as React from 'react';
3
+ import { useTranslation } from 'react-i18next';
4
+ import GenericError from '../../../shared/GenericError';
5
+ var TokenError = function (_a) {
6
+ var t = useTranslation().t;
7
+ return _jsx(GenericError, { error: t('kyc_token_invalid'), errorTitle: t('oops') });
8
+ };
9
+ export default React.memo(TokenError);
@@ -0,0 +1,2 @@
1
+ import TokenError from './TokenError';
2
+ export default TokenError;
@@ -0,0 +1,2 @@
1
+ import TokenError from './TokenError';
2
+ export default TokenError;
@@ -16,11 +16,12 @@ import { styled } from '@mui/material/styles';
16
16
  import { handleNextScreenStep, settingsSelector } from '../../../../app/settings';
17
17
  import Text from '../../../../components/Text';
18
18
  import Loader from '../../../../components/Loader';
19
+ import Warning from '../../../../components/Warning';
19
20
  import { isSA, maskIDNumber } from '../../../../utils';
20
21
  import { CONNECT_FLOWS, ICONS_NAMES } from '../../../../constants';
21
22
  import { useAppDispatch, useAppSelector, useSanitizedTranslation } from '../../../../hooks';
22
23
  import ScreenContainer from '../../../shared/Containers/ScreenContainer';
23
- import { createNafathAuth, createPaciAuth, kycSelector } from '../../../app/kyc/kycStore';
24
+ import { clearError, createNafathAuth, createPaciAuth, kycSelector } from '../../../app/kyc/kycStore';
24
25
  var BoxStyled = styled(Box, { shouldForwardProp: function (prop) { return !['loading'].includes(prop.toString()); } })(function (_a) {
25
26
  var theme = _a.theme, loading = _a.loading;
26
27
  return (__assign({ marginTop: theme.spacing(1), boxShadow: theme.shadows[3], backgroundColor: theme.palette.common.white, fontWeight: theme.typography.fontWeightMedium, fontSize: theme.spacing(1.875), padding: theme.spacing(1.5), borderRadius: theme.spacing(3.875), textAlign: 'center', cursor: 'pointer', display: 'flex', justifyContent: 'space-between' }, (loading && {
@@ -49,6 +50,8 @@ var Users = function () {
49
50
  var userList = ((_a = data.responseData) === null || _a === void 0 ? void 0 : _a.userList) || [];
50
51
  var isSACountry = React.useMemo(function () { return isSA(settingsData.businessCountry.iso2); }, [settingsData.businessCountry.iso2]);
51
52
  var onClickUser = function (user) {
53
+ if (error)
54
+ dispatch(clearError());
52
55
  setActiveUser(user);
53
56
  if (isSACountry) {
54
57
  dispatch(createNafathAuth(user))
@@ -68,6 +71,6 @@ var Users = function () {
68
71
  };
69
72
  return (_jsxs(ScreenContainer, __assign({ sx: { pl: 2, pr: 2 } }, { children: [_jsx(DescriptionStyled, { children: st('kyc_users_description', { provider: isSACountry ? 'NAFATH' : 'PACI' }) }), userList.map(function (user, index) {
70
73
  return (_jsx(BoxStyled, __assign({ onClick: function () { return onClickUser(user); } }, { children: (activeUser === null || activeUser === void 0 ? void 0 : activeUser.id) === user.id && loading ? (_jsx(Loader, { innerColor: 'black', outerColor: 'black', size: 8, style: { height: 20, width: 20 }, toggleAnimation: !!loading })) : (_jsxs(_Fragment, { children: [_jsx(ImgStyled, { src: ICONS_NAMES.individual_filled_icon }), maskIDNumber(user.identification.id), _jsx("span", {})] })) }), index));
71
- })] })));
74
+ }), error && (_jsx(Warning, __assign({ sx: { mt: 3, mb: 3 }, warningType: 'error' }, { children: error })))] })));
72
75
  };
73
76
  export default memo(Users);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tap-payments/auth-jsconnect",
3
- "version": "2.9.1-development",
3
+ "version": "2.9.3-development",
4
4
  "description": "connect library, auth",
5
5
  "private": false,
6
6
  "main": "build/index.js",