@test-web/react-native-sdk 1.0.0 → 2.1.0
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 +543 -26
- package/assets/images/Chrome-logo.svg +1 -0
- package/assets/images/Firefox-logo.png +0 -0
- package/assets/images/IDM-logo.jpg +0 -0
- package/assets/images/MRZOverlay.png +0 -0
- package/assets/images/Safari-logo.png +0 -0
- package/assets/images/aadhar.png +0 -0
- package/assets/images/camera-bg.png +0 -0
- package/assets/images/card-overlay-back.png +0 -0
- package/assets/images/card-overlay.png +0 -0
- package/assets/images/card-scan-back-icon.jpg +0 -0
- package/assets/images/card-scan-front-icon.png +0 -0
- package/assets/images/card-scan-icon-aadhaar-1.png +0 -0
- package/assets/images/card-scan-icon-aadhaar-back.png +0 -0
- package/assets/images/card-scan-icon-aadhaar-scan-qr.png +0 -0
- package/assets/images/card-scan-icon-aadhaar.png +0 -0
- package/assets/images/card-scan-icon-can-pr.png +0 -0
- package/assets/images/card-scan-icon-default-back.png +0 -0
- package/assets/images/card-scan-icon-dl.png +0 -0
- package/assets/images/card-scan-icon-greencard-back.jpg +0 -0
- package/assets/images/card-scan-icon-greencard.jpg +0 -0
- package/assets/images/card-scan-icon-hc.png +0 -0
- package/assets/images/card-scan-icon-ni-argentina-back.jpg +0 -0
- package/assets/images/card-scan-icon-ni-argentina-old.png +0 -0
- package/assets/images/card-scan-icon-ni-argentina.jpg +0 -0
- package/assets/images/card-scan-icon-ni-barcode.jpg +0 -0
- package/assets/images/card-scan-icon-ni-brazil-back.jpg +0 -0
- package/assets/images/card-scan-icon-ni-brazil.jpg +0 -0
- package/assets/images/card-scan-icon-ni-dominican-republic-back.png +0 -0
- package/assets/images/card-scan-icon-ni-dominican-republic-front.png +0 -0
- package/assets/images/card-scan-icon-ni-dominican-republic-mrz.png +0 -0
- package/assets/images/card-scan-icon-ni-dominicanaRepublic-back.jpg +0 -0
- package/assets/images/card-scan-icon-ni-france-back.png +0 -0
- package/assets/images/card-scan-icon-ni-france-front.png +0 -0
- package/assets/images/card-scan-icon-ni-france-scan-mrz.png +0 -0
- package/assets/images/card-scan-icon-ni-germany-back.jpg +0 -0
- package/assets/images/card-scan-icon-ni-germany.jpg +0 -0
- package/assets/images/card-scan-icon-ni-paraguay-back.png +0 -0
- package/assets/images/card-scan-icon-ni-paraguay-front.png +0 -0
- package/assets/images/card-scan-icon-ni-paraguay-scan-mrz.png +0 -0
- package/assets/images/card-scan-icon-ni-uae-back.png +0 -0
- package/assets/images/card-scan-icon-ni-uae-front.png +0 -0
- package/assets/images/card-scan-icon-ni-uae-scan-mrz.png +0 -0
- package/assets/images/card-scan-icon-ni-uganda-front.png +0 -0
- package/assets/images/card-scan-icon-ni-uganda-scan-mrz.png +0 -0
- package/assets/images/card-scan-icon-ni-ukrain-back.png +0 -0
- package/assets/images/card-scan-icon-ni-ukrain-front.png +0 -0
- package/assets/images/card-scan-icon-ni-ukrain-scan-mrz.png +0 -0
- package/assets/images/card-scan-icon-ni.png +0 -0
- package/assets/images/card-scan-icon-old.jpg +0 -0
- package/assets/images/card-scan-icon-pan.png +0 -0
- package/assets/images/card-scan-icon-passport-card-back.jpg +0 -0
- package/assets/images/card-scan-icon-passport-card.jpg +0 -0
- package/assets/images/card-scan-icon-passport-old.png +0 -0
- package/assets/images/card-scan-icon-passport.png +0 -0
- package/assets/images/card-scan-icon-pr.png +0 -0
- package/assets/images/card-scan-icon.jpg +0 -0
- package/assets/images/check.png +0 -0
- package/assets/images/chrome-animation-GPS-permissions-setting.gif +0 -0
- package/assets/images/chrome-animation-camera-permissions-setting.gif +0 -0
- package/assets/images/denied.png +0 -0
- package/assets/images/dl.png +0 -0
- package/assets/images/driver-license.png +0 -0
- package/assets/images/firefox-animation-permissions-setting.gif +0 -0
- package/assets/images/flashlight_on.png +0 -0
- package/assets/images/gallery.png +0 -0
- package/assets/images/greencard.png +0 -0
- package/assets/images/header.jpg +0 -0
- package/assets/images/health-card.png +0 -0
- package/assets/images/ic_camera_front_white_36px.svg +4 -0
- package/assets/images/ic_camera_rear_white_36px.svg +4 -0
- package/assets/images/ic_fullscreen_exit_white_48px.svg +4 -0
- package/assets/images/ic_fullscreen_white_48px.svg +4 -0
- package/assets/images/ic_photo_camera_white_48px.svg +5 -0
- package/assets/images/id-card.png +0 -0
- package/assets/images/idcardimg.png +0 -0
- package/assets/images/idmval-barcode.png +0 -0
- package/assets/images/information.png +0 -0
- package/assets/images/loader.gif +0 -0
- package/assets/images/loading.svg +1 -0
- package/assets/images/logo.jpg +0 -0
- package/assets/images/logo.png +0 -0
- package/assets/images/mrz-back.png +0 -0
- package/assets/images/mrz-ni.png +0 -0
- package/assets/images/mrz.png +0 -0
- package/assets/images/mrz1.png +0 -0
- package/assets/images/mrz_old.png +0 -0
- package/assets/images/mrz_small.png +0 -0
- package/assets/images/national-id.png +0 -0
- package/assets/images/nationalID.png +0 -0
- package/assets/images/no-wifi.png +0 -0
- package/assets/images/passport-card.png +0 -0
- package/assets/images/passport.png +0 -0
- package/assets/images/permit-card.png +0 -0
- package/assets/images/photo-overlay.png +0 -0
- package/assets/images/placeholder.jpg +0 -0
- package/assets/images/qr-code.png +0 -0
- package/assets/images/right-checkmark.jpg +0 -0
- package/assets/images/selfie.jpg +0 -0
- package/assets/images/showing-sec.png +0 -0
- package/assets/images/spinner.gif +0 -0
- package/assets/images/splash-icon.png +0 -0
- package/assets/images/take-selfie.jpg +0 -0
- package/assets/images/torch_off.png +0 -0
- package/assets/images/warning-icon.jpg +0 -0
- package/assets/images/warning-stick.jpg +0 -0
- package/assets/images/wrong-checkmark.jpg +0 -0
- package/package.json +35 -8
- package/src/apis/index.ts +338 -17
- package/src/components/common/Loader.tsx +16 -2
- package/src/config/apiConfig.ts +6 -0
- package/src/index.tsx +123 -7
- package/src/screens/BarcodeCapture.tsx +64 -12
- package/src/screens/DocumentCaptureBack.tsx +133 -24
- package/src/screens/DocumentCaptureFront.tsx +146 -24
- package/src/screens/MrzCapture.tsx +77 -12
- package/src/screens/SelectDocuments.tsx +37 -56
- package/src/screens/SelfieCapture.tsx +114 -18
- package/src/screens/ThankYou.tsx +34 -1
- package/src/services/getUserData.ts +111 -0
- package/src/types/IDMConf.ts +81 -7
- package/src/utils/base64.ts +25 -0
- package/src/utils/flowManager.ts +138 -0
- package/src/utils/imageProcessor.ts +96 -0
- package/src/utils/index.ts +18 -0
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
<svg fill="#FFFFFF" height="36" viewBox="0 0 24 24" width="36" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M0 0h24v24H0z" fill="none"/>
|
|
3
|
+
<path d="M10 20H5v2h5v2l3-3-3-3v2zm4 0v2h5v-2h-5zM12 8c1.1 0 2-.9 2-2s-.9-2-2-2-1.99.9-1.99 2S10.9 8 12 8zm5-8H7C5.9 0 5 .9 5 2v14c0 1.1.9 2 2 2h10c1.1 0 2-.9 2-2V2c0-1.1-.9-2-2-2zM7 2h10v10.5c0-1.67-3.33-2.5-5-2.5s-5 .83-5 2.5V2z"/>
|
|
4
|
+
</svg>
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
<svg fill="#FFFFFF" height="36" viewBox="0 0 24 24" width="36" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M0 0h24v24H0z" fill="none"/>
|
|
3
|
+
<path d="M10 20H5v2h5v2l3-3-3-3v2zm4 0v2h5v-2h-5zm3-20H7C5.9 0 5 .9 5 2v14c0 1.1.9 2 2 2h10c1.1 0 2-.9 2-2V2c0-1.1-.9-2-2-2zm-5 6c-1.11 0-2-.9-2-2s.89-2 1.99-2 2 .9 2 2C14 5.1 13.1 6 12 6z"/>
|
|
4
|
+
</svg>
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
<svg fill="#FFFFFF" height="48" viewBox="0 0 24 24" width="48" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<circle cx="12" cy="12" r="3.2"/>
|
|
3
|
+
<path d="M9 2L7.17 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2h-3.17L15 2H9zm3 15c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5z"/>
|
|
4
|
+
<path d="M0 0h24v24H0z" fill="none"/>
|
|
5
|
+
</svg>
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?><svg xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.0" width="64px" height="64px" viewBox="0 0 128 128" xml:space="preserve"><g><path d="M38.52 33.37L21.36 16.2A63.6 63.6 0 0 1 59.5.16v24.3a39.5 39.5 0 0 0-20.98 8.92z" fill="#3498db" fill-opacity="1"/><path d="M38.52 33.37L21.36 16.2A63.6 63.6 0 0 1 59.5.16v24.3a39.5 39.5 0 0 0-20.98 8.92z" fill="#cde6f6" fill-opacity="0.25" transform="rotate(45 64 64)"/><path d="M38.52 33.37L21.36 16.2A63.6 63.6 0 0 1 59.5.16v24.3a39.5 39.5 0 0 0-20.98 8.92z" fill="#cde6f6" fill-opacity="0.25" transform="rotate(90 64 64)"/><path d="M38.52 33.37L21.36 16.2A63.6 63.6 0 0 1 59.5.16v24.3a39.5 39.5 0 0 0-20.98 8.92z" fill="#cde6f6" fill-opacity="0.25" transform="rotate(135 64 64)"/><path d="M38.52 33.37L21.36 16.2A63.6 63.6 0 0 1 59.5.16v24.3a39.5 39.5 0 0 0-20.98 8.92z" fill="#cde6f6" fill-opacity="0.25" transform="rotate(180 64 64)"/><path d="M38.52 33.37L21.36 16.2A63.6 63.6 0 0 1 59.5.16v24.3a39.5 39.5 0 0 0-20.98 8.92z" fill="#cde6f6" fill-opacity="0.25" transform="rotate(225 64 64)"/><path d="M38.52 33.37L21.36 16.2A63.6 63.6 0 0 1 59.5.16v24.3a39.5 39.5 0 0 0-20.98 8.92z" fill="#cde6f6" fill-opacity="0.25" transform="rotate(270 64 64)"/><path d="M38.52 33.37L21.36 16.2A63.6 63.6 0 0 1 59.5.16v24.3a39.5 39.5 0 0 0-20.98 8.92z" fill="#cde6f6" fill-opacity="0.25" transform="rotate(315 64 64)"/><animateTransform attributeName="transform" type="rotate" values="0 64 64;45 64 64;90 64 64;135 64 64;180 64 64;225 64 64;270 64 64;315 64 64" calcMode="discrete" dur="720ms" repeatCount="indefinite"></animateTransform></g></svg>
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@test-web/react-native-sdk",
|
|
3
|
-
"version": "1.0
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "2.1.0",
|
|
4
|
+
"description": "Dynamic React Native SDK for document verification with API-driven configuration",
|
|
5
5
|
"main": "src/index.tsx",
|
|
6
6
|
"types": "src/index.tsx",
|
|
7
7
|
"files": [
|
|
8
8
|
"src",
|
|
9
9
|
"android",
|
|
10
10
|
"ios",
|
|
11
|
+
"assets",
|
|
11
12
|
"*.podspec"
|
|
12
13
|
],
|
|
13
14
|
"scripts": {
|
|
@@ -16,7 +17,15 @@
|
|
|
16
17
|
},
|
|
17
18
|
"keywords": [
|
|
18
19
|
"react-native",
|
|
19
|
-
"sdk"
|
|
20
|
+
"sdk",
|
|
21
|
+
"document-verification",
|
|
22
|
+
"identity-verification",
|
|
23
|
+
"kyc",
|
|
24
|
+
"ocr",
|
|
25
|
+
"barcode",
|
|
26
|
+
"mrz",
|
|
27
|
+
"dynamic",
|
|
28
|
+
"api-driven"
|
|
20
29
|
],
|
|
21
30
|
"repository": "https://github.com/yourcompany/react-native-sdk",
|
|
22
31
|
"author": "Your Company <hello@yourcompany.com>",
|
|
@@ -24,11 +33,29 @@
|
|
|
24
33
|
"peerDependencies": {
|
|
25
34
|
"react": "*",
|
|
26
35
|
"react-native": "*",
|
|
27
|
-
"@react-navigation/native": "
|
|
28
|
-
"@react-navigation/native-stack": "
|
|
29
|
-
"react-native-screens": "
|
|
30
|
-
"react-native-safe-area-context": "
|
|
31
|
-
"react-native-vision-camera": "
|
|
36
|
+
"@react-navigation/native": ">=6.0.0",
|
|
37
|
+
"@react-navigation/native-stack": ">=6.0.0",
|
|
38
|
+
"react-native-screens": ">=3.0.0",
|
|
39
|
+
"react-native-safe-area-context": ">=4.0.0",
|
|
40
|
+
"react-native-vision-camera": ">=3.0.0",
|
|
41
|
+
"react-native-image-resizer": ">=1.0.0",
|
|
42
|
+
"react-native-fs": ">=2.0.0",
|
|
43
|
+
"react-native-device-info": ">=10.0.0",
|
|
44
|
+
"react-native-geolocation-service": ">=5.0.0"
|
|
45
|
+
},
|
|
46
|
+
"peerDependenciesMeta": {
|
|
47
|
+
"react-native-image-resizer": {
|
|
48
|
+
"optional": false
|
|
49
|
+
},
|
|
50
|
+
"react-native-fs": {
|
|
51
|
+
"optional": false
|
|
52
|
+
},
|
|
53
|
+
"react-native-device-info": {
|
|
54
|
+
"optional": true
|
|
55
|
+
},
|
|
56
|
+
"react-native-geolocation-service": {
|
|
57
|
+
"optional": true
|
|
58
|
+
}
|
|
32
59
|
},
|
|
33
60
|
"devDependencies": {
|
|
34
61
|
"@types/react": "^18.2.0",
|
package/src/apis/index.ts
CHANGED
|
@@ -1,32 +1,353 @@
|
|
|
1
1
|
import { IDMConf } from '../types/IDMConf';
|
|
2
|
+
import { getBaseURL } from '../config/apiConfig';
|
|
3
|
+
import { base64Encode } from '../utils/base64';
|
|
4
|
+
import getUserData from '../services/getUserData';
|
|
2
5
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Get user data including location, device info, and permissions
|
|
8
|
+
*/
|
|
9
|
+
export async function getUserDataAPI(): Promise<any> {
|
|
10
|
+
return await getUserData();
|
|
8
11
|
}
|
|
9
12
|
|
|
13
|
+
/**
|
|
14
|
+
* Generate access token using client credentials
|
|
15
|
+
*/
|
|
10
16
|
export async function generateAccessToken(conf: IDMConf): Promise<string> {
|
|
11
|
-
|
|
12
|
-
|
|
17
|
+
const { clientID, clientSecret, environment } = conf;
|
|
18
|
+
|
|
19
|
+
if (!clientID || !clientSecret) {
|
|
20
|
+
throw new Error('clientID and clientSecret are required.');
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const URL = `${getBaseURL(environment)}/token`;
|
|
24
|
+
const encodedCredentials = base64Encode(`${clientID}:${clientSecret}`);
|
|
25
|
+
const params = new URLSearchParams({
|
|
26
|
+
grant_type: 'client_credentials',
|
|
27
|
+
scope: 'idmvalidate',
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
try {
|
|
31
|
+
const response = await fetch(URL, {
|
|
32
|
+
method: 'POST',
|
|
33
|
+
headers: {
|
|
34
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
35
|
+
Authorization: `Basic ${encodedCredentials}`,
|
|
36
|
+
},
|
|
37
|
+
body: params.toString(),
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
if (!response.ok) {
|
|
41
|
+
const errorBody = await response.text();
|
|
42
|
+
throw new Error(
|
|
43
|
+
`Failed to generate access token: ${response.status} ${response.statusText} - ${errorBody}`
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const data = await response.json();
|
|
48
|
+
return data.access_token;
|
|
49
|
+
} catch (error: any) {
|
|
50
|
+
console.error('Error generating access token:', error);
|
|
51
|
+
throw new Error(`Failed to generate access token: ${error.message}`);
|
|
52
|
+
}
|
|
13
53
|
}
|
|
14
54
|
|
|
55
|
+
/**
|
|
56
|
+
* Generate verification request
|
|
57
|
+
*/
|
|
15
58
|
export async function generateRequest(conf: IDMConf, requestData: any): Promise<any> {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
59
|
+
if (!conf.accessToken) {
|
|
60
|
+
throw new Error('Access token is missing');
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const URL = `${getBaseURL(conf.environment)}/verify`;
|
|
64
|
+
|
|
65
|
+
try {
|
|
66
|
+
const response = await fetch(URL, {
|
|
67
|
+
method: 'POST',
|
|
68
|
+
headers: {
|
|
69
|
+
'Content-Type': 'application/json',
|
|
70
|
+
Authorization: `Bearer ${conf.accessToken}`,
|
|
71
|
+
},
|
|
72
|
+
body: JSON.stringify(requestData),
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
if (!response.ok) {
|
|
76
|
+
const errorBody = await response.text();
|
|
77
|
+
throw new Error(
|
|
78
|
+
`API call failed: ${response.status} ${response.statusText} - ${errorBody}`
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const data = await response.json();
|
|
83
|
+
const verificationCode = data.verificationLink?.split('/').pop() || null;
|
|
84
|
+
return {
|
|
85
|
+
...data,
|
|
86
|
+
verificationCode,
|
|
87
|
+
};
|
|
88
|
+
} catch (error: any) {
|
|
89
|
+
console.error('generateRequest error:', error);
|
|
90
|
+
throw new Error(`generateRequest failed: ${error.message}`);
|
|
91
|
+
}
|
|
20
92
|
}
|
|
21
93
|
|
|
94
|
+
/**
|
|
95
|
+
* Get configuration for verification
|
|
96
|
+
*/
|
|
22
97
|
export async function getConfiguration(conf: IDMConf, verificationCode: string): Promise<any> {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
98
|
+
if (!conf.accessToken) {
|
|
99
|
+
throw new Error('Access token is missing');
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const URL = `${getBaseURL(conf.environment)}/verify/configuration/${verificationCode}`;
|
|
103
|
+
|
|
104
|
+
try {
|
|
105
|
+
const response = await fetch(URL, {
|
|
106
|
+
method: 'GET',
|
|
107
|
+
headers: {
|
|
108
|
+
'Content-Type': 'application/json',
|
|
109
|
+
Authorization: `Bearer ${conf.accessToken}`,
|
|
110
|
+
},
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
if (!response.ok) {
|
|
114
|
+
const errorBody = await response.text();
|
|
115
|
+
throw new Error(
|
|
116
|
+
`API call failed: ${response.status} ${response.statusText} - ${errorBody}`
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const data = await response.json();
|
|
121
|
+
return data;
|
|
122
|
+
} catch (error: any) {
|
|
123
|
+
console.error('getConfiguration error:', error);
|
|
124
|
+
throw new Error(`getConfiguration failed: ${error.message}`);
|
|
125
|
+
}
|
|
27
126
|
}
|
|
28
127
|
|
|
128
|
+
/**
|
|
129
|
+
* Get list of countries with metadata
|
|
130
|
+
*/
|
|
29
131
|
export async function getCountries(conf: IDMConf): Promise<any> {
|
|
30
|
-
|
|
31
|
-
|
|
132
|
+
if (!conf.accessToken) {
|
|
133
|
+
throw new Error('Access token is missing');
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const URL = `${getBaseURL(conf.environment)}/metadata/country/list/${conf.verificationCode}`;
|
|
137
|
+
|
|
138
|
+
try {
|
|
139
|
+
const response = await fetch(URL, {
|
|
140
|
+
method: 'GET',
|
|
141
|
+
headers: {
|
|
142
|
+
'Content-Type': 'application/json',
|
|
143
|
+
Authorization: `Bearer ${conf.accessToken}`,
|
|
144
|
+
},
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
if (!response.ok) {
|
|
148
|
+
const errorBody = await response.text();
|
|
149
|
+
throw new Error(
|
|
150
|
+
`Failed to load countries: ${response.status} ${response.statusText} - ${errorBody}`
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const data = await response.json();
|
|
155
|
+
return data;
|
|
156
|
+
} catch (error: any) {
|
|
157
|
+
console.error('getCountries error:', error);
|
|
158
|
+
throw new Error(`getCountries failed: ${error.message}`);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Capture document front image
|
|
164
|
+
*/
|
|
165
|
+
export async function captureDocumentFront(
|
|
166
|
+
conf: IDMConf,
|
|
167
|
+
requestData: {
|
|
168
|
+
latitude: string;
|
|
169
|
+
longitude: string;
|
|
170
|
+
token: string;
|
|
171
|
+
persistLoc: string;
|
|
172
|
+
metadataIndex: string;
|
|
173
|
+
file: string;
|
|
174
|
+
}
|
|
175
|
+
): Promise<any> {
|
|
176
|
+
if (!conf.accessToken) {
|
|
177
|
+
throw new Error('Access token is missing');
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
const URL = `${getBaseURL(conf.environment)}/ocr/base64/document`;
|
|
181
|
+
|
|
182
|
+
try {
|
|
183
|
+
const formData = new FormData();
|
|
184
|
+
formData.append('file', requestData.file);
|
|
185
|
+
formData.append('token', requestData.token);
|
|
186
|
+
formData.append('latitude', requestData.latitude);
|
|
187
|
+
formData.append('longitude', requestData.longitude);
|
|
188
|
+
formData.append('persistLoc', 'false');
|
|
189
|
+
formData.append('metadataIndex', requestData.metadataIndex);
|
|
190
|
+
|
|
191
|
+
const response = await fetch(URL, {
|
|
192
|
+
method: 'POST',
|
|
193
|
+
headers: {
|
|
194
|
+
Authorization: `Bearer ${conf.accessToken}`,
|
|
195
|
+
},
|
|
196
|
+
body: formData,
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
const data = await response.json();
|
|
200
|
+
return data;
|
|
201
|
+
} catch (error: any) {
|
|
202
|
+
console.error('captureDocumentFront error:', error);
|
|
203
|
+
throw new Error(`captureDocumentFront failed: ${error.message}`);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Capture document back image
|
|
209
|
+
*/
|
|
210
|
+
export async function captureDocumentBack(
|
|
211
|
+
conf: IDMConf,
|
|
212
|
+
requestData: {
|
|
213
|
+
token: string;
|
|
214
|
+
file: string;
|
|
215
|
+
}
|
|
216
|
+
): Promise<any> {
|
|
217
|
+
if (!conf.accessToken) {
|
|
218
|
+
throw new Error('Access token is missing');
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
const URL = `${getBaseURL(conf.environment)}/ocr/document/text/back`;
|
|
222
|
+
|
|
223
|
+
try {
|
|
224
|
+
const formData = new FormData();
|
|
225
|
+
formData.append('file', requestData.file);
|
|
226
|
+
formData.append('token', requestData.token);
|
|
227
|
+
|
|
228
|
+
const response = await fetch(URL, {
|
|
229
|
+
method: 'POST',
|
|
230
|
+
headers: {
|
|
231
|
+
Authorization: `Bearer ${conf.accessToken}`,
|
|
232
|
+
},
|
|
233
|
+
body: formData,
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
const data = await response.json();
|
|
237
|
+
return data;
|
|
238
|
+
} catch (error: any) {
|
|
239
|
+
console.error('captureDocumentBack error:', error);
|
|
240
|
+
throw new Error(`captureDocumentBack failed: ${error.message}`);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Capture barcode data
|
|
246
|
+
*/
|
|
247
|
+
export async function captureBarcode(
|
|
248
|
+
conf: IDMConf,
|
|
249
|
+
requestData: {
|
|
250
|
+
token: string;
|
|
251
|
+
text: string;
|
|
252
|
+
}
|
|
253
|
+
): Promise<any> {
|
|
254
|
+
if (!conf.accessToken) {
|
|
255
|
+
throw new Error('Access token is missing');
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
const URL = `${getBaseURL(conf.environment)}/ocr/base64/barcode/text`;
|
|
259
|
+
|
|
260
|
+
try {
|
|
261
|
+
const formData = new FormData();
|
|
262
|
+
formData.append('text', requestData.text);
|
|
263
|
+
formData.append('token', requestData.token);
|
|
264
|
+
|
|
265
|
+
const response = await fetch(URL, {
|
|
266
|
+
method: 'POST',
|
|
267
|
+
headers: {
|
|
268
|
+
Authorization: `Bearer ${conf.accessToken}`,
|
|
269
|
+
},
|
|
270
|
+
body: formData,
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
const data = await response.json();
|
|
274
|
+
return data;
|
|
275
|
+
} catch (error: any) {
|
|
276
|
+
console.error('captureBarcode error:', error);
|
|
277
|
+
throw new Error(`captureBarcode failed: ${error.message}`);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* Capture MRZ data
|
|
283
|
+
*/
|
|
284
|
+
export async function captureMRZ(
|
|
285
|
+
conf: IDMConf,
|
|
286
|
+
requestData: {
|
|
287
|
+
token: string;
|
|
288
|
+
code: string;
|
|
289
|
+
engine: string;
|
|
290
|
+
}
|
|
291
|
+
): Promise<any> {
|
|
292
|
+
if (!conf.accessToken) {
|
|
293
|
+
throw new Error('Access token is missing');
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
const URL = `${getBaseURL(conf.environment)}/ocr/mrz/text`;
|
|
297
|
+
|
|
298
|
+
try {
|
|
299
|
+
const formData = new FormData();
|
|
300
|
+
formData.append('token', requestData.token);
|
|
301
|
+
formData.append('code', requestData.code);
|
|
302
|
+
formData.append('engine', requestData.engine);
|
|
303
|
+
|
|
304
|
+
const response = await fetch(URL, {
|
|
305
|
+
method: 'POST',
|
|
306
|
+
headers: {
|
|
307
|
+
Authorization: `Bearer ${conf.accessToken}`,
|
|
308
|
+
},
|
|
309
|
+
body: formData,
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
const data = await response.json();
|
|
313
|
+
return data;
|
|
314
|
+
} catch (error: any) {
|
|
315
|
+
console.error('captureMRZ error:', error);
|
|
316
|
+
throw new Error(`captureMRZ failed: ${error.message}`);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* Complete verification process
|
|
322
|
+
*/
|
|
323
|
+
export async function completeVerification(conf: IDMConf): Promise<any> {
|
|
324
|
+
if (!conf.accessToken) {
|
|
325
|
+
throw new Error('Access token is missing');
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
const URL = `${getBaseURL(conf.environment)}/verify/complete/${conf.verificationCode}`;
|
|
329
|
+
|
|
330
|
+
try {
|
|
331
|
+
const response = await fetch(URL, {
|
|
332
|
+
method: 'POST',
|
|
333
|
+
headers: {
|
|
334
|
+
'Content-Type': 'application/json',
|
|
335
|
+
Authorization: `Bearer ${conf.accessToken}`,
|
|
336
|
+
},
|
|
337
|
+
});
|
|
338
|
+
|
|
339
|
+
if (!response.ok) {
|
|
340
|
+
const errorBody = await response.text();
|
|
341
|
+
throw new Error(
|
|
342
|
+
`API call failed: ${response.status} ${response.statusText} - ${errorBody}`
|
|
343
|
+
);
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
const data = await response.json();
|
|
347
|
+
return data;
|
|
348
|
+
} catch (error: any) {
|
|
349
|
+
console.error('completeVerification error:', error);
|
|
350
|
+
throw new Error(`completeVerification failed: ${error.message}`);
|
|
351
|
+
}
|
|
32
352
|
}
|
|
353
|
+
|