aeremmiddleware 1.0.19 → 1.0.22
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 +28 -28
- package/dist/AU finance/auEncrypt.d.ts +2 -0
- package/dist/AU finance/auEncrypt.js +63 -0
- package/dist/AU finance/auEncrypt.js.map +1 -0
- package/dist/AU finance/auFinance.d.ts +7 -0
- package/dist/AU finance/auFinance.js +43 -0
- package/dist/AU finance/auFinance.js.map +1 -0
- package/dist/Finance/auEncrypt.d.ts +2 -0
- package/dist/Finance/auEncrypt.js +36 -0
- package/dist/Finance/auEncrypt.js.map +1 -0
- package/dist/Finance/auFinance.d.ts +19 -0
- package/dist/Finance/auFinance.js +73 -0
- package/dist/Finance/auFinance.js.map +1 -0
- package/dist/Finance/index.d.ts +2 -0
- package/dist/Finance/index.js +2 -0
- package/dist/Finance/index.js.map +1 -1
- package/dist/Finance/ingenicoHtml.js +114 -114
- package/dist/Finance/novel.js +1 -1
- package/dist/Finance/novel.types.js +1 -1
- package/dist/Finance/novel.types.js.map +1 -1
- package/dist/Finance/qbrik.d.ts +34 -33
- package/dist/Finance/qbrik.js +7 -6
- package/dist/Finance/qbrik.js.map +1 -1
- package/dist/Finance/qbrik.types.d.ts +50 -0
- package/dist/Socials/Sms.types.js +1 -1
- package/dist/Socials/Sms.types.js.map +1 -1
- package/dist/Socials/Whatsapp.types.js +1 -1
- package/dist/Socials/Whatsapp.types.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/{PushNotification → pushNotification}/index.js +1 -1
- package/package.json +21 -21
- package/src/Finance/Ingenico.types.ts +21 -21
- package/src/Finance/auEncrypt.ts +32 -0
- package/src/Finance/auFinance.ts +78 -0
- package/src/Finance/crimeCheck.ts +135 -135
- package/src/Finance/crimecheck.types.ts +31 -31
- package/src/Finance/encrypt.ts +18 -18
- package/src/Finance/idfy.ts +542 -542
- package/src/Finance/index.ts +15 -13
- package/src/Finance/ingenico.ts +110 -110
- package/src/Finance/ingenicoHtml.ts +119 -119
- package/src/Finance/novel.ts +226 -226
- package/src/Finance/novel.types.ts +24 -24
- package/src/Finance/qbrik.ts +828 -822
- package/src/Finance/qbrik.types.ts +131 -81
- package/src/PushNotification/index.ts +5 -5
- package/src/PushNotification/pushNotificationFCM.ts +37 -37
- package/src/Socials/Sms.types.ts +9 -9
- package/src/Socials/SmsSender.ts +78 -78
- package/src/Socials/Whatsapp.types.ts +95 -95
- package/src/Socials/index.ts +6 -6
- package/src/Socials/whatsApp.ts +188 -188
- package/src/index.ts +9 -9
- package/tsconfig.json +111 -111
- /package/dist/{PushNotification → pushNotification}/index.d.ts +0 -0
- /package/dist/{PushNotification → pushNotification}/index.js.map +0 -0
- /package/dist/{PushNotification → pushNotification}/pushNotificationFCM.d.ts +0 -0
- /package/dist/{PushNotification → pushNotification}/pushNotificationFCM.js +0 -0
- /package/dist/{PushNotification → pushNotification}/pushNotificationFCM.js.map +0 -0
package/src/Finance/idfy.ts
CHANGED
|
@@ -1,542 +1,542 @@
|
|
|
1
|
-
import axios, { AxiosRequestConfig, AxiosResponse } from "axios";
|
|
2
|
-
interface ObjectTypes {
|
|
3
|
-
IDFY_TASK_ID: string;
|
|
4
|
-
IDFY_GROUP_ID: string;
|
|
5
|
-
IDFY_ACCOUNT_ID: string;
|
|
6
|
-
IDFY_API_KEY: string;
|
|
7
|
-
IDFY_COMPANY_SEARCH_API_KEY: string;
|
|
8
|
-
}
|
|
9
|
-
export default class IdfyAPIWrapper {
|
|
10
|
-
private bodyTaskIdGroupId = {
|
|
11
|
-
task_id: "",
|
|
12
|
-
group_id: "",
|
|
13
|
-
};
|
|
14
|
-
private defaultHeaderIdfyApi = {
|
|
15
|
-
"account-id": "",
|
|
16
|
-
"api-key": "",
|
|
17
|
-
};
|
|
18
|
-
private standardErrorThrowFormat = {
|
|
19
|
-
statusCode: 400,
|
|
20
|
-
message: ["bad request"],
|
|
21
|
-
};
|
|
22
|
-
private baseUrl: string = "https://eve.idfy.com/";
|
|
23
|
-
private gstVerificationEndPoint =
|
|
24
|
-
"v3/tasks/sync/verify_with_source/ind_gst_certificate";
|
|
25
|
-
private panIndividualVerificationEndPoint =
|
|
26
|
-
"v3/tasks/async/verify_with_source/ind_pan_plus";
|
|
27
|
-
private cinCompanyVerificationEndPoint =
|
|
28
|
-
"v3/tasks/async/verify_with_source/ind_mca";
|
|
29
|
-
private taskUrl = "v3/tasks?request_id=";
|
|
30
|
-
private asyncIndividualAadhaarLiteInfoEndPoint =
|
|
31
|
-
"v3/tasks/async/verify_with_source/aadhaar_lite";
|
|
32
|
-
private syncIndividualAadharScanInfoEndpoint =
|
|
33
|
-
"v3/tasks/sync/extract/ind_aadhaar_plus";
|
|
34
|
-
private syncIndividualPANScanInfoEndpoint = "v3/tasks/sync/extract/ind_pan";
|
|
35
|
-
private syncIndividualGSTScanInfoEndpoint =
|
|
36
|
-
"v3/tasks/sync/extract/ind_gst_certificate";
|
|
37
|
-
private syncIndividualLiveFaceLivenessEndpoint =
|
|
38
|
-
"v3/tasks/sync/check_photo_liveness/face";
|
|
39
|
-
|
|
40
|
-
private idfyCompanySearch = {
|
|
41
|
-
defaultHeader: {
|
|
42
|
-
"api-key": "",
|
|
43
|
-
"Content-Type": "application/json",
|
|
44
|
-
},
|
|
45
|
-
version: "v1",
|
|
46
|
-
companySearchUrl: "https://riskai.idfystaging.com/api/v1/company/search",
|
|
47
|
-
taskBaseUrl: "https://riskai.idfystaging.com/api/v1/task/",
|
|
48
|
-
cinllpinUrl: "https://riskai.idfystaging.com/api/v1/company/basic",
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
private idfyError = {
|
|
52
|
-
INVALID_IMAGE: {
|
|
53
|
-
idfyErrorCode: "IDFY_ERR_100",
|
|
54
|
-
message: "Please scan correct document",
|
|
55
|
-
},
|
|
56
|
-
INSUFFICIENT_CREDITS: {
|
|
57
|
-
idfyErrorCode: "IDFY_ERR_101",
|
|
58
|
-
message: "Please renew credit",
|
|
59
|
-
},
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
constructor({
|
|
63
|
-
IDFY_TASK_ID,
|
|
64
|
-
IDFY_GROUP_ID,
|
|
65
|
-
IDFY_ACCOUNT_ID,
|
|
66
|
-
IDFY_API_KEY,
|
|
67
|
-
IDFY_COMPANY_SEARCH_API_KEY,
|
|
68
|
-
}: ObjectTypes) {
|
|
69
|
-
this.bodyTaskIdGroupId.task_id = IDFY_TASK_ID;
|
|
70
|
-
this.bodyTaskIdGroupId.group_id = IDFY_GROUP_ID;
|
|
71
|
-
this.defaultHeaderIdfyApi["account-id"] = IDFY_ACCOUNT_ID;
|
|
72
|
-
this.defaultHeaderIdfyApi["api-key"] = IDFY_API_KEY;
|
|
73
|
-
this.idfyCompanySearch.defaultHeader["api-key"] =
|
|
74
|
-
IDFY_COMPANY_SEARCH_API_KEY;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
private async makeRequest<T>(
|
|
78
|
-
method: string,
|
|
79
|
-
endpoint: string,
|
|
80
|
-
data?: any
|
|
81
|
-
): Promise<T> {
|
|
82
|
-
const requestConfig: AxiosRequestConfig = {
|
|
83
|
-
method,
|
|
84
|
-
url: this.baseUrl + endpoint,
|
|
85
|
-
headers: this.defaultHeaderIdfyApi,
|
|
86
|
-
data,
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
try {
|
|
90
|
-
const response: AxiosResponse<T> = await axios(requestConfig);
|
|
91
|
-
return response.data;
|
|
92
|
-
} catch (error) {
|
|
93
|
-
console.error("Error while making Idfy Axios API request:", error);
|
|
94
|
-
throw error;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
private async makeAxiosRequest<T>({
|
|
99
|
-
method,
|
|
100
|
-
url,
|
|
101
|
-
data,
|
|
102
|
-
headers,
|
|
103
|
-
}: {
|
|
104
|
-
method: string;
|
|
105
|
-
url: string;
|
|
106
|
-
data?: any;
|
|
107
|
-
headers: any;
|
|
108
|
-
}): Promise<T> {
|
|
109
|
-
const requestConfig: AxiosRequestConfig = {
|
|
110
|
-
method,
|
|
111
|
-
url,
|
|
112
|
-
headers,
|
|
113
|
-
data,
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
try {
|
|
117
|
-
const response: AxiosResponse<T> = await axios(requestConfig);
|
|
118
|
-
return response.data;
|
|
119
|
-
} catch (error) {
|
|
120
|
-
console.error(
|
|
121
|
-
"Error while making Idfy makeAxiosRequest API request:",
|
|
122
|
-
error
|
|
123
|
-
);
|
|
124
|
-
throw error;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
private async getTask(requestId: string): Promise<any> {
|
|
129
|
-
try {
|
|
130
|
-
// const data = {}
|
|
131
|
-
const urlEndPoint = this.taskUrl + requestId;
|
|
132
|
-
const response = await this.makeRequest<any>("get", urlEndPoint);
|
|
133
|
-
return response;
|
|
134
|
-
} catch (error) {
|
|
135
|
-
console.error("Error while fetching Idfy getTask API data:", error);
|
|
136
|
-
throw error;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
private async getCompanySearchTask({
|
|
141
|
-
requestId,
|
|
142
|
-
}: {
|
|
143
|
-
requestId: string;
|
|
144
|
-
}): Promise<any> {
|
|
145
|
-
try {
|
|
146
|
-
const taskBaseUrl = this.idfyCompanySearch.taskBaseUrl + requestId;
|
|
147
|
-
const response = await this.makeAxiosRequest({
|
|
148
|
-
method: "get",
|
|
149
|
-
url: taskBaseUrl,
|
|
150
|
-
headers: this.idfyCompanySearch.defaultHeader,
|
|
151
|
-
});
|
|
152
|
-
return response;
|
|
153
|
-
} catch (error) {
|
|
154
|
-
console.error(
|
|
155
|
-
"Error while fetching Idfy getCompanySearchTask API data:",
|
|
156
|
-
error
|
|
157
|
-
);
|
|
158
|
-
throw error;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
private async pingTaskUntilSuccess(requestId: string): Promise<any> {
|
|
163
|
-
try {
|
|
164
|
-
let res: any = null;
|
|
165
|
-
const checkTaskAfter1sec = (requestId: any) => {
|
|
166
|
-
return new Promise<any>((resolve, reject) => {
|
|
167
|
-
try {
|
|
168
|
-
setTimeout(async () => {
|
|
169
|
-
const data = await this.getTask(requestId);
|
|
170
|
-
if (res?.[0].status == "failed") {
|
|
171
|
-
reject(res);
|
|
172
|
-
}
|
|
173
|
-
resolve(data);
|
|
174
|
-
}, 1000);
|
|
175
|
-
} catch (e) {
|
|
176
|
-
reject(e);
|
|
177
|
-
}
|
|
178
|
-
});
|
|
179
|
-
};
|
|
180
|
-
do {
|
|
181
|
-
res = await checkTaskAfter1sec(requestId);
|
|
182
|
-
|
|
183
|
-
console.log("### res ", res);
|
|
184
|
-
} while (res?.[0].status !== "completed");
|
|
185
|
-
|
|
186
|
-
return res;
|
|
187
|
-
} catch (error) {
|
|
188
|
-
console.error("Error while fetching Idfy getTask API data:", error);
|
|
189
|
-
throw error;
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
private async pingCompanySearchTaskUntilSuccess(
|
|
194
|
-
requestId: string
|
|
195
|
-
): Promise<any> {
|
|
196
|
-
try {
|
|
197
|
-
console.log(" ## requestId ", requestId);
|
|
198
|
-
let res: any = null;
|
|
199
|
-
const checkTaskAfter1sec = (requestId: string) => {
|
|
200
|
-
return new Promise<any>((resolve, reject) => {
|
|
201
|
-
try {
|
|
202
|
-
setTimeout(async () => {
|
|
203
|
-
const data = await this.getCompanySearchTask({ requestId });
|
|
204
|
-
if (data.status != "failed") {
|
|
205
|
-
resolve(data);
|
|
206
|
-
} else {
|
|
207
|
-
reject(res);
|
|
208
|
-
}
|
|
209
|
-
}, 1000);
|
|
210
|
-
} catch (e) {
|
|
211
|
-
reject(e);
|
|
212
|
-
}
|
|
213
|
-
});
|
|
214
|
-
};
|
|
215
|
-
do {
|
|
216
|
-
res = await checkTaskAfter1sec(requestId);
|
|
217
|
-
console.log("### res ", res);
|
|
218
|
-
} while (res?.status !== "completed");
|
|
219
|
-
|
|
220
|
-
return res;
|
|
221
|
-
} catch (error) {
|
|
222
|
-
console.error("Error while fetching Idfy getTask API data:", error);
|
|
223
|
-
throw error;
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
async getCompanyGstInfo({ gstNo }: { gstNo: string }): Promise<any> {
|
|
227
|
-
try {
|
|
228
|
-
const data = {
|
|
229
|
-
...this.bodyTaskIdGroupId,
|
|
230
|
-
data: {
|
|
231
|
-
gstin: gstNo,
|
|
232
|
-
},
|
|
233
|
-
};
|
|
234
|
-
const response = await this.makeRequest<any>(
|
|
235
|
-
"post",
|
|
236
|
-
this.gstVerificationEndPoint,
|
|
237
|
-
data
|
|
238
|
-
);
|
|
239
|
-
return response;
|
|
240
|
-
} catch (error: any) {
|
|
241
|
-
if (error?.response?.data?.error) {
|
|
242
|
-
let obj = this.idfyError;
|
|
243
|
-
const errorObj = obj[error?.response?.data?.error as keyof typeof obj];
|
|
244
|
-
if (errorObj)
|
|
245
|
-
throw {
|
|
246
|
-
...this.standardErrorThrowFormat,
|
|
247
|
-
message: [errorObj.message],
|
|
248
|
-
};
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
throw error;
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
async getCompanyCINInfo({ cinNo }: { cinNo: string }): Promise<any> {
|
|
255
|
-
try {
|
|
256
|
-
const data = {
|
|
257
|
-
...this.bodyTaskIdGroupId,
|
|
258
|
-
data: {
|
|
259
|
-
cin: cinNo,
|
|
260
|
-
},
|
|
261
|
-
};
|
|
262
|
-
const response = await this.makeRequest<any>(
|
|
263
|
-
"post",
|
|
264
|
-
this.cinCompanyVerificationEndPoint,
|
|
265
|
-
data
|
|
266
|
-
);
|
|
267
|
-
const successData = await this.pingTaskUntilSuccess(response.request_id);
|
|
268
|
-
|
|
269
|
-
return successData?.[0]?.result?.source_output;
|
|
270
|
-
} catch (error: any) {
|
|
271
|
-
if (error?.response?.data?.error) {
|
|
272
|
-
let obj = this.idfyError;
|
|
273
|
-
const errorObj = obj[error?.response?.data?.error as keyof typeof obj];
|
|
274
|
-
if (errorObj)
|
|
275
|
-
throw {
|
|
276
|
-
...this.standardErrorThrowFormat,
|
|
277
|
-
message: [errorObj.message],
|
|
278
|
-
};
|
|
279
|
-
}
|
|
280
|
-
throw error;
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
async getIndividualPANInfo({ panNo }: { panNo: string }): Promise<any> {
|
|
284
|
-
try {
|
|
285
|
-
const data = {
|
|
286
|
-
...this.bodyTaskIdGroupId,
|
|
287
|
-
data: {
|
|
288
|
-
id_number: panNo,
|
|
289
|
-
},
|
|
290
|
-
};
|
|
291
|
-
const response = await this.makeRequest<any>(
|
|
292
|
-
"post",
|
|
293
|
-
this.panIndividualVerificationEndPoint,
|
|
294
|
-
data
|
|
295
|
-
);
|
|
296
|
-
const successData = await this.pingTaskUntilSuccess(response.request_id);
|
|
297
|
-
|
|
298
|
-
return successData;
|
|
299
|
-
} catch (error: any) {
|
|
300
|
-
if (error?.response?.data?.error) {
|
|
301
|
-
let obj = this.idfyError;
|
|
302
|
-
const errorObj = obj[error?.response?.data?.error as keyof typeof obj];
|
|
303
|
-
if (errorObj)
|
|
304
|
-
throw {
|
|
305
|
-
...this.standardErrorThrowFormat,
|
|
306
|
-
message: [errorObj.message],
|
|
307
|
-
};
|
|
308
|
-
}
|
|
309
|
-
throw error;
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
async getSyncIndividualAadharScanInfo({
|
|
314
|
-
frontScanBase64,
|
|
315
|
-
backScanBase64,
|
|
316
|
-
}: {
|
|
317
|
-
frontScanBase64: string;
|
|
318
|
-
backScanBase64: string;
|
|
319
|
-
}): Promise<any> {
|
|
320
|
-
try {
|
|
321
|
-
const data = {
|
|
322
|
-
...this.bodyTaskIdGroupId,
|
|
323
|
-
data: {
|
|
324
|
-
document1: frontScanBase64,
|
|
325
|
-
document2: backScanBase64,
|
|
326
|
-
consent: "yes",
|
|
327
|
-
advanced_details: {
|
|
328
|
-
extract_qr_info: true,
|
|
329
|
-
extract_last_4_digit: false,
|
|
330
|
-
},
|
|
331
|
-
},
|
|
332
|
-
};
|
|
333
|
-
const response = await this.makeRequest<any>(
|
|
334
|
-
"post",
|
|
335
|
-
this.syncIndividualAadharScanInfoEndpoint,
|
|
336
|
-
data
|
|
337
|
-
);
|
|
338
|
-
|
|
339
|
-
return response?.result;
|
|
340
|
-
} catch (error: any) {
|
|
341
|
-
if (error?.response?.data?.error) {
|
|
342
|
-
let obj = this.idfyError;
|
|
343
|
-
const errorObj = obj[error?.response?.data?.error as keyof typeof obj];
|
|
344
|
-
if (errorObj)
|
|
345
|
-
throw {
|
|
346
|
-
...this.standardErrorThrowFormat,
|
|
347
|
-
message: [errorObj.message],
|
|
348
|
-
};
|
|
349
|
-
}
|
|
350
|
-
throw error;
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
async getSyncIndividualPANScanInfo({
|
|
355
|
-
frontScanBase64,
|
|
356
|
-
}: {
|
|
357
|
-
frontScanBase64: string;
|
|
358
|
-
}): Promise<any> {
|
|
359
|
-
try {
|
|
360
|
-
const data = {
|
|
361
|
-
...this.bodyTaskIdGroupId,
|
|
362
|
-
data: {
|
|
363
|
-
document1: frontScanBase64,
|
|
364
|
-
consent: "yes",
|
|
365
|
-
},
|
|
366
|
-
};
|
|
367
|
-
const response = await this.makeRequest<any>(
|
|
368
|
-
"post",
|
|
369
|
-
this.syncIndividualPANScanInfoEndpoint,
|
|
370
|
-
data
|
|
371
|
-
);
|
|
372
|
-
|
|
373
|
-
return response?.result;
|
|
374
|
-
} catch (error: any) {
|
|
375
|
-
if (error?.response?.data?.error) {
|
|
376
|
-
let obj = this.idfyError;
|
|
377
|
-
const errorObj = obj[error?.response?.data?.error as keyof typeof obj];
|
|
378
|
-
if (errorObj)
|
|
379
|
-
throw {
|
|
380
|
-
...this.standardErrorThrowFormat,
|
|
381
|
-
message: [errorObj.message],
|
|
382
|
-
};
|
|
383
|
-
}
|
|
384
|
-
throw error;
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
async getSyncCompanyGSTScanInfo({
|
|
389
|
-
frontScanBase64,
|
|
390
|
-
}: {
|
|
391
|
-
frontScanBase64: string;
|
|
392
|
-
}): Promise<any> {
|
|
393
|
-
try {
|
|
394
|
-
const data = {
|
|
395
|
-
...this.bodyTaskIdGroupId,
|
|
396
|
-
data: {
|
|
397
|
-
document1: frontScanBase64,
|
|
398
|
-
},
|
|
399
|
-
};
|
|
400
|
-
const response = await this.makeRequest<any>(
|
|
401
|
-
"post",
|
|
402
|
-
this.syncIndividualGSTScanInfoEndpoint,
|
|
403
|
-
data
|
|
404
|
-
);
|
|
405
|
-
|
|
406
|
-
return response?.result;
|
|
407
|
-
} catch (error: any) {
|
|
408
|
-
if (error?.response?.data?.error) {
|
|
409
|
-
let obj = this.idfyError;
|
|
410
|
-
const errorObj = obj[error?.response?.data?.error as keyof typeof obj];
|
|
411
|
-
if (errorObj)
|
|
412
|
-
throw {
|
|
413
|
-
...this.standardErrorThrowFormat,
|
|
414
|
-
message: [errorObj.message],
|
|
415
|
-
};
|
|
416
|
-
}
|
|
417
|
-
throw error;
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
async getSyncIndividualLivenessSelfyScanInfo({
|
|
422
|
-
faceScanBase64,
|
|
423
|
-
}: {
|
|
424
|
-
faceScanBase64: string;
|
|
425
|
-
}): Promise<any> {
|
|
426
|
-
try {
|
|
427
|
-
const data = {
|
|
428
|
-
...this.bodyTaskIdGroupId,
|
|
429
|
-
data: {
|
|
430
|
-
document1: faceScanBase64,
|
|
431
|
-
consent: "yes",
|
|
432
|
-
},
|
|
433
|
-
};
|
|
434
|
-
const response = await this.makeRequest<any>(
|
|
435
|
-
"post",
|
|
436
|
-
this.syncIndividualLiveFaceLivenessEndpoint,
|
|
437
|
-
data
|
|
438
|
-
);
|
|
439
|
-
|
|
440
|
-
return response?.result;
|
|
441
|
-
} catch (error: any) {
|
|
442
|
-
if (error?.response?.data?.error) {
|
|
443
|
-
let obj = this.idfyError;
|
|
444
|
-
const errorObj = obj[error?.response?.data?.error as keyof typeof obj];
|
|
445
|
-
if (errorObj)
|
|
446
|
-
throw {
|
|
447
|
-
...this.standardErrorThrowFormat,
|
|
448
|
-
message: [errorObj.message],
|
|
449
|
-
};
|
|
450
|
-
}
|
|
451
|
-
throw error;
|
|
452
|
-
}
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
async getAsyncAadhaarLiteInfo({
|
|
456
|
-
aadhaarNo,
|
|
457
|
-
}: {
|
|
458
|
-
aadhaarNo: string;
|
|
459
|
-
}): Promise<any> {
|
|
460
|
-
try {
|
|
461
|
-
const data = {
|
|
462
|
-
...this.bodyTaskIdGroupId,
|
|
463
|
-
data: {
|
|
464
|
-
aadhaar_number: aadhaarNo,
|
|
465
|
-
},
|
|
466
|
-
};
|
|
467
|
-
const response = await this.makeRequest<any>(
|
|
468
|
-
"post",
|
|
469
|
-
this.asyncIndividualAadhaarLiteInfoEndPoint,
|
|
470
|
-
data
|
|
471
|
-
);
|
|
472
|
-
const successData = await this.pingTaskUntilSuccess(response.request_id);
|
|
473
|
-
|
|
474
|
-
return successData;
|
|
475
|
-
} catch (error: any) {
|
|
476
|
-
if (error?.response?.data?.error) {
|
|
477
|
-
let obj = this.idfyError;
|
|
478
|
-
const errorObj = obj[error?.response?.data?.error as keyof typeof obj];
|
|
479
|
-
if (errorObj)
|
|
480
|
-
throw {
|
|
481
|
-
...this.standardErrorThrowFormat,
|
|
482
|
-
message: [errorObj.message],
|
|
483
|
-
};
|
|
484
|
-
}
|
|
485
|
-
throw error;
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
async getCompanyDetailsByName({
|
|
490
|
-
legalName,
|
|
491
|
-
}: {
|
|
492
|
-
legalName: string;
|
|
493
|
-
}): Promise<any> {
|
|
494
|
-
try {
|
|
495
|
-
const data = {
|
|
496
|
-
version: this.idfyCompanySearch.version,
|
|
497
|
-
...this.bodyTaskIdGroupId,
|
|
498
|
-
data: {
|
|
499
|
-
name: legalName,
|
|
500
|
-
},
|
|
501
|
-
};
|
|
502
|
-
const response = await this.makeAxiosRequest<any>({
|
|
503
|
-
method: "post",
|
|
504
|
-
url: this.idfyCompanySearch.companySearchUrl,
|
|
505
|
-
data,
|
|
506
|
-
headers: this.idfyCompanySearch.defaultHeader,
|
|
507
|
-
});
|
|
508
|
-
const successData = await this.pingCompanySearchTaskUntilSuccess(
|
|
509
|
-
response.request_id
|
|
510
|
-
);
|
|
511
|
-
|
|
512
|
-
return { request_id: response, successData: successData };
|
|
513
|
-
} catch (error) {
|
|
514
|
-
throw error;
|
|
515
|
-
}
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
async getCompanyDetailsByLlpinOrCin({
|
|
519
|
-
cinOrLlpin,
|
|
520
|
-
}: {
|
|
521
|
-
cinOrLlpin: string;
|
|
522
|
-
}): Promise<any> {
|
|
523
|
-
try {
|
|
524
|
-
const data = {
|
|
525
|
-
version: this.idfyCompanySearch.version,
|
|
526
|
-
...this.bodyTaskIdGroupId,
|
|
527
|
-
data: {
|
|
528
|
-
cin_llpin: cinOrLlpin,
|
|
529
|
-
},
|
|
530
|
-
};
|
|
531
|
-
const response = await this.makeAxiosRequest<any>({
|
|
532
|
-
method: "post",
|
|
533
|
-
url: this.idfyCompanySearch.cinllpinUrl,
|
|
534
|
-
data,
|
|
535
|
-
headers: this.idfyCompanySearch.defaultHeader,
|
|
536
|
-
});
|
|
537
|
-
return { response: response };
|
|
538
|
-
} catch (error) {
|
|
539
|
-
throw error;
|
|
540
|
-
}
|
|
541
|
-
}
|
|
542
|
-
}
|
|
1
|
+
import axios, { AxiosRequestConfig, AxiosResponse } from "axios";
|
|
2
|
+
interface ObjectTypes {
|
|
3
|
+
IDFY_TASK_ID: string;
|
|
4
|
+
IDFY_GROUP_ID: string;
|
|
5
|
+
IDFY_ACCOUNT_ID: string;
|
|
6
|
+
IDFY_API_KEY: string;
|
|
7
|
+
IDFY_COMPANY_SEARCH_API_KEY: string;
|
|
8
|
+
}
|
|
9
|
+
export default class IdfyAPIWrapper {
|
|
10
|
+
private bodyTaskIdGroupId = {
|
|
11
|
+
task_id: "",
|
|
12
|
+
group_id: "",
|
|
13
|
+
};
|
|
14
|
+
private defaultHeaderIdfyApi = {
|
|
15
|
+
"account-id": "",
|
|
16
|
+
"api-key": "",
|
|
17
|
+
};
|
|
18
|
+
private standardErrorThrowFormat = {
|
|
19
|
+
statusCode: 400,
|
|
20
|
+
message: ["bad request"],
|
|
21
|
+
};
|
|
22
|
+
private baseUrl: string = "https://eve.idfy.com/";
|
|
23
|
+
private gstVerificationEndPoint =
|
|
24
|
+
"v3/tasks/sync/verify_with_source/ind_gst_certificate";
|
|
25
|
+
private panIndividualVerificationEndPoint =
|
|
26
|
+
"v3/tasks/async/verify_with_source/ind_pan_plus";
|
|
27
|
+
private cinCompanyVerificationEndPoint =
|
|
28
|
+
"v3/tasks/async/verify_with_source/ind_mca";
|
|
29
|
+
private taskUrl = "v3/tasks?request_id=";
|
|
30
|
+
private asyncIndividualAadhaarLiteInfoEndPoint =
|
|
31
|
+
"v3/tasks/async/verify_with_source/aadhaar_lite";
|
|
32
|
+
private syncIndividualAadharScanInfoEndpoint =
|
|
33
|
+
"v3/tasks/sync/extract/ind_aadhaar_plus";
|
|
34
|
+
private syncIndividualPANScanInfoEndpoint = "v3/tasks/sync/extract/ind_pan";
|
|
35
|
+
private syncIndividualGSTScanInfoEndpoint =
|
|
36
|
+
"v3/tasks/sync/extract/ind_gst_certificate";
|
|
37
|
+
private syncIndividualLiveFaceLivenessEndpoint =
|
|
38
|
+
"v3/tasks/sync/check_photo_liveness/face";
|
|
39
|
+
|
|
40
|
+
private idfyCompanySearch = {
|
|
41
|
+
defaultHeader: {
|
|
42
|
+
"api-key": "",
|
|
43
|
+
"Content-Type": "application/json",
|
|
44
|
+
},
|
|
45
|
+
version: "v1",
|
|
46
|
+
companySearchUrl: "https://riskai.idfystaging.com/api/v1/company/search",
|
|
47
|
+
taskBaseUrl: "https://riskai.idfystaging.com/api/v1/task/",
|
|
48
|
+
cinllpinUrl: "https://riskai.idfystaging.com/api/v1/company/basic",
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
private idfyError = {
|
|
52
|
+
INVALID_IMAGE: {
|
|
53
|
+
idfyErrorCode: "IDFY_ERR_100",
|
|
54
|
+
message: "Please scan correct document",
|
|
55
|
+
},
|
|
56
|
+
INSUFFICIENT_CREDITS: {
|
|
57
|
+
idfyErrorCode: "IDFY_ERR_101",
|
|
58
|
+
message: "Please renew credit",
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
constructor({
|
|
63
|
+
IDFY_TASK_ID,
|
|
64
|
+
IDFY_GROUP_ID,
|
|
65
|
+
IDFY_ACCOUNT_ID,
|
|
66
|
+
IDFY_API_KEY,
|
|
67
|
+
IDFY_COMPANY_SEARCH_API_KEY,
|
|
68
|
+
}: ObjectTypes) {
|
|
69
|
+
this.bodyTaskIdGroupId.task_id = IDFY_TASK_ID;
|
|
70
|
+
this.bodyTaskIdGroupId.group_id = IDFY_GROUP_ID;
|
|
71
|
+
this.defaultHeaderIdfyApi["account-id"] = IDFY_ACCOUNT_ID;
|
|
72
|
+
this.defaultHeaderIdfyApi["api-key"] = IDFY_API_KEY;
|
|
73
|
+
this.idfyCompanySearch.defaultHeader["api-key"] =
|
|
74
|
+
IDFY_COMPANY_SEARCH_API_KEY;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
private async makeRequest<T>(
|
|
78
|
+
method: string,
|
|
79
|
+
endpoint: string,
|
|
80
|
+
data?: any
|
|
81
|
+
): Promise<T> {
|
|
82
|
+
const requestConfig: AxiosRequestConfig = {
|
|
83
|
+
method,
|
|
84
|
+
url: this.baseUrl + endpoint,
|
|
85
|
+
headers: this.defaultHeaderIdfyApi,
|
|
86
|
+
data,
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
try {
|
|
90
|
+
const response: AxiosResponse<T> = await axios(requestConfig);
|
|
91
|
+
return response.data;
|
|
92
|
+
} catch (error) {
|
|
93
|
+
console.error("Error while making Idfy Axios API request:", error);
|
|
94
|
+
throw error;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
private async makeAxiosRequest<T>({
|
|
99
|
+
method,
|
|
100
|
+
url,
|
|
101
|
+
data,
|
|
102
|
+
headers,
|
|
103
|
+
}: {
|
|
104
|
+
method: string;
|
|
105
|
+
url: string;
|
|
106
|
+
data?: any;
|
|
107
|
+
headers: any;
|
|
108
|
+
}): Promise<T> {
|
|
109
|
+
const requestConfig: AxiosRequestConfig = {
|
|
110
|
+
method,
|
|
111
|
+
url,
|
|
112
|
+
headers,
|
|
113
|
+
data,
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
try {
|
|
117
|
+
const response: AxiosResponse<T> = await axios(requestConfig);
|
|
118
|
+
return response.data;
|
|
119
|
+
} catch (error) {
|
|
120
|
+
console.error(
|
|
121
|
+
"Error while making Idfy makeAxiosRequest API request:",
|
|
122
|
+
error
|
|
123
|
+
);
|
|
124
|
+
throw error;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
private async getTask(requestId: string): Promise<any> {
|
|
129
|
+
try {
|
|
130
|
+
// const data = {}
|
|
131
|
+
const urlEndPoint = this.taskUrl + requestId;
|
|
132
|
+
const response = await this.makeRequest<any>("get", urlEndPoint);
|
|
133
|
+
return response;
|
|
134
|
+
} catch (error) {
|
|
135
|
+
console.error("Error while fetching Idfy getTask API data:", error);
|
|
136
|
+
throw error;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
private async getCompanySearchTask({
|
|
141
|
+
requestId,
|
|
142
|
+
}: {
|
|
143
|
+
requestId: string;
|
|
144
|
+
}): Promise<any> {
|
|
145
|
+
try {
|
|
146
|
+
const taskBaseUrl = this.idfyCompanySearch.taskBaseUrl + requestId;
|
|
147
|
+
const response = await this.makeAxiosRequest({
|
|
148
|
+
method: "get",
|
|
149
|
+
url: taskBaseUrl,
|
|
150
|
+
headers: this.idfyCompanySearch.defaultHeader,
|
|
151
|
+
});
|
|
152
|
+
return response;
|
|
153
|
+
} catch (error) {
|
|
154
|
+
console.error(
|
|
155
|
+
"Error while fetching Idfy getCompanySearchTask API data:",
|
|
156
|
+
error
|
|
157
|
+
);
|
|
158
|
+
throw error;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
private async pingTaskUntilSuccess(requestId: string): Promise<any> {
|
|
163
|
+
try {
|
|
164
|
+
let res: any = null;
|
|
165
|
+
const checkTaskAfter1sec = (requestId: any) => {
|
|
166
|
+
return new Promise<any>((resolve, reject) => {
|
|
167
|
+
try {
|
|
168
|
+
setTimeout(async () => {
|
|
169
|
+
const data = await this.getTask(requestId);
|
|
170
|
+
if (res?.[0].status == "failed") {
|
|
171
|
+
reject(res);
|
|
172
|
+
}
|
|
173
|
+
resolve(data);
|
|
174
|
+
}, 1000);
|
|
175
|
+
} catch (e) {
|
|
176
|
+
reject(e);
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
};
|
|
180
|
+
do {
|
|
181
|
+
res = await checkTaskAfter1sec(requestId);
|
|
182
|
+
|
|
183
|
+
console.log("### res ", res);
|
|
184
|
+
} while (res?.[0].status !== "completed");
|
|
185
|
+
|
|
186
|
+
return res;
|
|
187
|
+
} catch (error) {
|
|
188
|
+
console.error("Error while fetching Idfy getTask API data:", error);
|
|
189
|
+
throw error;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
private async pingCompanySearchTaskUntilSuccess(
|
|
194
|
+
requestId: string
|
|
195
|
+
): Promise<any> {
|
|
196
|
+
try {
|
|
197
|
+
console.log(" ## requestId ", requestId);
|
|
198
|
+
let res: any = null;
|
|
199
|
+
const checkTaskAfter1sec = (requestId: string) => {
|
|
200
|
+
return new Promise<any>((resolve, reject) => {
|
|
201
|
+
try {
|
|
202
|
+
setTimeout(async () => {
|
|
203
|
+
const data = await this.getCompanySearchTask({ requestId });
|
|
204
|
+
if (data.status != "failed") {
|
|
205
|
+
resolve(data);
|
|
206
|
+
} else {
|
|
207
|
+
reject(res);
|
|
208
|
+
}
|
|
209
|
+
}, 1000);
|
|
210
|
+
} catch (e) {
|
|
211
|
+
reject(e);
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
};
|
|
215
|
+
do {
|
|
216
|
+
res = await checkTaskAfter1sec(requestId);
|
|
217
|
+
console.log("### res ", res);
|
|
218
|
+
} while (res?.status !== "completed");
|
|
219
|
+
|
|
220
|
+
return res;
|
|
221
|
+
} catch (error) {
|
|
222
|
+
console.error("Error while fetching Idfy getTask API data:", error);
|
|
223
|
+
throw error;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
async getCompanyGstInfo({ gstNo }: { gstNo: string }): Promise<any> {
|
|
227
|
+
try {
|
|
228
|
+
const data = {
|
|
229
|
+
...this.bodyTaskIdGroupId,
|
|
230
|
+
data: {
|
|
231
|
+
gstin: gstNo,
|
|
232
|
+
},
|
|
233
|
+
};
|
|
234
|
+
const response = await this.makeRequest<any>(
|
|
235
|
+
"post",
|
|
236
|
+
this.gstVerificationEndPoint,
|
|
237
|
+
data
|
|
238
|
+
);
|
|
239
|
+
return response;
|
|
240
|
+
} catch (error: any) {
|
|
241
|
+
if (error?.response?.data?.error) {
|
|
242
|
+
let obj = this.idfyError;
|
|
243
|
+
const errorObj = obj[error?.response?.data?.error as keyof typeof obj];
|
|
244
|
+
if (errorObj)
|
|
245
|
+
throw {
|
|
246
|
+
...this.standardErrorThrowFormat,
|
|
247
|
+
message: [errorObj.message],
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
throw error;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
async getCompanyCINInfo({ cinNo }: { cinNo: string }): Promise<any> {
|
|
255
|
+
try {
|
|
256
|
+
const data = {
|
|
257
|
+
...this.bodyTaskIdGroupId,
|
|
258
|
+
data: {
|
|
259
|
+
cin: cinNo,
|
|
260
|
+
},
|
|
261
|
+
};
|
|
262
|
+
const response = await this.makeRequest<any>(
|
|
263
|
+
"post",
|
|
264
|
+
this.cinCompanyVerificationEndPoint,
|
|
265
|
+
data
|
|
266
|
+
);
|
|
267
|
+
const successData = await this.pingTaskUntilSuccess(response.request_id);
|
|
268
|
+
|
|
269
|
+
return successData?.[0]?.result?.source_output;
|
|
270
|
+
} catch (error: any) {
|
|
271
|
+
if (error?.response?.data?.error) {
|
|
272
|
+
let obj = this.idfyError;
|
|
273
|
+
const errorObj = obj[error?.response?.data?.error as keyof typeof obj];
|
|
274
|
+
if (errorObj)
|
|
275
|
+
throw {
|
|
276
|
+
...this.standardErrorThrowFormat,
|
|
277
|
+
message: [errorObj.message],
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
throw error;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
async getIndividualPANInfo({ panNo }: { panNo: string }): Promise<any> {
|
|
284
|
+
try {
|
|
285
|
+
const data = {
|
|
286
|
+
...this.bodyTaskIdGroupId,
|
|
287
|
+
data: {
|
|
288
|
+
id_number: panNo,
|
|
289
|
+
},
|
|
290
|
+
};
|
|
291
|
+
const response = await this.makeRequest<any>(
|
|
292
|
+
"post",
|
|
293
|
+
this.panIndividualVerificationEndPoint,
|
|
294
|
+
data
|
|
295
|
+
);
|
|
296
|
+
const successData = await this.pingTaskUntilSuccess(response.request_id);
|
|
297
|
+
|
|
298
|
+
return successData;
|
|
299
|
+
} catch (error: any) {
|
|
300
|
+
if (error?.response?.data?.error) {
|
|
301
|
+
let obj = this.idfyError;
|
|
302
|
+
const errorObj = obj[error?.response?.data?.error as keyof typeof obj];
|
|
303
|
+
if (errorObj)
|
|
304
|
+
throw {
|
|
305
|
+
...this.standardErrorThrowFormat,
|
|
306
|
+
message: [errorObj.message],
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
throw error;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
async getSyncIndividualAadharScanInfo({
|
|
314
|
+
frontScanBase64,
|
|
315
|
+
backScanBase64,
|
|
316
|
+
}: {
|
|
317
|
+
frontScanBase64: string;
|
|
318
|
+
backScanBase64: string;
|
|
319
|
+
}): Promise<any> {
|
|
320
|
+
try {
|
|
321
|
+
const data = {
|
|
322
|
+
...this.bodyTaskIdGroupId,
|
|
323
|
+
data: {
|
|
324
|
+
document1: frontScanBase64,
|
|
325
|
+
document2: backScanBase64,
|
|
326
|
+
consent: "yes",
|
|
327
|
+
advanced_details: {
|
|
328
|
+
extract_qr_info: true,
|
|
329
|
+
extract_last_4_digit: false,
|
|
330
|
+
},
|
|
331
|
+
},
|
|
332
|
+
};
|
|
333
|
+
const response = await this.makeRequest<any>(
|
|
334
|
+
"post",
|
|
335
|
+
this.syncIndividualAadharScanInfoEndpoint,
|
|
336
|
+
data
|
|
337
|
+
);
|
|
338
|
+
|
|
339
|
+
return response?.result;
|
|
340
|
+
} catch (error: any) {
|
|
341
|
+
if (error?.response?.data?.error) {
|
|
342
|
+
let obj = this.idfyError;
|
|
343
|
+
const errorObj = obj[error?.response?.data?.error as keyof typeof obj];
|
|
344
|
+
if (errorObj)
|
|
345
|
+
throw {
|
|
346
|
+
...this.standardErrorThrowFormat,
|
|
347
|
+
message: [errorObj.message],
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
throw error;
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
async getSyncIndividualPANScanInfo({
|
|
355
|
+
frontScanBase64,
|
|
356
|
+
}: {
|
|
357
|
+
frontScanBase64: string;
|
|
358
|
+
}): Promise<any> {
|
|
359
|
+
try {
|
|
360
|
+
const data = {
|
|
361
|
+
...this.bodyTaskIdGroupId,
|
|
362
|
+
data: {
|
|
363
|
+
document1: frontScanBase64,
|
|
364
|
+
consent: "yes",
|
|
365
|
+
},
|
|
366
|
+
};
|
|
367
|
+
const response = await this.makeRequest<any>(
|
|
368
|
+
"post",
|
|
369
|
+
this.syncIndividualPANScanInfoEndpoint,
|
|
370
|
+
data
|
|
371
|
+
);
|
|
372
|
+
|
|
373
|
+
return response?.result;
|
|
374
|
+
} catch (error: any) {
|
|
375
|
+
if (error?.response?.data?.error) {
|
|
376
|
+
let obj = this.idfyError;
|
|
377
|
+
const errorObj = obj[error?.response?.data?.error as keyof typeof obj];
|
|
378
|
+
if (errorObj)
|
|
379
|
+
throw {
|
|
380
|
+
...this.standardErrorThrowFormat,
|
|
381
|
+
message: [errorObj.message],
|
|
382
|
+
};
|
|
383
|
+
}
|
|
384
|
+
throw error;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
async getSyncCompanyGSTScanInfo({
|
|
389
|
+
frontScanBase64,
|
|
390
|
+
}: {
|
|
391
|
+
frontScanBase64: string;
|
|
392
|
+
}): Promise<any> {
|
|
393
|
+
try {
|
|
394
|
+
const data = {
|
|
395
|
+
...this.bodyTaskIdGroupId,
|
|
396
|
+
data: {
|
|
397
|
+
document1: frontScanBase64,
|
|
398
|
+
},
|
|
399
|
+
};
|
|
400
|
+
const response = await this.makeRequest<any>(
|
|
401
|
+
"post",
|
|
402
|
+
this.syncIndividualGSTScanInfoEndpoint,
|
|
403
|
+
data
|
|
404
|
+
);
|
|
405
|
+
|
|
406
|
+
return response?.result;
|
|
407
|
+
} catch (error: any) {
|
|
408
|
+
if (error?.response?.data?.error) {
|
|
409
|
+
let obj = this.idfyError;
|
|
410
|
+
const errorObj = obj[error?.response?.data?.error as keyof typeof obj];
|
|
411
|
+
if (errorObj)
|
|
412
|
+
throw {
|
|
413
|
+
...this.standardErrorThrowFormat,
|
|
414
|
+
message: [errorObj.message],
|
|
415
|
+
};
|
|
416
|
+
}
|
|
417
|
+
throw error;
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
async getSyncIndividualLivenessSelfyScanInfo({
|
|
422
|
+
faceScanBase64,
|
|
423
|
+
}: {
|
|
424
|
+
faceScanBase64: string;
|
|
425
|
+
}): Promise<any> {
|
|
426
|
+
try {
|
|
427
|
+
const data = {
|
|
428
|
+
...this.bodyTaskIdGroupId,
|
|
429
|
+
data: {
|
|
430
|
+
document1: faceScanBase64,
|
|
431
|
+
consent: "yes",
|
|
432
|
+
},
|
|
433
|
+
};
|
|
434
|
+
const response = await this.makeRequest<any>(
|
|
435
|
+
"post",
|
|
436
|
+
this.syncIndividualLiveFaceLivenessEndpoint,
|
|
437
|
+
data
|
|
438
|
+
);
|
|
439
|
+
|
|
440
|
+
return response?.result;
|
|
441
|
+
} catch (error: any) {
|
|
442
|
+
if (error?.response?.data?.error) {
|
|
443
|
+
let obj = this.idfyError;
|
|
444
|
+
const errorObj = obj[error?.response?.data?.error as keyof typeof obj];
|
|
445
|
+
if (errorObj)
|
|
446
|
+
throw {
|
|
447
|
+
...this.standardErrorThrowFormat,
|
|
448
|
+
message: [errorObj.message],
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
throw error;
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
async getAsyncAadhaarLiteInfo({
|
|
456
|
+
aadhaarNo,
|
|
457
|
+
}: {
|
|
458
|
+
aadhaarNo: string;
|
|
459
|
+
}): Promise<any> {
|
|
460
|
+
try {
|
|
461
|
+
const data = {
|
|
462
|
+
...this.bodyTaskIdGroupId,
|
|
463
|
+
data: {
|
|
464
|
+
aadhaar_number: aadhaarNo,
|
|
465
|
+
},
|
|
466
|
+
};
|
|
467
|
+
const response = await this.makeRequest<any>(
|
|
468
|
+
"post",
|
|
469
|
+
this.asyncIndividualAadhaarLiteInfoEndPoint,
|
|
470
|
+
data
|
|
471
|
+
);
|
|
472
|
+
const successData = await this.pingTaskUntilSuccess(response.request_id);
|
|
473
|
+
|
|
474
|
+
return successData;
|
|
475
|
+
} catch (error: any) {
|
|
476
|
+
if (error?.response?.data?.error) {
|
|
477
|
+
let obj = this.idfyError;
|
|
478
|
+
const errorObj = obj[error?.response?.data?.error as keyof typeof obj];
|
|
479
|
+
if (errorObj)
|
|
480
|
+
throw {
|
|
481
|
+
...this.standardErrorThrowFormat,
|
|
482
|
+
message: [errorObj.message],
|
|
483
|
+
};
|
|
484
|
+
}
|
|
485
|
+
throw error;
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
async getCompanyDetailsByName({
|
|
490
|
+
legalName,
|
|
491
|
+
}: {
|
|
492
|
+
legalName: string;
|
|
493
|
+
}): Promise<any> {
|
|
494
|
+
try {
|
|
495
|
+
const data = {
|
|
496
|
+
version: this.idfyCompanySearch.version,
|
|
497
|
+
...this.bodyTaskIdGroupId,
|
|
498
|
+
data: {
|
|
499
|
+
name: legalName,
|
|
500
|
+
},
|
|
501
|
+
};
|
|
502
|
+
const response = await this.makeAxiosRequest<any>({
|
|
503
|
+
method: "post",
|
|
504
|
+
url: this.idfyCompanySearch.companySearchUrl,
|
|
505
|
+
data,
|
|
506
|
+
headers: this.idfyCompanySearch.defaultHeader,
|
|
507
|
+
});
|
|
508
|
+
const successData = await this.pingCompanySearchTaskUntilSuccess(
|
|
509
|
+
response.request_id
|
|
510
|
+
);
|
|
511
|
+
|
|
512
|
+
return { request_id: response, successData: successData };
|
|
513
|
+
} catch (error) {
|
|
514
|
+
throw error;
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
async getCompanyDetailsByLlpinOrCin({
|
|
519
|
+
cinOrLlpin,
|
|
520
|
+
}: {
|
|
521
|
+
cinOrLlpin: string;
|
|
522
|
+
}): Promise<any> {
|
|
523
|
+
try {
|
|
524
|
+
const data = {
|
|
525
|
+
version: this.idfyCompanySearch.version,
|
|
526
|
+
...this.bodyTaskIdGroupId,
|
|
527
|
+
data: {
|
|
528
|
+
cin_llpin: cinOrLlpin,
|
|
529
|
+
},
|
|
530
|
+
};
|
|
531
|
+
const response = await this.makeAxiosRequest<any>({
|
|
532
|
+
method: "post",
|
|
533
|
+
url: this.idfyCompanySearch.cinllpinUrl,
|
|
534
|
+
data,
|
|
535
|
+
headers: this.idfyCompanySearch.defaultHeader,
|
|
536
|
+
});
|
|
537
|
+
return { response: response };
|
|
538
|
+
} catch (error) {
|
|
539
|
+
throw error;
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
}
|