@tap-payments/auth-jsconnect 1.0.88 → 1.0.89
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.
- package/README.md +216 -0
- package/build/constants/app.d.ts +1 -4
- package/build/constants/app.js +1 -4
- package/build/features/app/bank/bankStore.js +35 -25
- package/build/features/app/business/businessStore.js +9 -9
- package/build/features/app/connect/connectStore.js +8 -1
- package/build/features/app/individual/individualStore.d.ts +2 -1
- package/build/features/app/individual/individualStore.js +52 -43
- package/build/features/app/password/passwordStore.js +32 -22
- package/build/features/app/tax/taxStore.js +24 -14
- package/build/utils/object.d.ts +1 -0
- package/build/utils/object.js +5 -0
- package/package.json +126 -126
package/README.md
CHANGED
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
# Auth-JsConnect
|
|
2
|
+
|
|
3
|
+
Handling user authentication and identification
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
This is a [React](https://reactjs.org/) module available through the
|
|
8
|
+
[npm registry](https://www.npmjs.com/). Installation is done using the
|
|
9
|
+
[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):
|
|
10
|
+
|
|
11
|
+
```console
|
|
12
|
+
npm install @tap-payments/auth-jsconnect
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
---------------------------- OR -------------------------
|
|
16
|
+
|
|
17
|
+
```console
|
|
18
|
+
yarn add @tap-payments/auth-jsconnect
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Features
|
|
22
|
+
|
|
23
|
+
- [Connect](#Connect)
|
|
24
|
+
- [Business](#Business)
|
|
25
|
+
- [Password](#Password)
|
|
26
|
+
- [Individual](#Individual)
|
|
27
|
+
- [Bank](#Bank)
|
|
28
|
+
- [Tax](#Tax)
|
|
29
|
+
|
|
30
|
+
## Examples
|
|
31
|
+
|
|
32
|
+
### ES6
|
|
33
|
+
|
|
34
|
+
```js
|
|
35
|
+
import { ConnectLib } from '@tap-payments/auth-jsconnect'
|
|
36
|
+
|
|
37
|
+
const App = () => {
|
|
38
|
+
return (
|
|
39
|
+
<ConnectLib
|
|
40
|
+
open={true}
|
|
41
|
+
merchantDomain={'https://www.example.com'}
|
|
42
|
+
publicKey={'pk_test_xxxxxx'}
|
|
43
|
+
appInfo={{
|
|
44
|
+
identifier: 'tap_connect_demo',
|
|
45
|
+
name: 'Tap Connect Demo',
|
|
46
|
+
version: 'V2.0.0'
|
|
47
|
+
}}
|
|
48
|
+
businessCountryCode='SA'
|
|
49
|
+
language='en'
|
|
50
|
+
onError={(error) => {
|
|
51
|
+
alert(JSON.stringify({ error }))
|
|
52
|
+
}}
|
|
53
|
+
onFlowCompleted={(data) => {
|
|
54
|
+
console.log(data)
|
|
55
|
+
}}
|
|
56
|
+
onReady={() => {
|
|
57
|
+
console.log('ready!')
|
|
58
|
+
}}
|
|
59
|
+
onStepCompleted={(name, data) => {
|
|
60
|
+
console.log(name, data)
|
|
61
|
+
}}
|
|
62
|
+
onStepError={(name, error) => {
|
|
63
|
+
console.log(name, error)
|
|
64
|
+
}}
|
|
65
|
+
onStepStarted={(name) => {
|
|
66
|
+
console.log(name)
|
|
67
|
+
}}
|
|
68
|
+
scope={[]}
|
|
69
|
+
/>
|
|
70
|
+
)
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## ErrorObject
|
|
75
|
+
|
|
76
|
+
- `statusCode`: the status code of the error. `required`
|
|
77
|
+
- `message`: the error message. `required`
|
|
78
|
+
- `description`: the error description. `optional`
|
|
79
|
+
- `help`: the error url that can help the client to fix the api issue e.g
|
|
80
|
+
(<https://your-domain.example/integration/fixes/auth-api>) `optional`
|
|
81
|
+
- `invalidParams`: the errors of request in case you need to validate the
|
|
82
|
+
request data. `optional`
|
|
83
|
+
|
|
84
|
+
- `message`: the error message. `required`
|
|
85
|
+
- `param`: the error parameter name e.g (email, password, name, etc). `optional`
|
|
86
|
+
- `location`: the location of parameter key. `required`
|
|
87
|
+
|
|
88
|
+
- `errorKey`: the error key and the main purpose we can use it for localization part
|
|
89
|
+
and in this case we will have a generic errors we can catch any error message
|
|
90
|
+
by key `for example:` we can store local.en.json and local.en.json includes
|
|
91
|
+
|
|
92
|
+
```json
|
|
93
|
+
{ "bad_request": "invalid user request data" }
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
and local.ar.json includes
|
|
97
|
+
|
|
98
|
+
```json
|
|
99
|
+
{ "bad_request": "بايانات غير صحيحة" }
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
and the both files located in the
|
|
103
|
+
frontend so by using the response `errorKey` we can localize the error message
|
|
104
|
+
easily. `optional`
|
|
105
|
+
|
|
106
|
+
## HttpError
|
|
107
|
+
|
|
108
|
+
### Initializer
|
|
109
|
+
|
|
110
|
+
it's a middleware should be used in the top of your app or at lest before your
|
|
111
|
+
routes that include `HttpError`
|
|
112
|
+
|
|
113
|
+
```js
|
|
114
|
+
// in the beginning of your app (important)
|
|
115
|
+
app.use(HttpError.initializer)
|
|
116
|
+
// OR
|
|
117
|
+
app.use((req, res, next) => {
|
|
118
|
+
HttpError.initializer(req, res, next)
|
|
119
|
+
})
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Handler
|
|
123
|
+
|
|
124
|
+
it's a middleware and it will handle all the errors returned by
|
|
125
|
+
`HttpError` functions and it will send it back to the client but if the error
|
|
126
|
+
not belong ot the lib it will pass it using next fun
|
|
127
|
+
|
|
128
|
+
```js
|
|
129
|
+
// in the end of your app (important)
|
|
130
|
+
app.use(HttpError.handler)
|
|
131
|
+
// OR
|
|
132
|
+
app.use((err, req, res, next) => {
|
|
133
|
+
HttpError.handler(err, req, res, next)
|
|
134
|
+
})
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### customError
|
|
138
|
+
|
|
139
|
+
it's a helper function can help you to create your custom error.
|
|
140
|
+
|
|
141
|
+
### HttpError.{{ any function from the next list }}
|
|
142
|
+
|
|
143
|
+
- they are helper functions allow you to send sepecific error to the client
|
|
144
|
+
|
|
145
|
+
- `attrs` error object to customize your error response `optional`
|
|
146
|
+
- `message`: the error message. `required`
|
|
147
|
+
- `errorKey`: the error key. `optional`
|
|
148
|
+
- `help`: the error help location/url. `optional`
|
|
149
|
+
- `description`: the error description `optional`
|
|
150
|
+
- `invalidParams`: the request parameters errors `optional`
|
|
151
|
+
|
|
152
|
+
| status code | function name |
|
|
153
|
+
| ----------- | ----------------------------- |
|
|
154
|
+
| 400 | BadRequest |
|
|
155
|
+
| 401 | Unauthorized |
|
|
156
|
+
| 402 | PaymentRequired |
|
|
157
|
+
| 403 | Forbidden |
|
|
158
|
+
| 404 | NotFound |
|
|
159
|
+
| 405 | MethodNotAllowed |
|
|
160
|
+
| 406 | NotAcceptable |
|
|
161
|
+
| 407 | ProxyAuthenticationRequired |
|
|
162
|
+
| 408 | RequestTimeout |
|
|
163
|
+
| 409 | Conflict |
|
|
164
|
+
| 410 | Gone |
|
|
165
|
+
| 411 | LengthRequired |
|
|
166
|
+
| 412 | PreconditionFailed |
|
|
167
|
+
| 413 | PayloadTooLarge |
|
|
168
|
+
| 414 | URITooLong |
|
|
169
|
+
| 415 | UnsupportedMediaType |
|
|
170
|
+
| 416 | RangeNotSatisfiable |
|
|
171
|
+
| 417 | ExpectationFailed |
|
|
172
|
+
| 418 | ImATeapot |
|
|
173
|
+
| 421 | MisdirectedRequest |
|
|
174
|
+
| 422 | UnprocessableEntity |
|
|
175
|
+
| 423 | Locked |
|
|
176
|
+
| 424 | FailedDependency |
|
|
177
|
+
| 425 | TooEarly |
|
|
178
|
+
| 426 | UpgradeRequired |
|
|
179
|
+
| 428 | PreconditionRequired |
|
|
180
|
+
| 429 | TooManyRequests |
|
|
181
|
+
| 431 | RequestHeaderFieldsTooLarge |
|
|
182
|
+
| 451 | UnavailableForLegalReasons |
|
|
183
|
+
| 500 | InternalServerError |
|
|
184
|
+
| 501 | NotImplemented |
|
|
185
|
+
| 502 | BadGateway |
|
|
186
|
+
| 503 | ServiceUnavailable |
|
|
187
|
+
| 504 | GatewayTimeout |
|
|
188
|
+
| 505 | HTTPVersionNotSupported |
|
|
189
|
+
| 506 | VariantAlsoNegotiates |
|
|
190
|
+
| 507 | InsufficientStorage |
|
|
191
|
+
| 508 | LoopDetected |
|
|
192
|
+
| 509 | BandwidthLimitExceeded |
|
|
193
|
+
| 510 | NotExtended |
|
|
194
|
+
| 511 | NetworkAuthenticationRequired |
|
|
195
|
+
|
|
196
|
+
---
|
|
197
|
+
|
|
198
|
+
## RequestValidator
|
|
199
|
+
|
|
200
|
+
it's a middleware should be used after validating the request
|
|
201
|
+
body/parameter/query using `express-validator` library
|
|
202
|
+
|
|
203
|
+
```js
|
|
204
|
+
import { body } from 'express-validator'
|
|
205
|
+
import { RequestValidator } from 'http-error-handling'
|
|
206
|
+
import express, { NextFunction, Request, Response } from 'express'
|
|
207
|
+
let app = express()
|
|
208
|
+
//sample API
|
|
209
|
+
app.get('/validate', body('email').isEmail(), RequestValidator, (req: Request, res: Response, next: NextFunction) => {
|
|
210
|
+
return res.send(req.body)
|
|
211
|
+
})
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
## License
|
|
215
|
+
|
|
216
|
+
[MIT](LICENSE)
|
package/build/constants/app.d.ts
CHANGED
|
@@ -92,25 +92,22 @@ export declare const BUSINESS_STEP_NAMES: {
|
|
|
92
92
|
};
|
|
93
93
|
export declare const BANK_STEP_NAMES: {
|
|
94
94
|
PHONE_AUTH: string;
|
|
95
|
-
IDENTITY_AUTH: string;
|
|
96
95
|
BANK_INFO: string;
|
|
97
96
|
BANK_SUCCESS: string;
|
|
98
97
|
};
|
|
99
98
|
export declare const TAX_STEP_NAMES: {
|
|
100
99
|
PHONE_AUTH: string;
|
|
101
|
-
IDENTITY_AUTH: string;
|
|
102
100
|
TAX_INFO: string;
|
|
103
101
|
TAX_SUCCESS: string;
|
|
104
102
|
};
|
|
105
103
|
export declare const INDIVIDUAl_STEP_NAMES: {
|
|
106
104
|
PHONE_AUTH: string;
|
|
107
|
-
IDENTITY_AUTH: string;
|
|
108
105
|
INDIVIDUAl_INFO: string;
|
|
109
106
|
INDIVIDUAl_SUCCESS: string;
|
|
110
107
|
};
|
|
111
108
|
export declare const PASSWORD_STEP_NAMES: {
|
|
109
|
+
PASSWORD_INFO: string;
|
|
112
110
|
PHONE_AUTH: string;
|
|
113
|
-
IDENTITY_AUTH: string;
|
|
114
111
|
PASSWORD_CREATE: string;
|
|
115
112
|
PASSWORD_SUCCESS: string;
|
|
116
113
|
};
|
package/build/constants/app.js
CHANGED
|
@@ -291,25 +291,22 @@ export var BUSINESS_STEP_NAMES = {
|
|
|
291
291
|
};
|
|
292
292
|
export var BANK_STEP_NAMES = {
|
|
293
293
|
PHONE_AUTH: 'bank_phone_auth',
|
|
294
|
-
IDENTITY_AUTH: 'bank_identity_auth',
|
|
295
294
|
BANK_INFO: 'bank_info',
|
|
296
295
|
BANK_SUCCESS: 'bank_completed'
|
|
297
296
|
};
|
|
298
297
|
export var TAX_STEP_NAMES = {
|
|
299
298
|
PHONE_AUTH: 'tax_phone_auth',
|
|
300
|
-
IDENTITY_AUTH: 'tax_identity_auth',
|
|
301
299
|
TAX_INFO: 'tax_info',
|
|
302
300
|
TAX_SUCCESS: 'tax_completed'
|
|
303
301
|
};
|
|
304
302
|
export var INDIVIDUAl_STEP_NAMES = {
|
|
305
303
|
PHONE_AUTH: 'individual_phone_auth',
|
|
306
|
-
IDENTITY_AUTH: 'individual_identity_auth',
|
|
307
304
|
INDIVIDUAl_INFO: 'individual_info',
|
|
308
305
|
INDIVIDUAl_SUCCESS: 'individual_completed'
|
|
309
306
|
};
|
|
310
307
|
export var PASSWORD_STEP_NAMES = {
|
|
308
|
+
PASSWORD_INFO: 'password_info',
|
|
311
309
|
PHONE_AUTH: 'password_phone_auth',
|
|
312
|
-
IDENTITY_AUTH: 'password_identity_auth',
|
|
313
310
|
PASSWORD_CREATE: 'password_create',
|
|
314
311
|
PASSWORD_SUCCESS: 'password_completed'
|
|
315
312
|
};
|
|
@@ -48,13 +48,13 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
48
48
|
var _a;
|
|
49
49
|
import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
|
|
50
50
|
import API from '../../../api';
|
|
51
|
-
import { removeRequestHeaders } from '../../../utils';
|
|
51
|
+
import { hasKey, removeRequestHeaders } from '../../../utils';
|
|
52
52
|
import { handleNextScreenStep } from '../../../app/settings';
|
|
53
53
|
import { BANK_STEP_NAMES } from '../../../constants';
|
|
54
54
|
export var verifyLeadToken = createAsyncThunk('verifyLeadToken', function (token, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
55
|
-
var payload, data, leadResponse;
|
|
56
|
-
return __generator(this, function (
|
|
57
|
-
switch (
|
|
55
|
+
var payload, data, leadResponse, _a, steps, entity, hasCompleted;
|
|
56
|
+
return __generator(this, function (_b) {
|
|
57
|
+
switch (_b.label) {
|
|
58
58
|
case 0:
|
|
59
59
|
payload = {
|
|
60
60
|
service_name: 'tap_email',
|
|
@@ -62,22 +62,31 @@ export var verifyLeadToken = createAsyncThunk('verifyLeadToken', function (token
|
|
|
62
62
|
};
|
|
63
63
|
return [4, API.leadService.verifyLeadToken(payload)];
|
|
64
64
|
case 1:
|
|
65
|
-
data = (
|
|
65
|
+
data = (_b.sent()).data;
|
|
66
66
|
leadResponse = undefined;
|
|
67
|
-
if (!(!(data === null || data === void 0 ? void 0 : data.errors) && !(data === null || data === void 0 ? void 0 : data.mw_error))) return [3,
|
|
67
|
+
if (!(!(data === null || data === void 0 ? void 0 : data.errors) && !(data === null || data === void 0 ? void 0 : data.mw_error))) return [3, 5];
|
|
68
68
|
return [4, API.leadService.retrieveLead(data === null || data === void 0 ? void 0 : data.id)];
|
|
69
69
|
case 2:
|
|
70
|
-
leadResponse =
|
|
71
|
-
|
|
72
|
-
|
|
70
|
+
leadResponse = _b.sent();
|
|
71
|
+
_a = leadResponse.data, steps = _a.steps, entity = _a.entity;
|
|
72
|
+
hasCompleted = hasKey(steps, BANK_STEP_NAMES.BANK_SUCCESS);
|
|
73
|
+
if (!hasCompleted) return [3, 4];
|
|
74
|
+
return [4, thunkApi.dispatch(retrieveEntityInfo(entity === null || entity === void 0 ? void 0 : entity.id))];
|
|
75
|
+
case 3:
|
|
76
|
+
_b.sent();
|
|
77
|
+
thunkApi.dispatch(handleNextScreenStep('BANK_SUCCESS_FOUR_FLOWS_BUTTONS_STEP'));
|
|
78
|
+
return [3, 5];
|
|
79
|
+
case 4:
|
|
80
|
+
if (data.step_name === BANK_STEP_NAMES.BANK_INFO) {
|
|
81
|
+
thunkApi.dispatch(handleNextScreenStep('BANK_BANK_DETAILS_STEP'));
|
|
73
82
|
}
|
|
74
|
-
|
|
75
|
-
case
|
|
83
|
+
_b.label = 5;
|
|
84
|
+
case 5: return [2, { data: data, leadData: leadResponse === null || leadResponse === void 0 ? void 0 : leadResponse.data, token: token }];
|
|
76
85
|
}
|
|
77
86
|
});
|
|
78
87
|
}); });
|
|
79
88
|
export var verifyBankLeadOTP = createAsyncThunk('verifyBankLeadOTP', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
80
|
-
var _a, bank, settings, responseBody, payload, data, steps,
|
|
89
|
+
var _a, bank, settings, responseBody, payload, data, steps, hasCompleted;
|
|
81
90
|
var _b, _c, _d, _e;
|
|
82
91
|
return __generator(this, function (_f) {
|
|
83
92
|
switch (_f.label) {
|
|
@@ -97,8 +106,8 @@ export var verifyBankLeadOTP = createAsyncThunk('verifyBankLeadOTP', function (p
|
|
|
97
106
|
if (!!data.errors) return [3, 4];
|
|
98
107
|
(_d = (_c = settings.data.appConfig).onStepCompleted) === null || _d === void 0 ? void 0 : _d.call(_c, settings.data.activeScreen.name, { otp: params.otp });
|
|
99
108
|
steps = responseBody === null || responseBody === void 0 ? void 0 : responseBody.steps;
|
|
100
|
-
|
|
101
|
-
if (!
|
|
109
|
+
hasCompleted = hasKey(steps, BANK_STEP_NAMES.BANK_SUCCESS);
|
|
110
|
+
if (!hasCompleted) return [3, 3];
|
|
102
111
|
return [4, thunkApi.dispatch(retrieveEntityInfo((_e = responseBody === null || responseBody === void 0 ? void 0 : responseBody.entity) === null || _e === void 0 ? void 0 : _e.id))];
|
|
103
112
|
case 2:
|
|
104
113
|
_f.sent();
|
|
@@ -175,9 +184,9 @@ export var checkIbanBank = createAsyncThunk('checkIbanBank', function (_a) {
|
|
|
175
184
|
});
|
|
176
185
|
export var updateLeadSuccess = createAsyncThunk('updateLeadBankSuccess', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
177
186
|
var _a, settings, bank, id, payload, data;
|
|
178
|
-
var _b, _c, _d, _e, _f
|
|
179
|
-
return __generator(this, function (
|
|
180
|
-
switch (
|
|
187
|
+
var _b, _c, _d, _e, _f;
|
|
188
|
+
return __generator(this, function (_g) {
|
|
189
|
+
switch (_g.label) {
|
|
181
190
|
case 0:
|
|
182
191
|
_a = thunkApi.getState(), settings = _a.settings, bank = _a.bank;
|
|
183
192
|
id = (bank.data.verify.responseBody || {}).id;
|
|
@@ -185,17 +194,17 @@ export var updateLeadSuccess = createAsyncThunk('updateLeadBankSuccess', functio
|
|
|
185
194
|
return [2];
|
|
186
195
|
payload = {
|
|
187
196
|
step_name: BANK_STEP_NAMES.BANK_SUCCESS,
|
|
188
|
-
id:
|
|
197
|
+
id: id,
|
|
189
198
|
encryption_contract: []
|
|
190
199
|
};
|
|
191
200
|
return [4, API.leadService.updateLead(payload)];
|
|
192
201
|
case 1:
|
|
193
|
-
data = (
|
|
194
|
-
return [4, thunkApi.dispatch(retrieveEntityInfo((
|
|
202
|
+
data = (_g.sent()).data;
|
|
203
|
+
return [4, thunkApi.dispatch(retrieveEntityInfo((_b = data.entity) === null || _b === void 0 ? void 0 : _b.id))];
|
|
195
204
|
case 2:
|
|
196
|
-
|
|
197
|
-
(
|
|
198
|
-
(
|
|
205
|
+
_g.sent();
|
|
206
|
+
(_d = (_c = settings.data.appConfig).onStepCompleted) === null || _d === void 0 ? void 0 : _d.call(_c, settings.data.activeScreen.name, params);
|
|
207
|
+
(_f = (_e = settings.data.appConfig).onFlowCompleted) === null || _f === void 0 ? void 0 : _f.call(_e, { data: data });
|
|
199
208
|
thunkApi.dispatch(handleNextScreenStep());
|
|
200
209
|
return [2, { response: data, formData: params }];
|
|
201
210
|
}
|
|
@@ -249,7 +258,7 @@ export var bankSlice = createSlice({
|
|
|
249
258
|
state.error = description;
|
|
250
259
|
return;
|
|
251
260
|
}
|
|
252
|
-
state.data.verify.responseBody = __assign(__assign({}, data), leadData);
|
|
261
|
+
state.data.verify.responseBody = __assign(__assign(__assign({}, data), leadData), state.data.verify.responseBody);
|
|
253
262
|
state.data.verify.token = token;
|
|
254
263
|
})
|
|
255
264
|
.addCase(verifyLeadToken.rejected, function (state, action) {
|
|
@@ -307,7 +316,8 @@ export var bankSlice = createSlice({
|
|
|
307
316
|
state.error = description;
|
|
308
317
|
return;
|
|
309
318
|
}
|
|
310
|
-
|
|
319
|
+
var flows = response.flows, steps = response.steps;
|
|
320
|
+
state.data.verify.responseBody = __assign(__assign({}, state.data.verify.responseBody), { flows: flows, steps: steps });
|
|
311
321
|
removeRequestHeaders();
|
|
312
322
|
})
|
|
313
323
|
.addCase(updateLeadSuccess.pending, function (state) {
|
|
@@ -60,7 +60,7 @@ import moment from 'moment';
|
|
|
60
60
|
import API from '../../../api';
|
|
61
61
|
import { BusinessType } from '../../../@types';
|
|
62
62
|
import { BUSINESS_STEP_NAMES, defaultCountry, IDENTIFICATION_TYPE, OTHER_CR_LICENSE, OTHER_FL_LICENSE } from '../../../constants';
|
|
63
|
-
import { convertNumbers2English, getFlowUrl, removeRequestHeaders } from '../../../utils';
|
|
63
|
+
import { convertNumbers2English, getFlowUrl, hasKey, removeRequestHeaders } from '../../../utils';
|
|
64
64
|
import { handleNextScreenStep } from '../../../app/settings';
|
|
65
65
|
export var getCountries = createAsyncThunk('getCountries', function (_, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
66
66
|
var settings, countriesBody, businessCountry;
|
|
@@ -133,8 +133,8 @@ export var verifyLeadOTP = createAsyncThunk('verifyLeadOTP', function (params, t
|
|
|
133
133
|
case 2:
|
|
134
134
|
_f.sent();
|
|
135
135
|
(_d = (_c = settings.data.appConfig).onStepCompleted) === null || _d === void 0 ? void 0 : _d.call(_c, settings.data.activeScreen.name, { otp: params.otp });
|
|
136
|
-
steps =
|
|
137
|
-
hasBusinessCompleted =
|
|
136
|
+
steps = responseBody === null || responseBody === void 0 ? void 0 : responseBody.steps;
|
|
137
|
+
hasBusinessCompleted = hasKey(steps, BUSINESS_STEP_NAMES.BUSINESS_SUCCESS);
|
|
138
138
|
if (!isNID) return [3, 3];
|
|
139
139
|
thunkApi.dispatch(handleNextScreenStep());
|
|
140
140
|
return [3, 6];
|
|
@@ -294,7 +294,8 @@ export var updateActivitiesInfo = createAsyncThunk('updateActivitiesInfo', funct
|
|
|
294
294
|
activities: activities,
|
|
295
295
|
channel_services: channel,
|
|
296
296
|
business_operation_start_at: params.operationStartDate,
|
|
297
|
-
step_name: stepName
|
|
297
|
+
step_name: stepName,
|
|
298
|
+
encryption_contract: ['business_operation_start_at']
|
|
298
299
|
};
|
|
299
300
|
return [4, API.entityService.createEntityInfo(requestBody)];
|
|
300
301
|
case 1:
|
|
@@ -348,7 +349,8 @@ export var updateCustomersInfo = createAsyncThunk('updateCustomersInfo', functio
|
|
|
348
349
|
yearly_sales_range: ((_d = params.expectedSale) === null || _d === void 0 ? void 0 : _d.id) || '',
|
|
349
350
|
agree_refund: params.refundPolicy,
|
|
350
351
|
agree_chargeback: params.transactionPolicy,
|
|
351
|
-
step_name: stepName
|
|
352
|
+
step_name: stepName,
|
|
353
|
+
encryption_contract: ['customers_base[0]', 'customers_served_monthly', 'yearly_sales_range']
|
|
352
354
|
};
|
|
353
355
|
return [4, API.entityService.updateEntityInfo(requestBody)];
|
|
354
356
|
case 1:
|
|
@@ -541,10 +543,8 @@ export var businessSlice = createSlice({
|
|
|
541
543
|
state.error = action.error.message;
|
|
542
544
|
})
|
|
543
545
|
.addCase(updateLeadIdentity.pending, function (state, action) {
|
|
544
|
-
var _a
|
|
545
|
-
if ((_a = action.meta.arg) === null || _a === void 0 ? void 0 : _a.isResend)
|
|
546
|
-
state.customLoading = true;
|
|
547
|
-
if (!((_b = action.meta.arg) === null || _b === void 0 ? void 0 : _b.isResend))
|
|
546
|
+
var _a;
|
|
547
|
+
if (!((_a = action.meta.arg) === null || _a === void 0 ? void 0 : _a.isResend))
|
|
548
548
|
state.loading = true;
|
|
549
549
|
state.error = null;
|
|
550
550
|
})
|
|
@@ -290,7 +290,14 @@ export var updateLeadBrand = createAsyncThunk('updateLeadBrand', function (param
|
|
|
290
290
|
id: (isExistingUser ? (_h = brandData.responseBody) === null || _h === void 0 ? void 0 : _h.lead_id : (_j = otpData.responseBody) === null || _j === void 0 ? void 0 : _j.lead_id) || '',
|
|
291
291
|
terms_conditions_accepted: params.termAndConditionChecked,
|
|
292
292
|
step_name: CONNECT_STEP_NAMES.UPDATE_LEAD_MERCHANT,
|
|
293
|
-
encryption_contract: [
|
|
293
|
+
encryption_contract: [
|
|
294
|
+
'brand.name.en',
|
|
295
|
+
'brand.name.ar',
|
|
296
|
+
'brand.name.zh',
|
|
297
|
+
'brand.website',
|
|
298
|
+
'brand.social[0]',
|
|
299
|
+
'brand.social[1]'
|
|
300
|
+
]
|
|
294
301
|
};
|
|
295
302
|
return [4, API.leadService.updateLead(payload)];
|
|
296
303
|
case 1:
|
|
@@ -12,7 +12,8 @@ export declare const verifyLeadToken: import("@reduxjs/toolkit").AsyncThunk<{
|
|
|
12
12
|
export declare const retrieveDataList: import("@reduxjs/toolkit").AsyncThunk<{
|
|
13
13
|
sourceIncome: any;
|
|
14
14
|
monthlyIncome: any;
|
|
15
|
-
|
|
15
|
+
countryCode: string;
|
|
16
|
+
}, string, {}>;
|
|
16
17
|
export declare const retrieveEntityInfo: import("@reduxjs/toolkit").AsyncThunk<{
|
|
17
18
|
data: any;
|
|
18
19
|
}, string, {}>;
|
|
@@ -48,7 +48,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
48
48
|
var _a;
|
|
49
49
|
import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
|
|
50
50
|
import API from '../../../api';
|
|
51
|
-
import { removeRequestHeaders } from '../../../utils';
|
|
51
|
+
import { hasKey, removeRequestHeaders } from '../../../utils';
|
|
52
52
|
import { handleNextScreenStep } from '../../../app/settings';
|
|
53
53
|
import { defaultCountry, INDIVIDUAl_STEP_NAMES } from '../../../constants';
|
|
54
54
|
export var getCountries = createAsyncThunk('getCountries', function (_, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -68,9 +68,10 @@ export var getCountries = createAsyncThunk('getCountries', function (_, thunkApi
|
|
|
68
68
|
});
|
|
69
69
|
}); });
|
|
70
70
|
export var verifyLeadToken = createAsyncThunk('verifyLeadToken', function (token, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
71
|
-
var payload, data, leadResponse;
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
var payload, data, leadResponse, _a, steps, entity, hasTaxCompleted;
|
|
72
|
+
var _b, _c;
|
|
73
|
+
return __generator(this, function (_d) {
|
|
74
|
+
switch (_d.label) {
|
|
74
75
|
case 0:
|
|
75
76
|
payload = {
|
|
76
77
|
service_name: 'tap_email',
|
|
@@ -78,37 +79,45 @@ export var verifyLeadToken = createAsyncThunk('verifyLeadToken', function (token
|
|
|
78
79
|
};
|
|
79
80
|
return [4, API.leadService.verifyLeadToken(payload)];
|
|
80
81
|
case 1:
|
|
81
|
-
data = (
|
|
82
|
+
data = (_d.sent()).data;
|
|
82
83
|
leadResponse = undefined;
|
|
83
|
-
if (!(!(data === null || data === void 0 ? void 0 : data.errors) && !(data === null || data === void 0 ? void 0 : data.mw_error))) return [3,
|
|
84
|
+
if (!(!(data === null || data === void 0 ? void 0 : data.errors) && !(data === null || data === void 0 ? void 0 : data.mw_error))) return [3, 6];
|
|
84
85
|
return [4, API.leadService.retrieveLead(data === null || data === void 0 ? void 0 : data.id)];
|
|
85
86
|
case 2:
|
|
86
|
-
leadResponse =
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
case 3:
|
|
87
|
+
leadResponse = _d.sent();
|
|
88
|
+
_a = leadResponse.data, steps = _a.steps, entity = _a.entity;
|
|
89
|
+
hasTaxCompleted = hasKey(steps, INDIVIDUAl_STEP_NAMES.INDIVIDUAl_SUCCESS);
|
|
90
|
+
if (!hasTaxCompleted) return [3, 4];
|
|
91
|
+
return [4, thunkApi.dispatch(retrieveEntityInfo(entity === null || entity === void 0 ? void 0 : entity.id))];
|
|
92
|
+
case 3:
|
|
93
|
+
_d.sent();
|
|
94
|
+
thunkApi.dispatch(handleNextScreenStep('INDIVIDUAL_SUCCESS_FOUR_FLOWS_BUTTONS_STEP'));
|
|
95
|
+
return [3, 6];
|
|
96
|
+
case 4:
|
|
97
|
+
if (!(data.step_name === INDIVIDUAl_STEP_NAMES.INDIVIDUAl_INFO)) return [3, 6];
|
|
98
|
+
return [4, thunkApi.dispatch(retrieveDataList((_c = (_b = leadResponse.data) === null || _b === void 0 ? void 0 : _b.entity) === null || _c === void 0 ? void 0 : _c.country))];
|
|
99
|
+
case 5:
|
|
100
|
+
_d.sent();
|
|
101
|
+
thunkApi.dispatch(handleNextScreenStep('INDIVIDUAL_ADDITIONAL_INDIVIDUAL_INFO_STEP'));
|
|
102
|
+
_d.label = 6;
|
|
103
|
+
case 6: return [2, { data: data, leadData: leadResponse === null || leadResponse === void 0 ? void 0 : leadResponse.data, token: token }];
|
|
92
104
|
}
|
|
93
105
|
});
|
|
94
106
|
}); });
|
|
95
|
-
export var retrieveDataList = createAsyncThunk('retrieveDataList', function (
|
|
96
|
-
var
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
return [4, Promise.all([
|
|
104
|
-
API.dataService.getSourceOfIncome(),
|
|
105
|
-
API.dataService.getMonthlyIncome(code)
|
|
106
|
-
])];
|
|
107
|
+
export var retrieveDataList = createAsyncThunk('retrieveDataList', function (countryCode, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
108
|
+
var _a, sourceIncome, monthlyIncome;
|
|
109
|
+
return __generator(this, function (_b) {
|
|
110
|
+
switch (_b.label) {
|
|
111
|
+
case 0: return [4, Promise.all([
|
|
112
|
+
API.dataService.getSourceOfIncome(),
|
|
113
|
+
API.dataService.getMonthlyIncome(countryCode)
|
|
114
|
+
])];
|
|
107
115
|
case 1:
|
|
108
|
-
_a =
|
|
116
|
+
_a = _b.sent(), sourceIncome = _a[0].data, monthlyIncome = _a[1].data;
|
|
109
117
|
return [2, {
|
|
110
118
|
sourceIncome: sourceIncome,
|
|
111
|
-
monthlyIncome: monthlyIncome
|
|
119
|
+
monthlyIncome: monthlyIncome,
|
|
120
|
+
countryCode: countryCode
|
|
112
121
|
}];
|
|
113
122
|
}
|
|
114
123
|
});
|
|
@@ -126,9 +135,9 @@ export var retrieveEntityInfo = createAsyncThunk('retrieveIndividualEntityInfo',
|
|
|
126
135
|
}); });
|
|
127
136
|
export var verifyLeadOTP = createAsyncThunk('verifyIndividualLeadOTP', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
128
137
|
var _a, individual, settings, responseBody, payload, data, steps, hasIndividualCompleted;
|
|
129
|
-
var _b, _c, _d, _e;
|
|
130
|
-
return __generator(this, function (
|
|
131
|
-
switch (
|
|
138
|
+
var _b, _c, _d, _e, _f;
|
|
139
|
+
return __generator(this, function (_g) {
|
|
140
|
+
switch (_g.label) {
|
|
132
141
|
case 0:
|
|
133
142
|
_a = thunkApi.getState(), individual = _a.individual, settings = _a.settings;
|
|
134
143
|
responseBody = individual.data.verify.responseBody;
|
|
@@ -141,22 +150,22 @@ export var verifyLeadOTP = createAsyncThunk('verifyIndividualLeadOTP', function
|
|
|
141
150
|
};
|
|
142
151
|
return [4, API.leadService.verifyLeadOTP(payload)];
|
|
143
152
|
case 1:
|
|
144
|
-
data = (
|
|
153
|
+
data = (_g.sent()).data;
|
|
145
154
|
if (!!data.errors) return [3, 5];
|
|
146
155
|
(_d = (_c = settings.data.appConfig).onStepCompleted) === null || _d === void 0 ? void 0 : _d.call(_c, settings.data.activeScreen.name, { otp: params.otp });
|
|
147
156
|
steps = responseBody === null || responseBody === void 0 ? void 0 : responseBody.steps;
|
|
148
|
-
hasIndividualCompleted =
|
|
157
|
+
hasIndividualCompleted = hasKey(steps, INDIVIDUAl_STEP_NAMES.INDIVIDUAl_SUCCESS);
|
|
149
158
|
if (!hasIndividualCompleted) return [3, 3];
|
|
150
159
|
return [4, thunkApi.dispatch(retrieveEntityInfo((_e = responseBody === null || responseBody === void 0 ? void 0 : responseBody.entity) === null || _e === void 0 ? void 0 : _e.id))];
|
|
151
160
|
case 2:
|
|
152
|
-
|
|
161
|
+
_g.sent();
|
|
153
162
|
thunkApi.dispatch(handleNextScreenStep('INDIVIDUAL_SUCCESS_FOUR_FLOWS_BUTTONS_STEP'));
|
|
154
163
|
return [3, 5];
|
|
155
|
-
case 3: return [4, thunkApi.dispatch(retrieveDataList())];
|
|
164
|
+
case 3: return [4, thunkApi.dispatch(retrieveDataList((_f = responseBody === null || responseBody === void 0 ? void 0 : responseBody.entity) === null || _f === void 0 ? void 0 : _f.country))];
|
|
156
165
|
case 4:
|
|
157
|
-
|
|
166
|
+
_g.sent();
|
|
158
167
|
thunkApi.dispatch(handleNextScreenStep('INDIVIDUAL_ADDITIONAL_INDIVIDUAL_INFO_STEP'));
|
|
159
|
-
|
|
168
|
+
_g.label = 5;
|
|
160
169
|
case 5: return [2, { data: data, formData: __assign({}, params) }];
|
|
161
170
|
}
|
|
162
171
|
});
|
|
@@ -176,7 +185,7 @@ export var updateIndividualInfo = createAsyncThunk('updateIndividualInfo', funct
|
|
|
176
185
|
actual_income: (_f = params.monthlyIncome) === null || _f === void 0 ? void 0 : _f.id,
|
|
177
186
|
is_relative_PEP: params.isPEP,
|
|
178
187
|
is_influencer: params.isInfluencer,
|
|
179
|
-
encryption_contract: ['employer_name', 'employer_city', 'actual_income'],
|
|
188
|
+
encryption_contract: ['employer_name', 'employer_city', 'actual_income', 'source_income[0]'],
|
|
180
189
|
step_name: INDIVIDUAl_STEP_NAMES.INDIVIDUAl_INFO
|
|
181
190
|
};
|
|
182
191
|
return [4, API.entityService.updateEntityInfo(requestBody)];
|
|
@@ -287,7 +296,7 @@ export var individualSlice = createSlice({
|
|
|
287
296
|
state.error = description;
|
|
288
297
|
return;
|
|
289
298
|
}
|
|
290
|
-
state.data.verify.responseBody = __assign(__assign({}, data), leadData);
|
|
299
|
+
state.data.verify.responseBody = __assign(__assign(__assign({}, data), leadData), state.data.verify.responseBody);
|
|
291
300
|
state.data.verify.token = token;
|
|
292
301
|
})
|
|
293
302
|
.addCase(verifyLeadToken.rejected, function (state, action) {
|
|
@@ -320,10 +329,9 @@ export var individualSlice = createSlice({
|
|
|
320
329
|
state.error = null;
|
|
321
330
|
})
|
|
322
331
|
.addCase(retrieveDataList.fulfilled, function (state, action) {
|
|
323
|
-
var _a, _b;
|
|
324
332
|
state.loading = false;
|
|
325
333
|
state.error = null;
|
|
326
|
-
var
|
|
334
|
+
var _a = action.payload, sourceIncome = _a.sourceIncome, monthlyIncome = _a.monthlyIncome, countryCode = _a.countryCode;
|
|
327
335
|
var data = state.data.individualData.responseBody;
|
|
328
336
|
state.data.individualData.responseBody = __assign(__assign({}, data), { sourceIncomeList: sourceIncome || [], monthlyIncomeList: monthlyIncome || [] });
|
|
329
337
|
var selectedSourceIncome = sourceIncome === null || sourceIncome === void 0 ? void 0 : sourceIncome[0];
|
|
@@ -332,9 +340,9 @@ export var individualSlice = createSlice({
|
|
|
332
340
|
var selectedMonthlyIncome = monthlyIncome === null || monthlyIncome === void 0 ? void 0 : monthlyIncome[2];
|
|
333
341
|
if (!!selectedMonthlyIncome)
|
|
334
342
|
state.data.individualData.monthlyIncome = selectedMonthlyIncome;
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
state.data.individualData.employerLocation =
|
|
343
|
+
if (!!countryCode) {
|
|
344
|
+
var employerLocation = state.data.countries.find(function (country) { return country.iso2 === countryCode; });
|
|
345
|
+
state.data.individualData.employerLocation = employerLocation;
|
|
338
346
|
}
|
|
339
347
|
})
|
|
340
348
|
.addCase(retrieveDataList.rejected, function (state, action) {
|
|
@@ -392,7 +400,8 @@ export var individualSlice = createSlice({
|
|
|
392
400
|
state.error = description;
|
|
393
401
|
return;
|
|
394
402
|
}
|
|
395
|
-
|
|
403
|
+
var flows = response.flows, steps = response.steps;
|
|
404
|
+
state.data.verify.responseBody = __assign(__assign({}, state.data.verify.responseBody), { flows: flows, steps: steps });
|
|
396
405
|
removeRequestHeaders();
|
|
397
406
|
})
|
|
398
407
|
.addCase(updateLeadSuccess.pending, function (state) {
|
|
@@ -48,13 +48,13 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
48
48
|
var _a;
|
|
49
49
|
import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
|
|
50
50
|
import API from '../../../api';
|
|
51
|
-
import { removeRequestHeaders } from '../../../utils';
|
|
51
|
+
import { hasKey, removeRequestHeaders } from '../../../utils';
|
|
52
52
|
import { handleNextScreenStep } from '../../../app/settings';
|
|
53
53
|
import { PASSWORD_STEP_NAMES } from '../../../constants';
|
|
54
54
|
export var verifyLeadToken = createAsyncThunk('verifyLeadToken', function (token, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
55
|
-
var payload, data, leadResponse;
|
|
56
|
-
return __generator(this, function (
|
|
57
|
-
switch (
|
|
55
|
+
var payload, data, leadResponse, _a, steps, entity, hasCompleted;
|
|
56
|
+
return __generator(this, function (_b) {
|
|
57
|
+
switch (_b.label) {
|
|
58
58
|
case 0:
|
|
59
59
|
payload = {
|
|
60
60
|
service_name: 'tap_email',
|
|
@@ -62,17 +62,26 @@ export var verifyLeadToken = createAsyncThunk('verifyLeadToken', function (token
|
|
|
62
62
|
};
|
|
63
63
|
return [4, API.leadService.verifyLeadToken(payload)];
|
|
64
64
|
case 1:
|
|
65
|
-
data = (
|
|
65
|
+
data = (_b.sent()).data;
|
|
66
66
|
leadResponse = undefined;
|
|
67
|
-
if (!(!(data === null || data === void 0 ? void 0 : data.errors) && !(data === null || data === void 0 ? void 0 : data.mw_error))) return [3,
|
|
67
|
+
if (!(!(data === null || data === void 0 ? void 0 : data.errors) && !(data === null || data === void 0 ? void 0 : data.mw_error))) return [3, 5];
|
|
68
68
|
return [4, API.leadService.retrieveLead(data === null || data === void 0 ? void 0 : data.id)];
|
|
69
69
|
case 2:
|
|
70
|
-
leadResponse =
|
|
71
|
-
|
|
72
|
-
|
|
70
|
+
leadResponse = _b.sent();
|
|
71
|
+
_a = leadResponse.data, steps = _a.steps, entity = _a.entity;
|
|
72
|
+
hasCompleted = hasKey(steps, PASSWORD_STEP_NAMES.PASSWORD_SUCCESS);
|
|
73
|
+
if (!hasCompleted) return [3, 4];
|
|
74
|
+
return [4, thunkApi.dispatch(retrieveEntityInfo(entity === null || entity === void 0 ? void 0 : entity.id))];
|
|
75
|
+
case 3:
|
|
76
|
+
_b.sent();
|
|
77
|
+
thunkApi.dispatch(handleNextScreenStep('PASSWORD_SUCCESS_FOUR_FLOWS_BUTTONS_STEP'));
|
|
78
|
+
return [3, 5];
|
|
79
|
+
case 4:
|
|
80
|
+
if (data.step_name === PASSWORD_STEP_NAMES.PASSWORD_INFO) {
|
|
81
|
+
thunkApi.dispatch(handleNextScreenStep('PASSWORD_CREATE_PASSWORD_STEP'));
|
|
73
82
|
}
|
|
74
|
-
|
|
75
|
-
case
|
|
83
|
+
_b.label = 5;
|
|
84
|
+
case 5: return [2, { data: data, leadData: leadResponse === null || leadResponse === void 0 ? void 0 : leadResponse.data, token: token }];
|
|
76
85
|
}
|
|
77
86
|
});
|
|
78
87
|
}); });
|
|
@@ -88,7 +97,7 @@ export var retrieveEntityInfo = createAsyncThunk('retrievePasswordEntityInfo', f
|
|
|
88
97
|
});
|
|
89
98
|
}); });
|
|
90
99
|
export var verifyPasswordLeadOTP = createAsyncThunk('verifyPasswordLeadOTP', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
91
|
-
var _a, password, settings, responseBody, payload, data, steps,
|
|
100
|
+
var _a, password, settings, responseBody, payload, data, steps, hasCompleted;
|
|
92
101
|
var _b, _c, _d, _e;
|
|
93
102
|
return __generator(this, function (_f) {
|
|
94
103
|
switch (_f.label) {
|
|
@@ -108,8 +117,8 @@ export var verifyPasswordLeadOTP = createAsyncThunk('verifyPasswordLeadOTP', fun
|
|
|
108
117
|
if (!!data.errors) return [3, 4];
|
|
109
118
|
(_d = (_c = settings.data.appConfig).onStepCompleted) === null || _d === void 0 ? void 0 : _d.call(_c, settings.data.activeScreen.name, { otp: params.otp });
|
|
110
119
|
steps = responseBody === null || responseBody === void 0 ? void 0 : responseBody.steps;
|
|
111
|
-
|
|
112
|
-
if (!
|
|
120
|
+
hasCompleted = hasKey(steps, PASSWORD_STEP_NAMES.PASSWORD_SUCCESS);
|
|
121
|
+
if (!hasCompleted) return [3, 3];
|
|
113
122
|
return [4, thunkApi.dispatch(retrieveEntityInfo((_e = responseBody === null || responseBody === void 0 ? void 0 : responseBody.entity) === null || _e === void 0 ? void 0 : _e.id))];
|
|
114
123
|
case 2:
|
|
115
124
|
_f.sent();
|
|
@@ -124,23 +133,23 @@ export var verifyPasswordLeadOTP = createAsyncThunk('verifyPasswordLeadOTP', fun
|
|
|
124
133
|
}); });
|
|
125
134
|
export var createPassword = createAsyncThunk('createPassword', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
126
135
|
var _a, settings, password, requestBody, data;
|
|
127
|
-
var _b, _c, _d;
|
|
128
|
-
return __generator(this, function (
|
|
129
|
-
switch (
|
|
136
|
+
var _b, _c, _d, _e;
|
|
137
|
+
return __generator(this, function (_f) {
|
|
138
|
+
switch (_f.label) {
|
|
130
139
|
case 0:
|
|
131
140
|
_a = thunkApi.getState(), settings = _a.settings, password = _a.password;
|
|
132
141
|
requestBody = {
|
|
133
142
|
step_name: PASSWORD_STEP_NAMES.PASSWORD_CREATE,
|
|
134
|
-
signup_token: (_b = password.data.
|
|
143
|
+
signup_token: ((_b = password.data.verify.responseBody) === null || _b === void 0 ? void 0 : _b.signup_token) || ((_c = password.data.otpData.responseBody) === null || _c === void 0 ? void 0 : _c.signup_token),
|
|
135
144
|
password: params.password,
|
|
136
145
|
encryption_contract: ['password']
|
|
137
146
|
};
|
|
138
147
|
return [4, API.authService.createPassword(requestBody)];
|
|
139
148
|
case 1:
|
|
140
|
-
data = (
|
|
149
|
+
data = (_f.sent()).data;
|
|
141
150
|
if (!data.errors) {
|
|
142
151
|
thunkApi.dispatch(handleNextScreenStep());
|
|
143
|
-
(
|
|
152
|
+
(_e = (_d = settings.data.appConfig).onStepCompleted) === null || _e === void 0 ? void 0 : _e.call(_d, settings.data.activeScreen.name, requestBody);
|
|
144
153
|
}
|
|
145
154
|
return [2, { data: data, formData: params }];
|
|
146
155
|
}
|
|
@@ -216,7 +225,7 @@ export var passwordSlice = createSlice({
|
|
|
216
225
|
state.error = description;
|
|
217
226
|
return;
|
|
218
227
|
}
|
|
219
|
-
state.data.verify.responseBody = __assign(__assign({}, data), leadData);
|
|
228
|
+
state.data.verify.responseBody = __assign(__assign(__assign({}, data), leadData), state.data.verify.responseBody);
|
|
220
229
|
state.data.verify.token = token;
|
|
221
230
|
})
|
|
222
231
|
.addCase(verifyLeadToken.pending, function (state, action) {
|
|
@@ -299,7 +308,8 @@ export var passwordSlice = createSlice({
|
|
|
299
308
|
state.error = description;
|
|
300
309
|
return;
|
|
301
310
|
}
|
|
302
|
-
|
|
311
|
+
var flows = response.flows, steps = response.steps;
|
|
312
|
+
state.data.verify.responseBody = __assign(__assign({}, state.data.verify.responseBody), { flows: flows, steps: steps });
|
|
303
313
|
removeRequestHeaders();
|
|
304
314
|
})
|
|
305
315
|
.addCase(updateLeadSuccess.pending, function (state) {
|
|
@@ -48,13 +48,13 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
48
48
|
var _a;
|
|
49
49
|
import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
|
|
50
50
|
import API from '../../../api';
|
|
51
|
-
import { removeRequestHeaders } from '../../../utils';
|
|
51
|
+
import { hasKey, removeRequestHeaders } from '../../../utils';
|
|
52
52
|
import { handleNextScreenStep } from '../../../app/settings';
|
|
53
53
|
import { TAX_STEP_NAMES } from '../../../constants';
|
|
54
54
|
export var verifyLeadToken = createAsyncThunk('verifyLeadToken', function (token, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
55
|
-
var payload, data, leadResponse;
|
|
56
|
-
return __generator(this, function (
|
|
57
|
-
switch (
|
|
55
|
+
var payload, data, leadResponse, _a, steps, entity, hasTaxCompleted;
|
|
56
|
+
return __generator(this, function (_b) {
|
|
57
|
+
switch (_b.label) {
|
|
58
58
|
case 0:
|
|
59
59
|
payload = {
|
|
60
60
|
service_name: 'tap_email',
|
|
@@ -62,17 +62,26 @@ export var verifyLeadToken = createAsyncThunk('verifyLeadToken', function (token
|
|
|
62
62
|
};
|
|
63
63
|
return [4, API.leadService.verifyLeadToken(payload)];
|
|
64
64
|
case 1:
|
|
65
|
-
data = (
|
|
65
|
+
data = (_b.sent()).data;
|
|
66
66
|
leadResponse = undefined;
|
|
67
|
-
if (!(!(data === null || data === void 0 ? void 0 : data.errors) && !(data === null || data === void 0 ? void 0 : data.mw_error))) return [3,
|
|
67
|
+
if (!(!(data === null || data === void 0 ? void 0 : data.errors) && !(data === null || data === void 0 ? void 0 : data.mw_error))) return [3, 5];
|
|
68
68
|
return [4, API.leadService.retrieveLead(data === null || data === void 0 ? void 0 : data.id)];
|
|
69
69
|
case 2:
|
|
70
|
-
leadResponse =
|
|
71
|
-
|
|
72
|
-
|
|
70
|
+
leadResponse = _b.sent();
|
|
71
|
+
_a = leadResponse.data, steps = _a.steps, entity = _a.entity;
|
|
72
|
+
hasTaxCompleted = hasKey(steps, TAX_STEP_NAMES.TAX_SUCCESS);
|
|
73
|
+
if (!hasTaxCompleted) return [3, 4];
|
|
74
|
+
return [4, thunkApi.dispatch(retrieveEntityInfo(entity === null || entity === void 0 ? void 0 : entity.id))];
|
|
75
|
+
case 3:
|
|
76
|
+
_b.sent();
|
|
77
|
+
thunkApi.dispatch(handleNextScreenStep('TAX_SUCCESS_FOUR_FLOWS_BUTTONS_STEP'));
|
|
78
|
+
return [3, 5];
|
|
79
|
+
case 4:
|
|
80
|
+
if (data.step_name === TAX_STEP_NAMES.TAX_INFO) {
|
|
81
|
+
thunkApi.dispatch(handleNextScreenStep('TAX_TAX_DETAILS_STEP'));
|
|
73
82
|
}
|
|
74
|
-
|
|
75
|
-
case
|
|
83
|
+
_b.label = 5;
|
|
84
|
+
case 5: return [2, { data: data, leadData: leadResponse === null || leadResponse === void 0 ? void 0 : leadResponse.data, token: token }];
|
|
76
85
|
}
|
|
77
86
|
});
|
|
78
87
|
}); });
|
|
@@ -108,7 +117,7 @@ export var verifyTaxLeadOTP = createAsyncThunk('verifyTaxLeadOTP', function (par
|
|
|
108
117
|
if (!!data.errors) return [3, 4];
|
|
109
118
|
(_d = (_c = settings.data.appConfig).onStepCompleted) === null || _d === void 0 ? void 0 : _d.call(_c, settings.data.activeScreen.name, { otp: params.otp });
|
|
110
119
|
steps = responseBody === null || responseBody === void 0 ? void 0 : responseBody.steps;
|
|
111
|
-
hasTaxCompleted =
|
|
120
|
+
hasTaxCompleted = hasKey(steps, TAX_STEP_NAMES.TAX_SUCCESS);
|
|
112
121
|
if (!hasTaxCompleted) return [3, 3];
|
|
113
122
|
return [4, thunkApi.dispatch(retrieveEntityInfo((_e = responseBody === null || responseBody === void 0 ? void 0 : responseBody.entity) === null || _e === void 0 ? void 0 : _e.id))];
|
|
114
123
|
case 2:
|
|
@@ -214,7 +223,7 @@ export var taxSlice = createSlice({
|
|
|
214
223
|
state.error = description;
|
|
215
224
|
return;
|
|
216
225
|
}
|
|
217
|
-
state.data.verify.responseBody = __assign(__assign({}, data), leadData);
|
|
226
|
+
state.data.verify.responseBody = __assign(__assign(__assign({}, data), leadData), state.data.verify.responseBody);
|
|
218
227
|
state.data.verify.token = token;
|
|
219
228
|
})
|
|
220
229
|
.addCase(verifyLeadToken.pending, function (state, action) {
|
|
@@ -297,7 +306,8 @@ export var taxSlice = createSlice({
|
|
|
297
306
|
state.error = description;
|
|
298
307
|
return;
|
|
299
308
|
}
|
|
300
|
-
|
|
309
|
+
var flows = response.flows, steps = response.steps;
|
|
310
|
+
state.data.verify.responseBody = __assign(__assign({}, state.data.verify.responseBody), { flows: flows, steps: steps });
|
|
301
311
|
removeRequestHeaders();
|
|
302
312
|
})
|
|
303
313
|
.addCase(updateLeadSuccess.pending, function (state) {
|
package/build/utils/object.d.ts
CHANGED
package/build/utils/object.js
CHANGED
|
@@ -16,3 +16,8 @@ export var decodeObjectBase64 = function (str) {
|
|
|
16
16
|
throw new Error('Invalid base64 string or invalid json format. try to check [decodeObjectBase64]');
|
|
17
17
|
}
|
|
18
18
|
};
|
|
19
|
+
export var hasKey = function (obj, key) {
|
|
20
|
+
if (!obj)
|
|
21
|
+
return false;
|
|
22
|
+
return Object.keys(obj).includes(key);
|
|
23
|
+
};
|
package/package.json
CHANGED
|
@@ -1,126 +1,126 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@tap-payments/auth-jsconnect",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "connect library, auth",
|
|
5
|
-
"private": false,
|
|
6
|
-
"main": "build/index.js",
|
|
7
|
-
"module": "build/index.js",
|
|
8
|
-
"types": "build/index.d.ts",
|
|
9
|
-
"files": [
|
|
10
|
-
"build",
|
|
11
|
-
"README.md"
|
|
12
|
-
],
|
|
13
|
-
"scripts": {
|
|
14
|
-
"husky:setup": "npx husky install",
|
|
15
|
-
"prettier": "prettier --list-different \"src/**/*.{md,mdx,ts,js,tsx,jsx,json}\" *.json *.js",
|
|
16
|
-
"prettier:fix": "prettier --write \"src/**/*.{ts,tsx,js,jsx,json,md,css,json}\" *.json *.js",
|
|
17
|
-
"lint": "eslint src --color --ext .js,.jsx,.ts,.tsx,.json",
|
|
18
|
-
"lint:fix": "eslint src --ext .js,.jsx,.ts,.tsx --fix",
|
|
19
|
-
"start": "cross-env NODE_ENV=development webpack serve",
|
|
20
|
-
"build": "cross-env NODE_ENV=production webpack",
|
|
21
|
-
"copy:files": "copyfiles -u 1 src/**/*.css build/",
|
|
22
|
-
"tsc:alias": "tsc-alias -p tsconfig.json",
|
|
23
|
-
"ts:build": "tsc -p tsconfig.json && tsc-alias -p tsconfig.json && yarn copy:files",
|
|
24
|
-
"push": "npm publish --access public"
|
|
25
|
-
},
|
|
26
|
-
"keywords": [],
|
|
27
|
-
"author": {
|
|
28
|
-
"name": "Ahmed Elsharkawy",
|
|
29
|
-
"email": "a.elsharkawy@tap.company"
|
|
30
|
-
},
|
|
31
|
-
"license": "ISC",
|
|
32
|
-
"devDependencies": {
|
|
33
|
-
"@babel/core": "^7.18.6",
|
|
34
|
-
"@babel/preset-env": "^7.18.6",
|
|
35
|
-
"@babel/preset-react": "^7.18.6",
|
|
36
|
-
"@babel/preset-typescript": "^7.18.6",
|
|
37
|
-
"@types/lodash-es": "^4.17.6",
|
|
38
|
-
"@types/moment-hijri": "^2.1.0",
|
|
39
|
-
"@types/react": "^18.0.15",
|
|
40
|
-
"@types/react-calendar": "~3.5.1",
|
|
41
|
-
"@types/react-dom": "^18.0.6",
|
|
42
|
-
"@typescript-eslint/eslint-plugin": "^5.30.5",
|
|
43
|
-
"@typescript-eslint/parser": "^5.30.5",
|
|
44
|
-
"babel-loader": "^8.2.5",
|
|
45
|
-
"copyfiles": "^2.4.1",
|
|
46
|
-
"cross-env": "^7.0.3",
|
|
47
|
-
"css-loader": "^6.7.1",
|
|
48
|
-
"css-minimizer-webpack-plugin": "^4.0.0",
|
|
49
|
-
"eslint": "^8.19.0",
|
|
50
|
-
"eslint-config-airbnb": "^19.0.4",
|
|
51
|
-
"eslint-config-prettier": "^8.5.0",
|
|
52
|
-
"eslint-plugin-import": "^2.26.0",
|
|
53
|
-
"eslint-plugin-jsx-a11y": "^6.6.0",
|
|
54
|
-
"eslint-plugin-node": "^11.1.0",
|
|
55
|
-
"eslint-plugin-prettier": "^4.2.1",
|
|
56
|
-
"eslint-plugin-react": "^7.30.1",
|
|
57
|
-
"eslint-plugin-react-hooks": "^4.6.0",
|
|
58
|
-
"file-loader": "^6.2.0",
|
|
59
|
-
"fork-ts-checker-webpack-plugin": "^7.2.12",
|
|
60
|
-
"html-loader": "^3.1.2",
|
|
61
|
-
"html-webpack-plugin": "^5.5.0",
|
|
62
|
-
"husky": "^8.0.1",
|
|
63
|
-
"lint-staged": "^13.0.3",
|
|
64
|
-
"mini-css-extract-plugin": "^2.6.1",
|
|
65
|
-
"prettier": "^2.7.1",
|
|
66
|
-
"sass": "^1.53.0",
|
|
67
|
-
"sass-loader": "^13.0.2",
|
|
68
|
-
"style-loader": "^3.3.1",
|
|
69
|
-
"terser-webpack-plugin": "^5.3.3",
|
|
70
|
-
"tsc-alias": "^1.6.11",
|
|
71
|
-
"typescript": "^4.7.4",
|
|
72
|
-
"webpack": "^5.73.0",
|
|
73
|
-
"webpack-cli": "^4.10.0",
|
|
74
|
-
"webpack-dev-server": "^4.9.3",
|
|
75
|
-
"webpack-merge": "^5.8.0"
|
|
76
|
-
},
|
|
77
|
-
"dependencies": {
|
|
78
|
-
"@emotion/react": "^11.9.3",
|
|
79
|
-
"@emotion/styled": "^11.9.3",
|
|
80
|
-
"@fingerprintjs/fingerprintjs": "~3.3.4",
|
|
81
|
-
"@hookform/resolvers": "^2.9.6",
|
|
82
|
-
"@mui/icons-material": "^5.8.4",
|
|
83
|
-
"@mui/material": "^5.8.7",
|
|
84
|
-
"@reduxjs/toolkit": "^1.8.3",
|
|
85
|
-
"axios": "^0.27.2",
|
|
86
|
-
"device-detector-js": "^3.0.3",
|
|
87
|
-
"i18next": "^21.8.14",
|
|
88
|
-
"i18next-browser-languagedetector": "^6.1.4",
|
|
89
|
-
"i18next-http-backend": "^1.4.1",
|
|
90
|
-
"jsencrypt": "^3.2.1",
|
|
91
|
-
"lodash-es": "^4.17.21",
|
|
92
|
-
"moment-hijri": "~2.1.2",
|
|
93
|
-
"react": "^18.2.0",
|
|
94
|
-
"react-calendar": "~3.7.0",
|
|
95
|
-
"react-dom": "^18.2.0",
|
|
96
|
-
"react-hook-form": "^7.33.1",
|
|
97
|
-
"react-i18next": "^11.18.1",
|
|
98
|
-
"react-otp-input": "^2.4.0",
|
|
99
|
-
"react-redux": "^8.0.2",
|
|
100
|
-
"react-spring-bottom-sheet": "^3.4.1",
|
|
101
|
-
"yup": "^0.32.11"
|
|
102
|
-
},
|
|
103
|
-
"peerDependencies": {
|
|
104
|
-
"react": "^18.2.0",
|
|
105
|
-
"react-dom": "^18.2.0"
|
|
106
|
-
},
|
|
107
|
-
"lint-staged": {
|
|
108
|
-
"src/**/*.{ts,tsx,json,js,jsx}": [
|
|
109
|
-
"yarn run prettier:fix",
|
|
110
|
-
"yarn run lint",
|
|
111
|
-
"git add ."
|
|
112
|
-
]
|
|
113
|
-
},
|
|
114
|
-
"browserslist": {
|
|
115
|
-
"production": [
|
|
116
|
-
">0.2%",
|
|
117
|
-
"not dead",
|
|
118
|
-
"not op_mini all"
|
|
119
|
-
],
|
|
120
|
-
"development": [
|
|
121
|
-
"last 1 chrome version",
|
|
122
|
-
"last 1 firefox version",
|
|
123
|
-
"last 1 safari version"
|
|
124
|
-
]
|
|
125
|
-
}
|
|
126
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@tap-payments/auth-jsconnect",
|
|
3
|
+
"version": "1.0.89",
|
|
4
|
+
"description": "connect library, auth",
|
|
5
|
+
"private": false,
|
|
6
|
+
"main": "build/index.js",
|
|
7
|
+
"module": "build/index.js",
|
|
8
|
+
"types": "build/index.d.ts",
|
|
9
|
+
"files": [
|
|
10
|
+
"build",
|
|
11
|
+
"README.md"
|
|
12
|
+
],
|
|
13
|
+
"scripts": {
|
|
14
|
+
"husky:setup": "npx husky install",
|
|
15
|
+
"prettier": "prettier --list-different \"src/**/*.{md,mdx,ts,js,tsx,jsx,json}\" *.json *.js",
|
|
16
|
+
"prettier:fix": "prettier --write \"src/**/*.{ts,tsx,js,jsx,json,md,css,json}\" *.json *.js",
|
|
17
|
+
"lint": "eslint src --color --ext .js,.jsx,.ts,.tsx,.json",
|
|
18
|
+
"lint:fix": "eslint src --ext .js,.jsx,.ts,.tsx --fix",
|
|
19
|
+
"start": "cross-env NODE_ENV=development webpack serve",
|
|
20
|
+
"build": "cross-env NODE_ENV=production webpack",
|
|
21
|
+
"copy:files": "copyfiles -u 1 src/**/*.css build/",
|
|
22
|
+
"tsc:alias": "tsc-alias -p tsconfig.json",
|
|
23
|
+
"ts:build": "tsc -p tsconfig.json && tsc-alias -p tsconfig.json && yarn copy:files",
|
|
24
|
+
"push": "npm publish --access public"
|
|
25
|
+
},
|
|
26
|
+
"keywords": [],
|
|
27
|
+
"author": {
|
|
28
|
+
"name": "Ahmed Elsharkawy",
|
|
29
|
+
"email": "a.elsharkawy@tap.company"
|
|
30
|
+
},
|
|
31
|
+
"license": "ISC",
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@babel/core": "^7.18.6",
|
|
34
|
+
"@babel/preset-env": "^7.18.6",
|
|
35
|
+
"@babel/preset-react": "^7.18.6",
|
|
36
|
+
"@babel/preset-typescript": "^7.18.6",
|
|
37
|
+
"@types/lodash-es": "^4.17.6",
|
|
38
|
+
"@types/moment-hijri": "^2.1.0",
|
|
39
|
+
"@types/react": "^18.0.15",
|
|
40
|
+
"@types/react-calendar": "~3.5.1",
|
|
41
|
+
"@types/react-dom": "^18.0.6",
|
|
42
|
+
"@typescript-eslint/eslint-plugin": "^5.30.5",
|
|
43
|
+
"@typescript-eslint/parser": "^5.30.5",
|
|
44
|
+
"babel-loader": "^8.2.5",
|
|
45
|
+
"copyfiles": "^2.4.1",
|
|
46
|
+
"cross-env": "^7.0.3",
|
|
47
|
+
"css-loader": "^6.7.1",
|
|
48
|
+
"css-minimizer-webpack-plugin": "^4.0.0",
|
|
49
|
+
"eslint": "^8.19.0",
|
|
50
|
+
"eslint-config-airbnb": "^19.0.4",
|
|
51
|
+
"eslint-config-prettier": "^8.5.0",
|
|
52
|
+
"eslint-plugin-import": "^2.26.0",
|
|
53
|
+
"eslint-plugin-jsx-a11y": "^6.6.0",
|
|
54
|
+
"eslint-plugin-node": "^11.1.0",
|
|
55
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
56
|
+
"eslint-plugin-react": "^7.30.1",
|
|
57
|
+
"eslint-plugin-react-hooks": "^4.6.0",
|
|
58
|
+
"file-loader": "^6.2.0",
|
|
59
|
+
"fork-ts-checker-webpack-plugin": "^7.2.12",
|
|
60
|
+
"html-loader": "^3.1.2",
|
|
61
|
+
"html-webpack-plugin": "^5.5.0",
|
|
62
|
+
"husky": "^8.0.1",
|
|
63
|
+
"lint-staged": "^13.0.3",
|
|
64
|
+
"mini-css-extract-plugin": "^2.6.1",
|
|
65
|
+
"prettier": "^2.7.1",
|
|
66
|
+
"sass": "^1.53.0",
|
|
67
|
+
"sass-loader": "^13.0.2",
|
|
68
|
+
"style-loader": "^3.3.1",
|
|
69
|
+
"terser-webpack-plugin": "^5.3.3",
|
|
70
|
+
"tsc-alias": "^1.6.11",
|
|
71
|
+
"typescript": "^4.7.4",
|
|
72
|
+
"webpack": "^5.73.0",
|
|
73
|
+
"webpack-cli": "^4.10.0",
|
|
74
|
+
"webpack-dev-server": "^4.9.3",
|
|
75
|
+
"webpack-merge": "^5.8.0"
|
|
76
|
+
},
|
|
77
|
+
"dependencies": {
|
|
78
|
+
"@emotion/react": "^11.9.3",
|
|
79
|
+
"@emotion/styled": "^11.9.3",
|
|
80
|
+
"@fingerprintjs/fingerprintjs": "~3.3.4",
|
|
81
|
+
"@hookform/resolvers": "^2.9.6",
|
|
82
|
+
"@mui/icons-material": "^5.8.4",
|
|
83
|
+
"@mui/material": "^5.8.7",
|
|
84
|
+
"@reduxjs/toolkit": "^1.8.3",
|
|
85
|
+
"axios": "^0.27.2",
|
|
86
|
+
"device-detector-js": "^3.0.3",
|
|
87
|
+
"i18next": "^21.8.14",
|
|
88
|
+
"i18next-browser-languagedetector": "^6.1.4",
|
|
89
|
+
"i18next-http-backend": "^1.4.1",
|
|
90
|
+
"jsencrypt": "^3.2.1",
|
|
91
|
+
"lodash-es": "^4.17.21",
|
|
92
|
+
"moment-hijri": "~2.1.2",
|
|
93
|
+
"react": "^18.2.0",
|
|
94
|
+
"react-calendar": "~3.7.0",
|
|
95
|
+
"react-dom": "^18.2.0",
|
|
96
|
+
"react-hook-form": "^7.33.1",
|
|
97
|
+
"react-i18next": "^11.18.1",
|
|
98
|
+
"react-otp-input": "^2.4.0",
|
|
99
|
+
"react-redux": "^8.0.2",
|
|
100
|
+
"react-spring-bottom-sheet": "^3.4.1",
|
|
101
|
+
"yup": "^0.32.11"
|
|
102
|
+
},
|
|
103
|
+
"peerDependencies": {
|
|
104
|
+
"react": "^18.2.0",
|
|
105
|
+
"react-dom": "^18.2.0"
|
|
106
|
+
},
|
|
107
|
+
"lint-staged": {
|
|
108
|
+
"src/**/*.{ts,tsx,json,js,jsx}": [
|
|
109
|
+
"yarn run prettier:fix",
|
|
110
|
+
"yarn run lint",
|
|
111
|
+
"git add ."
|
|
112
|
+
]
|
|
113
|
+
},
|
|
114
|
+
"browserslist": {
|
|
115
|
+
"production": [
|
|
116
|
+
">0.2%",
|
|
117
|
+
"not dead",
|
|
118
|
+
"not op_mini all"
|
|
119
|
+
],
|
|
120
|
+
"development": [
|
|
121
|
+
"last 1 chrome version",
|
|
122
|
+
"last 1 firefox version",
|
|
123
|
+
"last 1 safari version"
|
|
124
|
+
]
|
|
125
|
+
}
|
|
126
|
+
}
|