vishwam-react-ent-sdk 1.0.7 → 1.0.8
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 +148 -1
- package/dist/index.js +2 -12
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +2 -12
- package/dist/index.modern.js.map +1 -1
- package/package.json +2 -2
- package/dist/6-dots-rotate-white-36~GzbzADco.svg +0 -1
- package/dist/bouncing-circles~bhjNpXkl.svg +0 -1
- package/dist/disabled~jGBIdXqZ.svg +0 -73
- package/dist/enabled~bhrMcaug.svg +0 -27
- package/dist/fade-stagger-squares~ZuauTkHT.svg +0 -1
- package/dist/gears-spinner~ViTwyWPY.svg +0 -1
- package/dist/infinite-spinner~bblPQPhI.svg +0 -1
- package/dist/loading~GzbzADco.svg +0 -1
package/README.md
CHANGED
|
@@ -1 +1,148 @@
|
|
|
1
|
-
# vishwam-react-sdk
|
|
1
|
+
# vishwam-react-ent-sdk
|
|
2
|
+
|
|
3
|
+
React components for **ENT photo liveness** (`CheckLiveness`): in-browser face capture, on-device face detection, and backend liveness verification.
|
|
4
|
+
|
|
5
|
+
**Peer dependency:** React `^17.0.1`
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install vishwam-react-ent-sdk
|
|
13
|
+
# or
|
|
14
|
+
yarn add vishwam-react-ent-sdk
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Quick start
|
|
20
|
+
|
|
21
|
+
Integration values (`url`, `appId`, and related props) are issued for your deployment. Do not use example credentials in production.
|
|
22
|
+
|
|
23
|
+
```jsx
|
|
24
|
+
import React from 'react'
|
|
25
|
+
import { CheckLiveness } from 'vishwam-react-ent-sdk'
|
|
26
|
+
|
|
27
|
+
function App() {
|
|
28
|
+
function onLiveness(response) {
|
|
29
|
+
// response.livenessImage — base64 (no data: prefix)
|
|
30
|
+
// response.livenessImageType — e.g. image/jpeg or image/png
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<CheckLiveness
|
|
35
|
+
url={apiBaseUrl}
|
|
36
|
+
appId={appId}
|
|
37
|
+
userId={userId}
|
|
38
|
+
referenceId={referenceId}
|
|
39
|
+
captureType={captureType}
|
|
40
|
+
eyesCheck={eyesCheck}
|
|
41
|
+
storeId={storeId}
|
|
42
|
+
whiteBackground={whiteBackground}
|
|
43
|
+
expiryIn={expiryIn}
|
|
44
|
+
getLivenessResponse={onLiveness}
|
|
45
|
+
/>
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## Exports
|
|
53
|
+
|
|
54
|
+
| Export | Description |
|
|
55
|
+
|--------|-------------|
|
|
56
|
+
| `CheckLiveness` | Photo liveness UI + API call |
|
|
57
|
+
| `ReadDocument` | Document capture flow |
|
|
58
|
+
| `Init` | Face detector preparation helper |
|
|
59
|
+
| `faceMatch` | Face match API helper |
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## `CheckLiveness` props
|
|
64
|
+
|
|
65
|
+
| Prop | Type | Description |
|
|
66
|
+
|------|------|-------------|
|
|
67
|
+
| `url` | string | API base URL for your environment |
|
|
68
|
+
| `appId` | string | Application id |
|
|
69
|
+
| `userId` | string \| number | User id |
|
|
70
|
+
| `referenceId` | string | Reference / transaction id |
|
|
71
|
+
| `captureType` | string | Capture type sent to API |
|
|
72
|
+
| `eyesCheck` | string | Eyes-open check flag for API |
|
|
73
|
+
| `storeId` | string | Store id |
|
|
74
|
+
| `whiteBackground` | string | White background flag |
|
|
75
|
+
| `expiryIn` | string | Token expiry (e.g. `1h`) |
|
|
76
|
+
| `getLivenessResponse` | function | Callback with API response (see below) |
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## Capture and images
|
|
81
|
+
|
|
82
|
+
On capture the SDK:
|
|
83
|
+
|
|
84
|
+
1. Reads a frame from the camera (desktop: webcam screenshot; mobile: canvas snapshot).
|
|
85
|
+
2. Builds two square images from the same frame:
|
|
86
|
+
- **450×450** — sent as the second image field in the liveness API request.
|
|
87
|
+
- **224×224** — sent as the first image field in the liveness API request.
|
|
88
|
+
3. Calls the liveness endpoint with both images (after obtaining an auth token).
|
|
89
|
+
|
|
90
|
+
On-device face detection models are loaded by the SDK at runtime.
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
## `getLivenessResponse` callback
|
|
95
|
+
|
|
96
|
+
The SDK merges the API JSON with local image fields before calling your handler:
|
|
97
|
+
|
|
98
|
+
| Field | Description |
|
|
99
|
+
|-------|-------------|
|
|
100
|
+
| `status` | API status (e.g. `success` / `failed`) |
|
|
101
|
+
| `livenessImage` | Base64-encoded face image (**no** `data:` prefix) |
|
|
102
|
+
| `livenessImageType` | MIME type for decoding (typically `image/jpeg` on desktop, `image/png` on mobile) |
|
|
103
|
+
| … | Other fields returned by the liveness API |
|
|
104
|
+
|
|
105
|
+
**Display example:**
|
|
106
|
+
|
|
107
|
+
```javascript
|
|
108
|
+
const src = `data:${response.livenessImageType};base64,${response.livenessImage}`
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Decode with `Image` / `naturalWidth` × `naturalHeight` if you need pixel dimensions.
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
## Changelog
|
|
116
|
+
|
|
117
|
+
### 1.0.8
|
|
118
|
+
|
|
119
|
+
**Callback image quality**
|
|
120
|
+
|
|
121
|
+
- **`livenessImage` is now the 450×450 capture** (same asset previously sent only as the high-resolution API upload).
|
|
122
|
+
- In **1.0.7**, `livenessImage` was the **224×224** image. Integrators that assumed 224×224 in the callback should update display/storage logic; API upload sizes are unchanged.
|
|
123
|
+
|
|
124
|
+
**Desktop bug fix**
|
|
125
|
+
|
|
126
|
+
- On **desktop**, startup now runs the full face-detection initialization path (models, UI ready state, detection loop) instead of loading models only, which could leave laptop browsers stuck on “face detector is initializing”.
|
|
127
|
+
- **Mobile** flow is unchanged.
|
|
128
|
+
|
|
129
|
+
### 1.0.7
|
|
130
|
+
|
|
131
|
+
- Updated on-device model loading for face detection.
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## Build (maintainers)
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
npm install
|
|
139
|
+
npm run build
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Published tarball includes `dist/` (`prepare` runs build on `npm publish`).
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
## License
|
|
147
|
+
|
|
148
|
+
MIT
|
package/dist/index.js
CHANGED
|
@@ -631,7 +631,7 @@ function CheckLiveness(_ref) {
|
|
|
631
631
|
var img2 = imgStr.split(',')[1];
|
|
632
632
|
clearInterval(interval);
|
|
633
633
|
return Promise.resolve(callLiveness(url, appId, userId, referenceId, captureType, eyesCheck, storeId, whiteBackground, expiryIn, img, img2, mimeString)).then(function (response) {
|
|
634
|
-
response.livenessImage =
|
|
634
|
+
response.livenessImage = img;
|
|
635
635
|
response.livenessImageType = mimeString;
|
|
636
636
|
getLivenessResponse(response);
|
|
637
637
|
setLoading(false);
|
|
@@ -659,20 +659,10 @@ function CheckLiveness(_ref) {
|
|
|
659
659
|
}, []);
|
|
660
660
|
React.useEffect(function () {
|
|
661
661
|
setTimeout(function () {
|
|
662
|
-
var initModels = function initModels() {
|
|
663
|
-
try {
|
|
664
|
-
return Promise.resolve(faceapi.nets.tinyFaceDetector.loadFromUri('https://skyc-cdn-prod.vishwamcorp.com/apis/models/')).then(function () {
|
|
665
|
-
return Promise.resolve(faceapi.nets.faceLandmark68TinyNet.loadFromUri('https://skyc-cdn-prod.vishwamcorp.com/apis/models/')).then(function () {});
|
|
666
|
-
});
|
|
667
|
-
} catch (e) {
|
|
668
|
-
return Promise.reject(e);
|
|
669
|
-
}
|
|
670
|
-
};
|
|
671
|
-
|
|
672
662
|
if (reactDeviceDetect.isMobile) {
|
|
673
663
|
startCamera();
|
|
674
664
|
} else {
|
|
675
|
-
|
|
665
|
+
init();
|
|
676
666
|
}
|
|
677
667
|
}, 500);
|
|
678
668
|
}, []);
|