aeremmiddleware 1.0.47 → 1.0.49

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.
@@ -1,661 +1,715 @@
1
1
  import axios, { AxiosRequestConfig, AxiosResponse } from "axios";
2
+ import { convertToCamelCase } from "../utils/convertToCamelcase";
2
3
  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
- callbackUrl: string;
4
+ IDFY_TASK_ID: string;
5
+ IDFY_GROUP_ID: string;
6
+ IDFY_ACCOUNT_ID: string;
7
+ IDFY_API_KEY: string;
8
+ IDFY_COMPANY_SEARCH_API_KEY: string;
9
+ callbackUrl: string;
9
10
  }
10
11
  export default class IdfyAPIWrapper {
11
- private bodyTaskIdGroupId = {
12
- task_id: "",
13
- group_id: "",
14
- };
15
- private defaultHeaderIdfyApi = {
16
- "account-id": "",
17
- "api-key": "",
18
- };
19
- private standardErrorThrowFormat = {
20
- statusCode: 400,
21
- message: ["bad request"],
22
- };
23
- private baseUrl: string = "https://eve.idfy.com/";
24
- private gstVerificationEndPoint =
25
- "v3/tasks/sync/verify_with_source/ind_gst_certificate";
26
- private panIndividualVerificationEndPoint =
27
- "v3/tasks/async/verify_with_source/ind_pan_plus";
28
- private cinCompanyVerificationEndPoint =
29
- "v3/tasks/async/verify_with_source/ind_mca";
30
- private taskUrl = "v3/tasks?request_id=";
31
- private asyncIndividualAadhaarLiteInfoEndPoint =
32
- "v3/tasks/async/verify_with_source/aadhaar_lite";
33
- private syncIndividualAadharScanInfoEndpoint =
34
- "v3/tasks/sync/extract/ind_aadhaar_plus";
35
- private syncIndividualPANScanInfoEndpoint = "v3/tasks/sync/extract/ind_pan";
36
- private syncIndividualGSTScanInfoEndpoint =
37
- "v3/tasks/sync/extract/ind_gst_certificate";
38
- private syncIndividualLiveFaceLivenessEndpoint =
39
- "v3/tasks/sync/check_photo_liveness/face";
40
- private getDigilockerDetailsEndpoint =
41
- "v3/tasks/async/verify_with_source/ind_digilocker_fetch_documents";
42
- private doc_type = ["ADHAR", "PANCR"];
43
- private file_format = "xml";
44
- private callbackUrl: string;
45
-
46
- private idfyCompanySearch = {
47
- defaultHeader: {
48
- "api-key": "",
49
- "Content-Type": "application/json",
50
- },
51
- version: "v1",
52
- companySearchUrl: "https://riskai.idfystaging.com/api/v1/company/search",
53
- taskBaseUrl: "https://riskai.idfystaging.com/api/v1/task/",
54
- cinllpinUrl: "https://riskai.idfystaging.com/api/v1/company/basic",
55
- };
56
-
57
- private idfyError = {
58
- INVALID_IMAGE: {
59
- idfyErrorCode: "IDFY_ERR_100",
60
- message: "Please scan correct document",
61
- },
62
- INSUFFICIENT_CREDITS: {
63
- idfyErrorCode: "IDFY_ERR_101",
64
- message: "Please renew credit",
65
- },
66
- };
67
-
68
- constructor({
69
- IDFY_TASK_ID,
70
- IDFY_GROUP_ID,
71
- IDFY_ACCOUNT_ID,
72
- IDFY_API_KEY,
73
- IDFY_COMPANY_SEARCH_API_KEY,
74
- callbackUrl,
75
- }: ObjectTypes) {
76
- this.bodyTaskIdGroupId.task_id = IDFY_TASK_ID;
77
- this.bodyTaskIdGroupId.group_id = IDFY_GROUP_ID;
78
- this.defaultHeaderIdfyApi["account-id"] = IDFY_ACCOUNT_ID;
79
- this.defaultHeaderIdfyApi["api-key"] = IDFY_API_KEY;
80
- this.idfyCompanySearch.defaultHeader["api-key"] =
81
- IDFY_COMPANY_SEARCH_API_KEY;
82
- this.callbackUrl = callbackUrl;
83
- }
84
-
85
- private async makeRequest<T>(
86
- method: string,
87
- endpoint: string,
88
- data?: any
89
- ): Promise<T> {
90
- const requestConfig: AxiosRequestConfig = {
91
- method,
92
- url: this.baseUrl + endpoint,
93
- headers: this.defaultHeaderIdfyApi,
94
- data,
12
+ private bodyTaskIdGroupId = {
13
+ task_id: "",
14
+ group_id: "",
15
+ };
16
+ private defaultHeaderIdfyApi = {
17
+ "account-id": "",
18
+ "api-key": "",
19
+ };
20
+ private standardErrorThrowFormat = {
21
+ statusCode: 400,
22
+ message: ["bad request"],
23
+ };
24
+ private baseUrl: string = "https://eve.idfy.com/";
25
+ private gstVerificationEndPoint =
26
+ "v3/tasks/sync/verify_with_source/ind_gst_certificate";
27
+ private panIndividualVerificationEndPoint =
28
+ "v3/tasks/async/verify_with_source/ind_pan_plus";
29
+ private cinCompanyVerificationEndPoint =
30
+ "v3/tasks/async/verify_with_source/ind_mca";
31
+ private taskUrl = "v3/tasks?request_id=";
32
+ private asyncIndividualAadhaarLiteInfoEndPoint =
33
+ "v3/tasks/async/verify_with_source/aadhaar_lite";
34
+ private syncIndividualAadharScanInfoEndpoint =
35
+ "v3/tasks/sync/extract/ind_aadhaar_plus";
36
+ private syncIndividualPANScanInfoEndpoint = "v3/tasks/sync/extract/ind_pan";
37
+ private syncIndividualGSTScanInfoEndpoint =
38
+ "v3/tasks/sync/extract/ind_gst_certificate";
39
+ private syncIndividualLiveFaceLivenessEndpoint =
40
+ "v3/tasks/sync/check_photo_liveness/face";
41
+ private getDigilockerDetailsEndpoint =
42
+ "v3/tasks/async/verify_with_source/ind_digilocker_fetch_documents";
43
+ private getUdhyamEndpoint =
44
+ "v3/tasks/async/verify_with_source/udyam_aadhaar";
45
+ private doc_type = ["ADHAR", "PANCR"];
46
+ private file_format = "xml";
47
+ private callbackUrl: string;
48
+
49
+ private idfyCompanySearch = {
50
+ defaultHeader: {
51
+ "api-key": "",
52
+ "Content-Type": "application/json",
53
+ },
54
+ version: "v1",
55
+ companySearchUrl:
56
+ "https://riskai.idfystaging.com/api/v1/company/search",
57
+ taskBaseUrl: "https://riskai.idfystaging.com/api/v1/task/",
58
+ cinllpinUrl: "https://riskai.idfystaging.com/api/v1/company/basic",
95
59
  };
96
60
 
97
- try {
98
- const response: AxiosResponse<T> = await axios(requestConfig);
99
- return response.data;
100
- } catch (error) {
101
- console.error("Error while making Idfy Axios API request:", error);
102
- throw error;
103
- }
104
- }
105
-
106
- private async makeAxiosRequest<T>({
107
- method,
108
- url,
109
- data,
110
- headers,
111
- }: {
112
- method: string;
113
- url: string;
114
- data?: any;
115
- headers: any;
116
- }): Promise<T> {
117
- const requestConfig: AxiosRequestConfig = {
118
- method,
119
- url,
120
- headers,
121
- data,
61
+ private idfyError = {
62
+ INVALID_IMAGE: {
63
+ idfyErrorCode: "IDFY_ERR_100",
64
+ message: "Please scan correct document",
65
+ },
66
+ INSUFFICIENT_CREDITS: {
67
+ idfyErrorCode: "IDFY_ERR_101",
68
+ message: "Please renew credit",
69
+ },
122
70
  };
123
71
 
124
- try {
125
- const response: AxiosResponse<T> = await axios(requestConfig);
126
- return response.data;
127
- } catch (error) {
128
- console.error(
129
- "Error while making Idfy makeAxiosRequest API request:",
130
- error
131
- );
132
- throw error;
72
+ constructor({
73
+ IDFY_TASK_ID,
74
+ IDFY_GROUP_ID,
75
+ IDFY_ACCOUNT_ID,
76
+ IDFY_API_KEY,
77
+ IDFY_COMPANY_SEARCH_API_KEY,
78
+ callbackUrl,
79
+ }: ObjectTypes) {
80
+ this.bodyTaskIdGroupId.task_id = IDFY_TASK_ID;
81
+ this.bodyTaskIdGroupId.group_id = IDFY_GROUP_ID;
82
+ this.defaultHeaderIdfyApi["account-id"] = IDFY_ACCOUNT_ID;
83
+ this.defaultHeaderIdfyApi["api-key"] = IDFY_API_KEY;
84
+ this.idfyCompanySearch.defaultHeader["api-key"] =
85
+ IDFY_COMPANY_SEARCH_API_KEY;
86
+ this.callbackUrl = callbackUrl;
133
87
  }
134
- }
135
-
136
- private async getTask(requestId: string): Promise<any> {
137
- try {
138
- // const data = {}
139
- const urlEndPoint = this.taskUrl + requestId;
140
- const response = await this.makeRequest<any>("get", urlEndPoint);
141
- return response;
142
- } catch (error) {
143
- console.error("Error while fetching Idfy getTask API data:", error);
144
- throw error;
88
+
89
+ private async makeRequest<T>(
90
+ method: string,
91
+ endpoint: string,
92
+ data?: any
93
+ ): Promise<T> {
94
+ const requestConfig: AxiosRequestConfig = {
95
+ method,
96
+ url: this.baseUrl + endpoint,
97
+ headers: this.defaultHeaderIdfyApi,
98
+ data,
99
+ };
100
+
101
+ try {
102
+ const response: AxiosResponse<T> = await axios(requestConfig);
103
+ return response.data;
104
+ } catch (error) {
105
+ console.error("Error while making Idfy Axios API request:", error);
106
+ throw error;
107
+ }
145
108
  }
146
- }
147
-
148
- private async getCompanySearchTask({
149
- requestId,
150
- }: {
151
- requestId: string;
152
- }): Promise<any> {
153
- try {
154
- const taskBaseUrl = this.idfyCompanySearch.taskBaseUrl + requestId;
155
- const response = await this.makeAxiosRequest({
156
- method: "get",
157
- url: taskBaseUrl,
158
- headers: this.idfyCompanySearch.defaultHeader,
159
- });
160
- return response;
161
- } catch (error) {
162
- console.error(
163
- "Error while fetching Idfy getCompanySearchTask API data:",
164
- error
165
- );
166
- throw error;
109
+
110
+ private async makeAxiosRequest<T>({
111
+ method,
112
+ url,
113
+ data,
114
+ headers,
115
+ }: {
116
+ method: string;
117
+ url: string;
118
+ data?: any;
119
+ headers: any;
120
+ }): Promise<T> {
121
+ const requestConfig: AxiosRequestConfig = {
122
+ method,
123
+ url,
124
+ headers,
125
+ data,
126
+ };
127
+
128
+ try {
129
+ const response: AxiosResponse<T> = await axios(requestConfig);
130
+ return response.data;
131
+ } catch (error) {
132
+ console.error(
133
+ "Error while making Idfy makeAxiosRequest API request:",
134
+ error
135
+ );
136
+ throw error;
137
+ }
167
138
  }
168
- }
169
-
170
- private async pingTaskUntilSuccess(requestId: string): Promise<any> {
171
- try {
172
- let res: any = null;
173
- const checkTaskAfter1sec = (requestId: any) => {
174
- return new Promise<any>((resolve, reject) => {
175
- try {
176
- setTimeout(async () => {
177
- const data = await this.getTask(requestId);
178
- if (res?.[0].status == "failed") {
179
- reject(res);
180
- }
181
- resolve(data);
182
- }, 1000);
183
- } catch (e) {
184
- reject(e);
185
- }
186
- });
187
- };
188
- do {
189
- res = await checkTaskAfter1sec(requestId);
190
-
191
- console.log("### res ", res);
192
- } while (res?.[0].status !== "completed");
193
-
194
- return res;
195
- } catch (error) {
196
- console.error("Error while fetching Idfy getTask API data:", error);
197
- throw error;
139
+
140
+ private async getTask(requestId: string): Promise<any> {
141
+ try {
142
+ // const data = {}
143
+ const urlEndPoint = this.taskUrl + requestId;
144
+ const response = await this.makeRequest<any>("get", urlEndPoint);
145
+ return response;
146
+ } catch (error) {
147
+ console.error("Error while fetching Idfy getTask API data:", error);
148
+ throw error;
149
+ }
198
150
  }
199
- }
200
-
201
- private async pingCompanySearchTaskUntilSuccess(
202
- requestId: string
203
- ): Promise<any> {
204
- try {
205
- console.log(" ## requestId ", requestId);
206
- let res: any = null;
207
- const checkTaskAfter1sec = (requestId: string) => {
208
- return new Promise<any>((resolve, reject) => {
209
- try {
210
- setTimeout(async () => {
211
- const data = await this.getCompanySearchTask({ requestId });
212
- if (data.status != "failed") {
213
- resolve(data);
214
- } else {
215
- reject(res);
216
- }
217
- }, 1000);
218
- } catch (e) {
219
- reject(e);
220
- }
221
- });
222
- };
223
- do {
224
- res = await checkTaskAfter1sec(requestId);
225
- console.log("### res ", res);
226
- } while (res?.status !== "completed");
227
-
228
- return res;
229
- } catch (error) {
230
- console.error("Error while fetching Idfy getTask API data:", error);
231
- throw error;
151
+
152
+ private async getCompanySearchTask({
153
+ requestId,
154
+ }: {
155
+ requestId: string;
156
+ }): Promise<any> {
157
+ try {
158
+ const taskBaseUrl = this.idfyCompanySearch.taskBaseUrl + requestId;
159
+ const response = await this.makeAxiosRequest({
160
+ method: "get",
161
+ url: taskBaseUrl,
162
+ headers: this.idfyCompanySearch.defaultHeader,
163
+ });
164
+ return response;
165
+ } catch (error) {
166
+ console.error(
167
+ "Error while fetching Idfy getCompanySearchTask API data:",
168
+ error
169
+ );
170
+ throw error;
171
+ }
232
172
  }
233
- }
234
- async getCompanyGstInfo({ gstNo }: { gstNo: string }): Promise<any> {
235
- try {
236
- const data = {
237
- ...this.bodyTaskIdGroupId,
238
- data: {
239
- gstin: gstNo,
240
- },
241
- };
242
- const response = await this.makeRequest<any>(
243
- "post",
244
- this.gstVerificationEndPoint,
245
- data
246
- );
247
- return response;
248
- } catch (error: any) {
249
- if (error?.response?.data?.error) {
250
- let obj = this.idfyError;
251
- const errorObj = obj[error?.response?.data?.error as keyof typeof obj];
252
- if (errorObj)
253
- throw {
254
- ...this.standardErrorThrowFormat,
255
- message: [errorObj.message],
256
- };
257
- }
258
-
259
- throw error;
173
+
174
+ private async pingTaskUntilSuccess(requestId: string): Promise<any> {
175
+ try {
176
+ let res: any = null;
177
+ const checkTaskAfter1sec = (requestId: any) => {
178
+ return new Promise<any>((resolve, reject) => {
179
+ try {
180
+ setTimeout(async () => {
181
+ const data = await this.getTask(requestId);
182
+ if (res?.[0].status == "failed") {
183
+ reject(res);
184
+ }
185
+ resolve(data);
186
+ }, 1000);
187
+ } catch (e) {
188
+ reject(e);
189
+ }
190
+ });
191
+ };
192
+ do {
193
+ res = await checkTaskAfter1sec(requestId);
194
+
195
+ console.log("### res ", res);
196
+ } while (res?.[0].status !== "completed");
197
+
198
+ return res;
199
+ } catch (error) {
200
+ console.error("Error while fetching Idfy getTask API data:", error);
201
+ throw error;
202
+ }
260
203
  }
261
- }
262
- async getCompanyCINInfo({ cinNo }: { cinNo: string }): Promise<any> {
263
- try {
264
- const data = {
265
- ...this.bodyTaskIdGroupId,
266
- data: {
267
- cin: cinNo,
268
- },
269
- };
270
- const response = await this.makeRequest<any>(
271
- "post",
272
- this.cinCompanyVerificationEndPoint,
273
- data
274
- );
275
- const successData = await this.pingTaskUntilSuccess(response.request_id);
276
-
277
- return successData?.[0]?.result?.source_output;
278
- } catch (error: any) {
279
- if (error?.response?.data?.error) {
280
- let obj = this.idfyError;
281
- const errorObj = obj[error?.response?.data?.error as keyof typeof obj];
282
- if (errorObj)
283
- throw {
284
- ...this.standardErrorThrowFormat,
285
- message: [errorObj.message],
286
- };
287
- }
288
- throw error;
204
+
205
+ private async pingCompanySearchTaskUntilSuccess(
206
+ requestId: string
207
+ ): Promise<any> {
208
+ try {
209
+ console.log(" ## requestId ", requestId);
210
+ let res: any = null;
211
+ const checkTaskAfter1sec = (requestId: string) => {
212
+ return new Promise<any>((resolve, reject) => {
213
+ try {
214
+ setTimeout(async () => {
215
+ const data = await this.getCompanySearchTask({
216
+ requestId,
217
+ });
218
+ if (data.status != "failed") {
219
+ resolve(data);
220
+ } else {
221
+ reject(res);
222
+ }
223
+ }, 1000);
224
+ } catch (e) {
225
+ reject(e);
226
+ }
227
+ });
228
+ };
229
+ do {
230
+ res = await checkTaskAfter1sec(requestId);
231
+ console.log("### res ", res);
232
+ } while (res?.status !== "completed");
233
+
234
+ return res;
235
+ } catch (error) {
236
+ console.error("Error while fetching Idfy getTask API data:", error);
237
+ throw error;
238
+ }
289
239
  }
290
- }
291
- async getIndividualPANInfo({ panNo }: { panNo: string }): Promise<any> {
292
- try {
293
- const data = {
294
- ...this.bodyTaskIdGroupId,
295
- data: {
296
- id_number: panNo,
297
- },
298
- };
299
- const response = await this.makeRequest<any>(
300
- "post",
301
- this.panIndividualVerificationEndPoint,
302
- data
303
- );
304
- const successData = await this.pingTaskUntilSuccess(response.request_id);
305
-
306
- return successData;
307
- } catch (error: any) {
308
- if (error?.response?.data?.error) {
309
- let obj = this.idfyError;
310
- const errorObj = obj[error?.response?.data?.error as keyof typeof obj];
311
- if (errorObj)
312
- throw {
313
- ...this.standardErrorThrowFormat,
314
- message: [errorObj.message],
315
- };
316
- }
317
- throw error;
240
+ async getCompanyGstInfo({ gstNo }: { gstNo: string }): Promise<any> {
241
+ try {
242
+ const data = {
243
+ ...this.bodyTaskIdGroupId,
244
+ data: {
245
+ gstin: gstNo,
246
+ },
247
+ };
248
+ const response = await this.makeRequest<any>(
249
+ "post",
250
+ this.gstVerificationEndPoint,
251
+ data
252
+ );
253
+ return response;
254
+ } catch (error: any) {
255
+ if (error?.response?.data?.error) {
256
+ let obj = this.idfyError;
257
+ const errorObj =
258
+ obj[error?.response?.data?.error as keyof typeof obj];
259
+ if (errorObj)
260
+ throw {
261
+ ...this.standardErrorThrowFormat,
262
+ message: [errorObj.message],
263
+ };
264
+ }
265
+
266
+ throw error;
267
+ }
318
268
  }
319
- }
320
-
321
- async getSyncIndividualAadharScanInfo({
322
- frontScanBase64,
323
- backScanBase64,
324
- }: {
325
- frontScanBase64: string;
326
- backScanBase64: string;
327
- }): Promise<any> {
328
- try {
329
- const data = {
330
- ...this.bodyTaskIdGroupId,
331
- data: {
332
- document1: frontScanBase64,
333
- document2: backScanBase64,
334
- consent: "yes",
335
- advanced_details: {
336
- extract_qr_info: true,
337
- extract_last_4_digit: false,
338
- },
339
- },
340
- };
341
- const response = await this.makeRequest<any>(
342
- "post",
343
- this.syncIndividualAadharScanInfoEndpoint,
344
- data
345
- );
346
-
347
- return response?.result;
348
- } catch (error: any) {
349
- if (error?.response?.data?.error) {
350
- let obj = this.idfyError;
351
- const errorObj = obj[error?.response?.data?.error as keyof typeof obj];
352
- if (errorObj)
353
- throw {
354
- ...this.standardErrorThrowFormat,
355
- message: [errorObj.message],
356
- };
357
- }
358
- throw error;
269
+ async getCompanyCINInfo({ cinNo }: { cinNo: string }): Promise<any> {
270
+ try {
271
+ const data = {
272
+ ...this.bodyTaskIdGroupId,
273
+ data: {
274
+ cin: cinNo,
275
+ },
276
+ };
277
+ const response = await this.makeRequest<any>(
278
+ "post",
279
+ this.cinCompanyVerificationEndPoint,
280
+ data
281
+ );
282
+ const successData = await this.pingTaskUntilSuccess(
283
+ response.request_id
284
+ );
285
+
286
+ return successData?.[0]?.result?.source_output;
287
+ } catch (error: any) {
288
+ if (error?.response?.data?.error) {
289
+ let obj = this.idfyError;
290
+ const errorObj =
291
+ obj[error?.response?.data?.error as keyof typeof obj];
292
+ if (errorObj)
293
+ throw {
294
+ ...this.standardErrorThrowFormat,
295
+ message: [errorObj.message],
296
+ };
297
+ }
298
+ throw error;
299
+ }
359
300
  }
360
- }
361
-
362
- async getSyncIndividualPANScanInfo({
363
- frontScanBase64,
364
- }: {
365
- frontScanBase64: string;
366
- }): Promise<any> {
367
- try {
368
- const data = {
369
- ...this.bodyTaskIdGroupId,
370
- data: {
371
- document1: frontScanBase64,
372
- consent: "yes",
373
- },
374
- };
375
- const response = await this.makeRequest<any>(
376
- "post",
377
- this.syncIndividualPANScanInfoEndpoint,
378
- data
379
- );
380
-
381
- return response?.result;
382
- } catch (error: any) {
383
- if (error?.response?.data?.error) {
384
- let obj = this.idfyError;
385
- const errorObj = obj[error?.response?.data?.error as keyof typeof obj];
386
- if (errorObj)
387
- throw {
388
- ...this.standardErrorThrowFormat,
389
- message: [errorObj.message],
390
- };
391
- }
392
- throw error;
301
+ async getIndividualPANInfo({ panNo }: { panNo: string }): Promise<any> {
302
+ try {
303
+ const data = {
304
+ ...this.bodyTaskIdGroupId,
305
+ data: {
306
+ id_number: panNo,
307
+ },
308
+ };
309
+ const response = await this.makeRequest<any>(
310
+ "post",
311
+ this.panIndividualVerificationEndPoint,
312
+ data
313
+ );
314
+ const successData = await this.pingTaskUntilSuccess(
315
+ response.request_id
316
+ );
317
+
318
+ return successData;
319
+ } catch (error: any) {
320
+ if (error?.response?.data?.error) {
321
+ let obj = this.idfyError;
322
+ const errorObj =
323
+ obj[error?.response?.data?.error as keyof typeof obj];
324
+ if (errorObj)
325
+ throw {
326
+ ...this.standardErrorThrowFormat,
327
+ message: [errorObj.message],
328
+ };
329
+ }
330
+ throw error;
331
+ }
393
332
  }
394
- }
395
-
396
- async getSyncCompanyGSTScanInfo({
397
- frontScanBase64,
398
- }: {
399
- frontScanBase64: string;
400
- }): Promise<any> {
401
- try {
402
- const data = {
403
- ...this.bodyTaskIdGroupId,
404
- data: {
405
- document1: frontScanBase64,
406
- },
407
- };
408
- const response = await this.makeRequest<any>(
409
- "post",
410
- this.syncIndividualGSTScanInfoEndpoint,
411
- data
412
- );
413
-
414
- return response?.result;
415
- } catch (error: any) {
416
- if (error?.response?.data?.error) {
417
- let obj = this.idfyError;
418
- const errorObj = obj[error?.response?.data?.error as keyof typeof obj];
419
- if (errorObj)
420
- throw {
421
- ...this.standardErrorThrowFormat,
422
- message: [errorObj.message],
423
- };
424
- }
425
- throw error;
333
+
334
+ async getSyncIndividualAadharScanInfo({
335
+ frontScanBase64,
336
+ backScanBase64,
337
+ }: {
338
+ frontScanBase64: string;
339
+ backScanBase64: string;
340
+ }): Promise<any> {
341
+ try {
342
+ const data = {
343
+ ...this.bodyTaskIdGroupId,
344
+ data: {
345
+ document1: frontScanBase64,
346
+ document2: backScanBase64,
347
+ consent: "yes",
348
+ advanced_details: {
349
+ extract_qr_info: true,
350
+ extract_last_4_digit: false,
351
+ },
352
+ },
353
+ };
354
+ const response = await this.makeRequest<any>(
355
+ "post",
356
+ this.syncIndividualAadharScanInfoEndpoint,
357
+ data
358
+ );
359
+
360
+ return response?.result;
361
+ } catch (error: any) {
362
+ if (error?.response?.data?.error) {
363
+ let obj = this.idfyError;
364
+ const errorObj =
365
+ obj[error?.response?.data?.error as keyof typeof obj];
366
+ if (errorObj)
367
+ throw {
368
+ ...this.standardErrorThrowFormat,
369
+ message: [errorObj.message],
370
+ };
371
+ }
372
+ throw error;
373
+ }
426
374
  }
427
- }
428
-
429
- async getSyncIndividualLivenessSelfyScanInfo({
430
- faceScanBase64,
431
- }: {
432
- faceScanBase64: string;
433
- }): Promise<any> {
434
- try {
435
- const data = {
436
- ...this.bodyTaskIdGroupId,
437
- data: {
438
- document1: faceScanBase64,
439
- consent: "yes",
440
- },
441
- };
442
- const response = await this.makeRequest<any>(
443
- "post",
444
- this.syncIndividualLiveFaceLivenessEndpoint,
445
- data
446
- );
447
-
448
- return response?.result;
449
- } catch (error: any) {
450
- if (error?.response?.data?.error) {
451
- let obj = this.idfyError;
452
- const errorObj = obj[error?.response?.data?.error as keyof typeof obj];
453
- if (errorObj)
454
- throw {
455
- ...this.standardErrorThrowFormat,
456
- message: [errorObj.message],
457
- };
458
- }
459
- throw error;
375
+
376
+ async getSyncIndividualPANScanInfo({
377
+ frontScanBase64,
378
+ }: {
379
+ frontScanBase64: string;
380
+ }): Promise<any> {
381
+ try {
382
+ const data = {
383
+ ...this.bodyTaskIdGroupId,
384
+ data: {
385
+ document1: frontScanBase64,
386
+ consent: "yes",
387
+ },
388
+ };
389
+ const response = await this.makeRequest<any>(
390
+ "post",
391
+ this.syncIndividualPANScanInfoEndpoint,
392
+ data
393
+ );
394
+
395
+ return response?.result;
396
+ } catch (error: any) {
397
+ if (error?.response?.data?.error) {
398
+ let obj = this.idfyError;
399
+ const errorObj =
400
+ obj[error?.response?.data?.error as keyof typeof obj];
401
+ if (errorObj)
402
+ throw {
403
+ ...this.standardErrorThrowFormat,
404
+ message: [errorObj.message],
405
+ };
406
+ }
407
+ throw error;
408
+ }
460
409
  }
461
- }
462
-
463
- async getAsyncAadhaarLiteInfo({
464
- aadhaarNo,
465
- }: {
466
- aadhaarNo: string;
467
- }): Promise<any> {
468
- try {
469
- const data = {
470
- ...this.bodyTaskIdGroupId,
471
- data: {
472
- aadhaar_number: aadhaarNo,
473
- },
474
- };
475
- const response = await this.makeRequest<any>(
476
- "post",
477
- this.asyncIndividualAadhaarLiteInfoEndPoint,
478
- data
479
- );
480
- const successData = await this.pingTaskUntilSuccess(response.request_id);
481
-
482
- return successData;
483
- } catch (error: any) {
484
- if (error?.response?.data?.error) {
485
- let obj = this.idfyError;
486
- const errorObj = obj[error?.response?.data?.error as keyof typeof obj];
487
- if (errorObj)
488
- throw {
489
- ...this.standardErrorThrowFormat,
490
- message: [errorObj.message],
491
- };
492
- }
493
- throw error;
410
+
411
+ async getSyncCompanyGSTScanInfo({
412
+ frontScanBase64,
413
+ }: {
414
+ frontScanBase64: string;
415
+ }): Promise<any> {
416
+ try {
417
+ const data = {
418
+ ...this.bodyTaskIdGroupId,
419
+ data: {
420
+ document1: frontScanBase64,
421
+ },
422
+ };
423
+ const response = await this.makeRequest<any>(
424
+ "post",
425
+ this.syncIndividualGSTScanInfoEndpoint,
426
+ data
427
+ );
428
+
429
+ return response?.result;
430
+ } catch (error: any) {
431
+ if (error?.response?.data?.error) {
432
+ let obj = this.idfyError;
433
+ const errorObj =
434
+ obj[error?.response?.data?.error as keyof typeof obj];
435
+ if (errorObj)
436
+ throw {
437
+ ...this.standardErrorThrowFormat,
438
+ message: [errorObj.message],
439
+ };
440
+ }
441
+ throw error;
442
+ }
494
443
  }
495
- }
496
-
497
- async getCompanyDetailsByName({
498
- legalName,
499
- }: {
500
- legalName: string;
501
- }): Promise<any> {
502
- try {
503
- const data = {
504
- version: this.idfyCompanySearch.version,
505
- ...this.bodyTaskIdGroupId,
506
- data: {
507
- name: legalName,
508
- },
509
- };
510
- const response = await this.makeAxiosRequest<any>({
511
- method: "post",
512
- url: this.idfyCompanySearch.companySearchUrl,
513
- data,
514
- headers: this.idfyCompanySearch.defaultHeader,
515
- });
516
- const successData = await this.pingCompanySearchTaskUntilSuccess(
517
- response.request_id
518
- );
519
-
520
- return { request_id: response, successData: successData };
521
- } catch (error) {
522
- throw error;
444
+
445
+ async getSyncIndividualLivenessSelfyScanInfo({
446
+ faceScanBase64,
447
+ }: {
448
+ faceScanBase64: string;
449
+ }): Promise<any> {
450
+ try {
451
+ const data = {
452
+ ...this.bodyTaskIdGroupId,
453
+ data: {
454
+ document1: faceScanBase64,
455
+ consent: "yes",
456
+ },
457
+ };
458
+ const response = await this.makeRequest<any>(
459
+ "post",
460
+ this.syncIndividualLiveFaceLivenessEndpoint,
461
+ data
462
+ );
463
+
464
+ return response?.result;
465
+ } catch (error: any) {
466
+ if (error?.response?.data?.error) {
467
+ let obj = this.idfyError;
468
+ const errorObj =
469
+ obj[error?.response?.data?.error as keyof typeof obj];
470
+ if (errorObj)
471
+ throw {
472
+ ...this.standardErrorThrowFormat,
473
+ message: [errorObj.message],
474
+ };
475
+ }
476
+ throw error;
477
+ }
523
478
  }
524
- }
525
-
526
- async getCompanyDetailsByLlpinOrCin({
527
- cinOrLlpin,
528
- }: {
529
- cinOrLlpin: string;
530
- }): Promise<any> {
531
- try {
532
- const data = {
533
- version: this.idfyCompanySearch.version,
534
- ...this.bodyTaskIdGroupId,
535
- data: {
536
- cin_llpin: cinOrLlpin,
537
- },
538
- };
539
- const response = await this.makeAxiosRequest<any>({
540
- method: "post",
541
- url: this.idfyCompanySearch.cinllpinUrl,
542
- data,
543
- headers: this.idfyCompanySearch.defaultHeader,
544
- });
545
- return { response: response };
546
- } catch (error) {
547
- throw error;
479
+
480
+ async getAsyncAadhaarLiteInfo({
481
+ aadhaarNo,
482
+ }: {
483
+ aadhaarNo: string;
484
+ }): Promise<any> {
485
+ try {
486
+ const data = {
487
+ ...this.bodyTaskIdGroupId,
488
+ data: {
489
+ aadhaar_number: aadhaarNo,
490
+ },
491
+ };
492
+ const response = await this.makeRequest<any>(
493
+ "post",
494
+ this.asyncIndividualAadhaarLiteInfoEndPoint,
495
+ data
496
+ );
497
+ const successData = await this.pingTaskUntilSuccess(
498
+ response.request_id
499
+ );
500
+
501
+ return successData;
502
+ } catch (error: any) {
503
+ if (error?.response?.data?.error) {
504
+ let obj = this.idfyError;
505
+ const errorObj =
506
+ obj[error?.response?.data?.error as keyof typeof obj];
507
+ if (errorObj)
508
+ throw {
509
+ ...this.standardErrorThrowFormat,
510
+ message: [errorObj.message],
511
+ };
512
+ }
513
+ throw error;
514
+ }
548
515
  }
549
- }
550
-
551
- async getAsyncFaceComparisionInfo({
552
- document1,
553
- document2,
554
- }: {
555
- document1: string;
556
- document2: string;
557
- }): Promise<any> {
558
- try {
559
- const data = {
560
- task_id: "74f4c926-250c-43hca-9c53-453e87ceacd1",
561
- group_id: "8e16424a-58fc-4ba4-ab20-5bc8e7c3c41e",
562
- data: {
563
- document1: document1,
564
- document2: document2,
565
- consent: "yes",
566
- },
567
- };
568
- const res = await this.makeRequest<any>(
569
- "post",
570
- "v3/tasks/async/compare/face",
571
- data
572
- );
573
- const requestId = res.request_id;
574
- const response = (await this.pingTaskUntilSuccess(requestId))?.[0];
575
- if (response.result) {
576
- return {
577
- isMatch: response.result.is_a_match,
578
- matchScore: response.result.match_score,
579
- };
580
- } else {
581
- return response;
582
- }
583
- } catch (error: any) {
584
- if (error?.response?.data?.error) {
585
- let obj = this.idfyError;
586
- const errorObj = obj[error?.response?.data?.error as keyof typeof obj];
587
- if (errorObj)
588
- throw {
589
- ...this.standardErrorThrowFormat,
590
- message: [errorObj.message],
591
- };
592
- }
593
- throw error;
516
+
517
+ async getCompanyDetailsByName({
518
+ legalName,
519
+ }: {
520
+ legalName: string;
521
+ }): Promise<any> {
522
+ try {
523
+ const data = {
524
+ version: this.idfyCompanySearch.version,
525
+ ...this.bodyTaskIdGroupId,
526
+ data: {
527
+ name: legalName,
528
+ },
529
+ };
530
+ const response = await this.makeAxiosRequest<any>({
531
+ method: "post",
532
+ url: this.idfyCompanySearch.companySearchUrl,
533
+ data,
534
+ headers: this.idfyCompanySearch.defaultHeader,
535
+ });
536
+ const successData = await this.pingCompanySearchTaskUntilSuccess(
537
+ response.request_id
538
+ );
539
+
540
+ return { request_id: response, successData: successData };
541
+ } catch (error) {
542
+ throw error;
543
+ }
594
544
  }
595
- }
596
-
597
- async getAsyncDigilockerFetchDocument({
598
- referenceId,
599
- extraFields,
600
- keyId,
601
- ouId,
602
- secret,
603
- }: {
604
- referenceId: string;
605
- extraFields: {
606
- panno: string;
607
- PANFullName: string;
608
- };
609
- keyId: string;
610
- ouId: string;
611
- secret: string;
612
- }): Promise<any> {
613
- try {
614
- console.log("key_id", keyId);
615
- console.log("ou_id", ouId);
616
- console.log("secret", secret);
617
- const datas = {
618
- task_id: "74f4c926-250c-43hca-9c53-453e87ceacd1",
619
- group_id: "8e16424a-58fc-4ba4-ab20-5bc8e7c3c41e",
620
- data: {
621
- reference_id: referenceId,
622
- key_id: keyId,
623
- ou_id: ouId,
624
- secret: secret,
625
- callback_url: this.callbackUrl,
626
- doc_type: this.doc_type,
627
- file_format: this.file_format,
628
- extra_fields: extraFields,
629
- },
630
- };
631
- const res = await this.makeRequest<any>(
632
- "post",
633
- this.getDigilockerDetailsEndpoint,
634
- datas
635
- );
636
- const requestId = res.request_id;
637
- const response = (await this.pingTaskUntilSuccess(requestId))?.[0];
638
- if (response.result.source_output) {
639
- return {
640
- redirectUrl: response.result.source_output.redirect_url,
641
- referenceId: response.result.source_output.reference_id,
642
- sessionExists: response.result.source_output.session_exists,
643
- status: response.result.source_output.status,
545
+
546
+ async getCompanyDetailsByLlpinOrCin({
547
+ cinOrLlpin,
548
+ }: {
549
+ cinOrLlpin: string;
550
+ }): Promise<any> {
551
+ try {
552
+ const data = {
553
+ version: this.idfyCompanySearch.version,
554
+ ...this.bodyTaskIdGroupId,
555
+ data: {
556
+ cin_llpin: cinOrLlpin,
557
+ },
558
+ };
559
+ const response = await this.makeAxiosRequest<any>({
560
+ method: "post",
561
+ url: this.idfyCompanySearch.cinllpinUrl,
562
+ data,
563
+ headers: this.idfyCompanySearch.defaultHeader,
564
+ });
565
+ return { response: response };
566
+ } catch (error) {
567
+ throw error;
568
+ }
569
+ }
570
+
571
+ async getAsyncFaceComparisionInfo({
572
+ document1,
573
+ document2,
574
+ }: {
575
+ document1: string;
576
+ document2: string;
577
+ }): Promise<any> {
578
+ try {
579
+ const data = {
580
+ task_id: "74f4c926-250c-43hca-9c53-453e87ceacd1",
581
+ group_id: "8e16424a-58fc-4ba4-ab20-5bc8e7c3c41e",
582
+ data: {
583
+ document1: document1,
584
+ document2: document2,
585
+ consent: "yes",
586
+ },
587
+ };
588
+ const res = await this.makeRequest<any>(
589
+ "post",
590
+ "v3/tasks/async/compare/face",
591
+ data
592
+ );
593
+ const requestId = res.request_id;
594
+ const response = (await this.pingTaskUntilSuccess(requestId))?.[0];
595
+ if (response.result) {
596
+ return {
597
+ isMatch: response.result.is_a_match,
598
+ matchScore: response.result.match_score,
599
+ };
600
+ } else {
601
+ return response;
602
+ }
603
+ } catch (error: any) {
604
+ if (error?.response?.data?.error) {
605
+ let obj = this.idfyError;
606
+ const errorObj =
607
+ obj[error?.response?.data?.error as keyof typeof obj];
608
+ if (errorObj)
609
+ throw {
610
+ ...this.standardErrorThrowFormat,
611
+ message: [errorObj.message],
612
+ };
613
+ }
614
+ throw error;
615
+ }
616
+ }
617
+
618
+ async getAsyncDigilockerFetchDocument({
619
+ referenceId,
620
+ extraFields,
621
+ keyId,
622
+ ouId,
623
+ secret,
624
+ }: {
625
+ referenceId: string;
626
+ extraFields: {
627
+ panno: string;
628
+ PANFullName: string;
644
629
  };
645
- } else {
646
- return response;
647
- }
648
- } catch (error: any) {
649
- if (error?.response?.data?.error) {
650
- let obj = this.idfyError;
651
- const errorObj = obj[error?.response?.data?.error as keyof typeof obj];
652
- if (errorObj)
653
- throw {
654
- ...this.standardErrorThrowFormat,
655
- message: [errorObj.message],
656
- };
657
- }
658
- throw error;
630
+ keyId: string;
631
+ ouId: string;
632
+ secret: string;
633
+ }): Promise<any> {
634
+ try {
635
+ console.log("key_id", keyId);
636
+ console.log("ou_id", ouId);
637
+ console.log("secret", secret);
638
+ const datas = {
639
+ task_id: "74f4c926-250c-43hca-9c53-453e87ceacd1",
640
+ group_id: "8e16424a-58fc-4ba4-ab20-5bc8e7c3c41e",
641
+ data: {
642
+ reference_id: referenceId,
643
+ key_id: keyId,
644
+ ou_id: ouId,
645
+ secret: secret,
646
+ callback_url: this.callbackUrl,
647
+ doc_type: this.doc_type,
648
+ file_format: this.file_format,
649
+ extra_fields: extraFields,
650
+ },
651
+ };
652
+ const res = await this.makeRequest<any>(
653
+ "post",
654
+ this.getDigilockerDetailsEndpoint,
655
+ datas
656
+ );
657
+ const requestId = res.request_id;
658
+ const response = (await this.pingTaskUntilSuccess(requestId))?.[0];
659
+ if (response.result.source_output) {
660
+ return {
661
+ redirectUrl: response.result.source_output.redirect_url,
662
+ referenceId: response.result.source_output.reference_id,
663
+ sessionExists: response.result.source_output.session_exists,
664
+ status: response.result.source_output.status,
665
+ };
666
+ } else {
667
+ return response;
668
+ }
669
+ } catch (error: any) {
670
+ if (error?.response?.data?.error) {
671
+ let obj = this.idfyError;
672
+ const errorObj =
673
+ obj[error?.response?.data?.error as keyof typeof obj];
674
+ if (errorObj)
675
+ throw {
676
+ ...this.standardErrorThrowFormat,
677
+ message: [errorObj.message],
678
+ };
679
+ }
680
+ throw error;
681
+ }
682
+ }
683
+
684
+ async getUdhyamDetails({ uamNumber }: { uamNumber: string }): Promise<any> {
685
+ try {
686
+ const data = {
687
+ task_id: "74f4c926-250c-43hca-9c53-453e87ceacd1",
688
+ group_id: "8e16424a-58fc-4ba4-ab20-5bc8e7c3c41e",
689
+ data: {
690
+ uam_number: uamNumber,
691
+ },
692
+ };
693
+ const res = await this.makeRequest<any>(
694
+ "post",
695
+ this.getUdhyamEndpoint,
696
+ data
697
+ );
698
+ const requestId = res.request_id;
699
+ const response = (await this.pingTaskUntilSuccess(requestId))?.[0];
700
+ return convertToCamelCase(response);
701
+ } catch (error: any) {
702
+ if (error?.response?.data?.error) {
703
+ let obj = this.idfyError;
704
+ const errorObj =
705
+ obj[error?.response?.data?.error as keyof typeof obj];
706
+ if (errorObj)
707
+ throw {
708
+ ...this.standardErrorThrowFormat,
709
+ message: [errorObj.message],
710
+ };
711
+ }
712
+ throw convertToCamelCase(error);
713
+ }
659
714
  }
660
- }
661
715
  }