biometry-sdk 2.3.5 → 2.3.6
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 +688 -260
- package/dist/sdk/index.d.ts +3 -3
- package/dist/sdk.js +1 -1
- package/dist/sdk.js.map +1 -1
- package/dist/types/biometry/doc-auth.d.ts +16 -1
- package/dist/types/biometry/enrollment.d.ts +5 -1
- package/dist/types/biometry/face-match.d.ts +6 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,274 +1,702 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
## Installation
|
|
30
|
-
Install the Biometry Web SDK via npm:
|
|
1
|
+
# Biometry Web SDK
|
|
2
|
+
|
|
3
|
+
The official JavaScript/TypeScript SDK for integrating [Biometry](https://biometrysolutions.com) identity verification services into web applications. Provides a simple, promise-based API for biometric enrollment, liveness detection, face matching, document authentication, and consent management.
|
|
4
|
+
|
|
5
|
+
> **Companion library:** For pre-built React UI components (camera capture, liveness screens, etc.), see [biometry-react-components](https://www.npmjs.com/package/biometry-react-components). Use it alongside this SDK for a faster integration.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- **Session management** — group related transactions under a single session ID
|
|
10
|
+
- **Consent management** — collect authorization and storage consent (required before biometric operations)
|
|
11
|
+
- **Face enrollment** — register a user's face from a photo or ID document
|
|
12
|
+
- **Voice enrollment** — register a user's voice for speaker verification
|
|
13
|
+
- **Video processing** — liveness detection, active speaker detection, face recognition, voice recognition, and visual speech recognition in one call
|
|
14
|
+
- **Auto-enrollment** — automatic face and voice enrollment during video processing when both consents are given
|
|
15
|
+
- **Face matching** — compare a reference image against a video to verify identity
|
|
16
|
+
- **Document authentication** — extract and validate data from ID documents (passports, ID cards, etc.)
|
|
17
|
+
- **Full TypeScript support** — ships with complete type definitions
|
|
18
|
+
- **Framework-agnostic** — works with React, Angular, Vue, vanilla JS, or any web framework
|
|
19
|
+
|
|
20
|
+
## Getting Started
|
|
21
|
+
|
|
22
|
+
### Prerequisites
|
|
23
|
+
|
|
24
|
+
- An active Biometry project with an **API key** (obtain one from the [Biometry Dashboard](https://console.biometrysolutions.com))
|
|
25
|
+
- Node.js 16+ (for npm-based projects) or any modern browser with ES module support
|
|
26
|
+
|
|
27
|
+
### Installation
|
|
28
|
+
|
|
31
29
|
```bash
|
|
32
30
|
npm install biometry-sdk
|
|
33
31
|
```
|
|
34
32
|
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
### Initialization
|
|
34
|
+
|
|
37
35
|
```typescript
|
|
38
36
|
import { BiometrySDK } from 'biometry-sdk';
|
|
39
37
|
|
|
40
|
-
// Initialize the SDK with your API key
|
|
41
38
|
const sdk = new BiometrySDK('YOUR_API_KEY');
|
|
42
39
|
```
|
|
43
40
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
This is useful for
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
41
|
+
The API key is used as a Bearer token for all requests to the Biometry API. An error is thrown if the key is empty.
|
|
42
|
+
|
|
43
|
+
> **Security:** Never hardcode API keys in client-side code shipped to production. Use environment variables or a server-side proxy to keep your key private.
|
|
44
|
+
|
|
45
|
+
## Response Structure
|
|
46
|
+
|
|
47
|
+
All gateway API responses follow a standard envelope format:
|
|
48
|
+
|
|
49
|
+
```json
|
|
50
|
+
{
|
|
51
|
+
"data": { ... },
|
|
52
|
+
"scoring_result": "pass" | "fail" | "refer" | { ... },
|
|
53
|
+
"score": 0.95,
|
|
54
|
+
"decision_reasons": ["reason1", "reason2"],
|
|
55
|
+
"message": "human-readable status message"
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
| Field | Type | Description |
|
|
60
|
+
|-------|------|-------------|
|
|
61
|
+
| `data` | `object` | The primary response payload (service results, extracted data, etc.) |
|
|
62
|
+
| `scoring_result` | `string \| object` | Scoring outcome — `"pass"`, `"fail"`, or `"refer"` for video processing and document auth; a detailed scoring map for face matching |
|
|
63
|
+
| `score` | `number` | Numeric confidence score (0–1), present on video processing responses |
|
|
64
|
+
| `decision_reasons` | `string[]` | Reasons for a fail/refer decision (e.g. `["liveness_failed"]`) |
|
|
65
|
+
| `message` | `string` | Human-readable status message |
|
|
66
|
+
|
|
67
|
+
The SDK wraps this in an `ApiResponse<T>` object that also includes the HTTP response headers:
|
|
68
|
+
|
|
69
|
+
```typescript
|
|
70
|
+
interface ApiResponse<T> {
|
|
71
|
+
body: T; // Response payload (the envelope above)
|
|
72
|
+
headers: Record<string, string>; // HTTP response headers
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Not all fields are present on every response — only relevant fields are included (empty/zero fields are omitted).
|
|
77
|
+
|
|
78
|
+
## Usage
|
|
79
|
+
|
|
80
|
+
### Sessions
|
|
81
|
+
|
|
82
|
+
Sessions group related transactions together so they appear as a single flow in the Biometry Dashboard.
|
|
83
|
+
|
|
84
|
+
```typescript
|
|
85
|
+
const session = await sdk.startSession();
|
|
86
|
+
const sessionId = session.body.data; // "sess_xxxxxxxx-xxxx-..."
|
|
87
|
+
|
|
88
|
+
// Pass sessionId to subsequent calls to link them together
|
|
89
|
+
await sdk.giveStorageConsent(true, 'Jane Doe', { sessionId });
|
|
90
|
+
await sdk.enrollFace(faceFile, 'Jane Doe', false, { sessionId });
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Consent
|
|
94
|
+
|
|
95
|
+
Consent must be collected **before** performing biometric operations. There are two types:
|
|
96
|
+
|
|
97
|
+
| Type | Required before | Method |
|
|
98
|
+
|------|----------------|--------|
|
|
99
|
+
| **Authorization** | Face recognition, voice recognition, face matching | `giveAuthorizationConsent()` |
|
|
100
|
+
| **Storage** | Face enrollment, voice enrollment | `giveStorageConsent()` |
|
|
101
|
+
|
|
102
|
+
```typescript
|
|
103
|
+
// Authorization consent — required for recognition/verification operations
|
|
104
|
+
await sdk.giveAuthorizationConsent(true, 'Jane Doe');
|
|
105
|
+
|
|
106
|
+
// Storage consent — required for enrollment operations
|
|
107
|
+
await sdk.giveStorageConsent(true, 'Jane Doe');
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Both methods accept optional `sessionId` and `deviceInfo`:
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
await sdk.giveAuthorizationConsent(true, 'Jane Doe', {
|
|
114
|
+
sessionId: 'sess_abc123',
|
|
115
|
+
deviceInfo: { os: 'iOS', browser: 'Safari' },
|
|
116
|
+
});
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
> **Important — Consent and video processing:** The `processVideo` endpoint does **not** reject requests without consent. Instead, it silently removes services that require authorization consent (face recognition, voice recognition) and processes only the remaining services (liveness detection, active speaker detection, visual speech recognition). When services are removed, the response includes the header `X-Removed-Services: true`. Always collect consent before calling `processVideo` to ensure all services run.
|
|
120
|
+
|
|
121
|
+
> **Important — Auto-enrollment:** When **both** authorization and storage consent are given, `processVideo` will automatically enroll the user's face and voice in the background (if not already enrolled). The response header `X-Auto-Enroll: true` is set when this occurs. See [Auto-Enrollment](#auto-enrollment) for details.
|
|
122
|
+
|
|
123
|
+
### Face Enrollment
|
|
124
|
+
|
|
125
|
+
Register a user's face for future matching. Requires **storage consent** first.
|
|
126
|
+
|
|
127
|
+
```typescript
|
|
128
|
+
const faceFile = new File([imageBytes], 'face.jpg', { type: 'image/jpeg' });
|
|
129
|
+
|
|
130
|
+
await sdk.giveStorageConsent(true, 'Jane Doe');
|
|
131
|
+
const response = await sdk.enrollFace(faceFile, 'Jane Doe');
|
|
132
|
+
|
|
133
|
+
// Response envelope:
|
|
134
|
+
// {
|
|
135
|
+
// "data": {
|
|
136
|
+
// "enrollment_result": { "code": 0, "description": "Face enrolled successfully" },
|
|
137
|
+
// "document_auth": null
|
|
138
|
+
// },
|
|
139
|
+
// "message": "face enrolled successfully"
|
|
140
|
+
// }
|
|
141
|
+
|
|
142
|
+
console.log(response.body.data.enrollment_result);
|
|
143
|
+
// { code: 0, description: "Face enrolled successfully" }
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
If enrolling from an ID document image (e.g. passport photo), set `isDocument` to `true`. This improves face detection accuracy for document photos:
|
|
147
|
+
|
|
148
|
+
```typescript
|
|
149
|
+
const response = await sdk.enrollFace(documentImage, 'Jane Doe', true);
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
When `isDocument` is `true`, the response may include `document_auth` with extracted document data alongside the enrollment result.
|
|
153
|
+
|
|
154
|
+
An `enrollment_result.code` of `0` means success. Non-zero codes indicate a failure (e.g. no face detected, multiple faces detected).
|
|
155
|
+
|
|
156
|
+
### Voice Enrollment
|
|
157
|
+
|
|
158
|
+
Register a user's voice for speaker verification. Requires **storage consent** first.
|
|
159
|
+
|
|
160
|
+
```typescript
|
|
161
|
+
const audioFile = new File([audioBytes], 'voice.wav', { type: 'audio/wav' });
|
|
162
|
+
|
|
163
|
+
await sdk.giveStorageConsent(true, 'Jane Doe');
|
|
164
|
+
const response = await sdk.enrollVoice(
|
|
165
|
+
audioFile,
|
|
166
|
+
'Jane Doe',
|
|
167
|
+
'jane-doe-id', // unique identifier
|
|
168
|
+
'one two three' // the phrase spoken in the audio
|
|
169
|
+
);
|
|
170
|
+
|
|
171
|
+
// Response envelope:
|
|
172
|
+
// {
|
|
173
|
+
// "data": {
|
|
174
|
+
// "status": "good",
|
|
175
|
+
// "qa_combined": { ... },
|
|
176
|
+
// "qa_list": [...]
|
|
177
|
+
// },
|
|
178
|
+
// "message": "voice registered successfully"
|
|
179
|
+
// }
|
|
180
|
+
|
|
181
|
+
console.log(response.body.data.status); // "good" | "qafailed" | "enrolled" | "error"
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
> **Note:** The voice enrollment identifier is derived from the `userFullName` parameter (spaces are replaced with underscores). For example, `'Jane Doe'` becomes `Jane_Doe` as the enrollment ID on the backend. The `uniqueId` parameter is sent in the request but the server-side identifier is derived from the user's full name.
|
|
185
|
+
|
|
186
|
+
### Video Processing (Liveness & Recognition)
|
|
187
|
+
|
|
188
|
+
Process a video to perform up to five biometric checks in a single request:
|
|
189
|
+
|
|
190
|
+
1. **Face Liveness Detection** — determines if the face in the video is a real person (not a photo/screen replay)
|
|
191
|
+
2. **Active Speaker Detection** — verifies the person is actively speaking
|
|
192
|
+
3. **Visual Speech Recognition** — reads lips to verify the spoken phrase matches
|
|
193
|
+
4. **Face Recognition** — identifies the face against enrolled faces (requires authorization consent)
|
|
194
|
+
5. **Voice Recognition** — verifies the speaker's voice against enrolled voiceprints (requires authorization consent)
|
|
195
|
+
|
|
196
|
+
```typescript
|
|
197
|
+
const videoFile = new File([videoBytes], 'video.mp4', { type: 'video/mp4' });
|
|
198
|
+
|
|
199
|
+
await sdk.giveAuthorizationConsent(true, 'Jane Doe');
|
|
200
|
+
const response = await sdk.processVideo(videoFile, '12345678', 'Jane Doe');
|
|
201
|
+
|
|
202
|
+
// Response envelope:
|
|
203
|
+
// {
|
|
204
|
+
// "data": {
|
|
205
|
+
// "Face Liveness Detection": { "code": 0, "description": "Real face detected", "result": true },
|
|
206
|
+
// "Active Speaker Detection": { "code": 0, "description": "Active speaker detected", "result": 1 },
|
|
207
|
+
// "Visual Speech Recognition": { "code": 0, "description": "...", "result": "12345678" },
|
|
208
|
+
// "Face Recognition": { "code": 0, "description": "Face identified" },
|
|
209
|
+
// "Voice Recognition": { "status": "good", "id": "Jane_Doe", "score": 0.92, ... }
|
|
210
|
+
// },
|
|
211
|
+
// "scoring_result": "pass",
|
|
212
|
+
// "score": 0.95,
|
|
213
|
+
// "decision_reasons": [],
|
|
214
|
+
// "message": "video processed successfully"
|
|
215
|
+
// }
|
|
216
|
+
|
|
217
|
+
console.log(response.body.scoring_result); // "pass" | "fail" | "refer"
|
|
218
|
+
console.log(response.body.data['Face Liveness Detection'].result); // true or false
|
|
219
|
+
console.log(response.body.data['Visual Speech Recognition'].result); // the recognized phrase
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
The `phrase` parameter is a set of digits the user speaks aloud in the video (e.g. `'12345678'`). This is used for visual speech recognition and voice verification.
|
|
223
|
+
|
|
224
|
+
The `scoring_result` field indicates the overall outcome:
|
|
225
|
+
- `"pass"` — all checks passed
|
|
226
|
+
- `"fail"` — one or more checks failed
|
|
227
|
+
- `"refer"` — needs manual review
|
|
228
|
+
|
|
229
|
+
When the result is `"fail"` or `"refer"`, check `decision_reasons` for specific failure causes.
|
|
230
|
+
|
|
231
|
+
#### Auto-Enrollment
|
|
232
|
+
|
|
233
|
+
When **both** authorization consent and storage consent have been given for the user, `processVideo` automatically enrolls the user's face and voice in the background. This is useful for registration flows where you want to verify liveness and enroll in a single step.
|
|
234
|
+
|
|
235
|
+
Auto-enrollment behavior:
|
|
236
|
+
- **Face**: Enrolled from the video if the user's face is not already enrolled
|
|
237
|
+
- **Voice**: Enrolled from the video audio if the user's voice is not already enrolled for the given phrase
|
|
238
|
+
- **Response header**: `X-Auto-Enroll: true` is set when auto-enrollment is triggered
|
|
239
|
+
- **Non-blocking**: Enrollment happens asynchronously and does not affect the video processing response
|
|
240
|
+
|
|
241
|
+
```typescript
|
|
242
|
+
// Collect both consents to enable auto-enrollment
|
|
243
|
+
await sdk.giveStorageConsent(true, 'Jane Doe', { sessionId });
|
|
244
|
+
await sdk.giveAuthorizationConsent(true, 'Jane Doe', { sessionId });
|
|
245
|
+
|
|
246
|
+
// processVideo will now auto-enroll face and voice in the background
|
|
247
|
+
const response = await sdk.processVideo(videoFile, '12345678', 'Jane Doe', { sessionId });
|
|
248
|
+
|
|
249
|
+
// Check if auto-enrollment was triggered
|
|
250
|
+
if (response.headers['x-auto-enroll'] === 'true') {
|
|
251
|
+
console.log('Face and voice enrolled automatically');
|
|
252
|
+
}
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
> **Tip:** If you only need liveness detection (without face/voice recognition), you can call `processVideo` without providing a `userFullName`. Services that require consent (face recognition, voice recognition) will be skipped.
|
|
256
|
+
|
|
257
|
+
### Face Matching
|
|
258
|
+
|
|
259
|
+
Compare a reference image (selfie, ID photo, etc.) against a face from a video to verify identity.
|
|
260
|
+
|
|
261
|
+
**Option A — Provide both image and video:**
|
|
262
|
+
|
|
263
|
+
```typescript
|
|
264
|
+
const imageFile = new File([imgBytes], 'face.jpg', { type: 'image/jpeg' });
|
|
265
|
+
const videoFile = new File([vidBytes], 'video.mp4', { type: 'video/mp4' });
|
|
266
|
+
|
|
267
|
+
const response = await sdk.matchFaces(imageFile, videoFile, 'Jane Doe');
|
|
268
|
+
|
|
269
|
+
// Response envelope:
|
|
270
|
+
// {
|
|
271
|
+
// "data": {
|
|
272
|
+
// "code": 0,
|
|
273
|
+
// "result": 1,
|
|
274
|
+
// "description": "Successful check",
|
|
275
|
+
// "anchor": { "code": 0, "description": "One face found in the image" },
|
|
276
|
+
// "target": { "code": 0, "description": "One face found in the video" }
|
|
277
|
+
// },
|
|
278
|
+
// "scoring_result": { "status": "pass", ... },
|
|
279
|
+
// "decision_reasons": [],
|
|
280
|
+
// "message": "faces match result is here"
|
|
281
|
+
// }
|
|
282
|
+
|
|
283
|
+
console.log(response.body.data.result); // 1 = match, 0 = no match
|
|
284
|
+
console.log(response.body.data.description); // "Successful check"
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
| `data.result` | Meaning |
|
|
288
|
+
|-------|---------|
|
|
289
|
+
| `1` | Faces match |
|
|
290
|
+
| `0` | Faces do not match |
|
|
291
|
+
|
|
292
|
+
The `anchor` field describes the face detected in the reference image, and `target` describes the face detected in the video. A `code` of `0` means a face was successfully found.
|
|
293
|
+
|
|
294
|
+
**Option B — Reuse video from a previous `processVideo` call:**
|
|
295
|
+
|
|
296
|
+
If you already called `processVideo` with a `sessionId`, you can skip uploading the video again:
|
|
297
|
+
|
|
298
|
+
```typescript
|
|
299
|
+
const session = await sdk.startSession();
|
|
300
|
+
const sessionId = session.body.data;
|
|
301
|
+
|
|
302
|
+
// Step 1: Process video within the session
|
|
303
|
+
await sdk.processVideo(videoFile, '12345678', 'Jane Doe', { sessionId });
|
|
304
|
+
|
|
305
|
+
// Step 2: Match faces reusing the same video
|
|
306
|
+
const response = await sdk.matchFaces(
|
|
307
|
+
imageFile, // Reference image
|
|
308
|
+
undefined, // No video file needed
|
|
309
|
+
'Jane Doe',
|
|
310
|
+
true, // usePrefilledVideo
|
|
311
|
+
{ sessionId } // Same session ID
|
|
312
|
+
);
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
### Document Authentication
|
|
316
|
+
|
|
317
|
+
Extract and validate information from identity documents (passports, ID cards, driver's licenses). Only JPG, JPEG, and PNG images are accepted.
|
|
318
|
+
|
|
319
|
+
```typescript
|
|
320
|
+
const docFile = new File([docBytes], 'passport.jpg', { type: 'image/jpeg' });
|
|
321
|
+
|
|
322
|
+
await sdk.giveAuthorizationConsent(true, 'Jane Doe', { sessionId });
|
|
323
|
+
const response = await sdk.checkDocAuth(docFile, 'Jane Doe', {
|
|
324
|
+
sessionId,
|
|
325
|
+
inHouseCheck: true,
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
// Response envelope:
|
|
329
|
+
// {
|
|
330
|
+
// "data": {
|
|
331
|
+
// "document_type": "National Identification Card",
|
|
332
|
+
// "first_name": "JANE",
|
|
333
|
+
// "last_name": "DOE",
|
|
334
|
+
// "birth_date": "1990-01-01",
|
|
335
|
+
// "document_number": "AB1234567",
|
|
336
|
+
// "country_code": "AUS",
|
|
337
|
+
// "sex": "FEMALE",
|
|
338
|
+
// "expiry_date": "2028-08-01",
|
|
339
|
+
// "portrait_photo": "<base64>",
|
|
340
|
+
// "face_image_base64": "<base64>",
|
|
341
|
+
// "current_result": "Passed",
|
|
342
|
+
// ...
|
|
343
|
+
// },
|
|
344
|
+
// "scoring_result": "pass",
|
|
345
|
+
// "message": "Document uploaded successfully, looks like it's authentic"
|
|
346
|
+
// }
|
|
347
|
+
|
|
348
|
+
const doc = response.body.data;
|
|
349
|
+
console.log(doc.first_name); // "JANE" (uppercase)
|
|
350
|
+
console.log(doc.last_name); // "DOE" (uppercase)
|
|
351
|
+
console.log(doc.document_number); // "AB1234567"
|
|
352
|
+
console.log(doc.document_type); // "National Identification Card"
|
|
353
|
+
console.log(doc.portrait_photo); // Base64-encoded photo from document OCR
|
|
354
|
+
console.log(doc.face_image_base64); // Base64-encoded cropped face image
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
> **Note:** `first_name` and `last_name` are returned in uppercase. The `portrait_photo` field contains the photo extracted via OCR/field parsing, while `face_image_base64` contains a cropped face image detected and extracted from the document.
|
|
358
|
+
|
|
359
|
+
The `scoring_result` field indicates document validation outcome: `"pass"` if the document looks authentic, `"fail"` otherwise.
|
|
360
|
+
|
|
361
|
+
The `inHouseCheck` option uses Biometry's in-house document verification (GPT + ML-based). When set to `false` (or omitted), the external IDScan verification service is used instead. The in-house check is the default and recommended option.
|
|
362
|
+
|
|
363
|
+
## Common Flows
|
|
364
|
+
|
|
365
|
+
### Identity Verification (KYC)
|
|
366
|
+
|
|
367
|
+
A typical identity verification flow combines consent, liveness, and face matching:
|
|
368
|
+
|
|
369
|
+
```typescript
|
|
370
|
+
const sdk = new BiometrySDK('YOUR_API_KEY');
|
|
371
|
+
const session = await sdk.startSession();
|
|
372
|
+
const sessionId = session.body.data;
|
|
373
|
+
const userName = 'Jane Doe';
|
|
374
|
+
|
|
375
|
+
// 1. Collect both consents
|
|
376
|
+
await sdk.giveStorageConsent(true, userName, { sessionId });
|
|
377
|
+
await sdk.giveAuthorizationConsent(true, userName, { sessionId });
|
|
378
|
+
|
|
379
|
+
// 2. Process live video for liveness + auto-enrollment
|
|
380
|
+
// (auto-enrolls face and voice since both consents are given)
|
|
381
|
+
const liveVideo = new File([videoBytes], 'video.mp4', { type: 'video/mp4' });
|
|
382
|
+
const videoResult = await sdk.processVideo(liveVideo, '12345678', userName, { sessionId });
|
|
383
|
+
|
|
384
|
+
if (videoResult.body.scoring_result !== 'pass') {
|
|
385
|
+
console.error('Liveness check failed:', videoResult.body.decision_reasons);
|
|
386
|
+
return;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
// 3. Match the ID photo against the live video (reusing video from step 2)
|
|
390
|
+
const idPhoto = new File([idBytes], 'id.jpg', { type: 'image/jpeg' });
|
|
391
|
+
const matchResult = await sdk.matchFaces(
|
|
392
|
+
idPhoto, undefined, userName, true, { sessionId }
|
|
393
|
+
);
|
|
394
|
+
|
|
395
|
+
if (matchResult.body.data.result === 1) {
|
|
396
|
+
console.log('Identity verified!');
|
|
397
|
+
} else {
|
|
398
|
+
console.log('Face mismatch — verification failed');
|
|
399
|
+
}
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
> **Note:** In this flow, explicit face enrollment (step 2 from the previous version) is no longer needed. Since both consents are given, `processVideo` auto-enrolls the user's face and voice in the background. You can proceed directly to face matching.
|
|
403
|
+
|
|
404
|
+
### Document-Only Verification
|
|
405
|
+
|
|
406
|
+
For flows that only need document data extraction:
|
|
407
|
+
|
|
408
|
+
```typescript
|
|
409
|
+
const sdk = new BiometrySDK('YOUR_API_KEY');
|
|
410
|
+
|
|
411
|
+
await sdk.giveAuthorizationConsent(true, 'Jane Doe');
|
|
412
|
+
|
|
413
|
+
const result = await sdk.checkDocAuth(documentFile, 'Jane Doe', {
|
|
414
|
+
inHouseCheck: true,
|
|
415
|
+
});
|
|
416
|
+
|
|
417
|
+
const doc = result.body.data;
|
|
418
|
+
console.log(`${doc.first_name} ${doc.last_name}`);
|
|
419
|
+
console.log(`DOB: ${doc.birth_date}`);
|
|
420
|
+
console.log(`Document: ${doc.document_number}`);
|
|
421
|
+
console.log(`Valid: ${result.body.scoring_result}`); // "pass" or "fail"
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
### Full KYC with Document Authentication
|
|
425
|
+
|
|
426
|
+
Combine document authentication with liveness verification and face matching for a comprehensive KYC flow:
|
|
427
|
+
|
|
428
|
+
```typescript
|
|
429
|
+
const sdk = new BiometrySDK('YOUR_API_KEY');
|
|
430
|
+
const session = await sdk.startSession();
|
|
431
|
+
const sessionId = session.body.data;
|
|
432
|
+
const userName = 'Jane Doe';
|
|
433
|
+
|
|
434
|
+
// 1. Collect both consents
|
|
435
|
+
await sdk.giveStorageConsent(true, userName, { sessionId });
|
|
436
|
+
await sdk.giveAuthorizationConsent(true, userName, { sessionId });
|
|
437
|
+
|
|
438
|
+
// 2. Authenticate the ID document
|
|
439
|
+
const docImage = new File([docBytes], 'passport.jpg', { type: 'image/jpeg' });
|
|
440
|
+
const docResult = await sdk.checkDocAuth(docImage, userName, {
|
|
441
|
+
sessionId,
|
|
442
|
+
inHouseCheck: true,
|
|
443
|
+
});
|
|
444
|
+
|
|
445
|
+
if (docResult.body.scoring_result !== 'pass') {
|
|
446
|
+
console.error('Document authentication failed');
|
|
447
|
+
return;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
// 3. Process live video (liveness + auto-enrollment)
|
|
451
|
+
const liveVideo = new File([videoBytes], 'video.mp4', { type: 'video/mp4' });
|
|
452
|
+
const videoResult = await sdk.processVideo(liveVideo, '12345678', userName, { sessionId });
|
|
453
|
+
|
|
454
|
+
if (videoResult.body.scoring_result !== 'pass') {
|
|
455
|
+
console.error('Liveness check failed');
|
|
456
|
+
return;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
// 4. Match document photo against live video
|
|
460
|
+
const matchResult = await sdk.matchFaces(
|
|
461
|
+
docImage, undefined, userName, true, { sessionId }
|
|
462
|
+
);
|
|
463
|
+
|
|
464
|
+
if (matchResult.body.data.result === 1) {
|
|
465
|
+
console.log('KYC complete — identity verified!');
|
|
466
|
+
} else {
|
|
467
|
+
console.log('Face mismatch — document does not match live video');
|
|
468
|
+
}
|
|
469
|
+
```
|
|
470
|
+
|
|
471
|
+
## API Reference
|
|
472
|
+
|
|
473
|
+
### `new BiometrySDK(apiKey)`
|
|
474
|
+
|
|
475
|
+
Creates a new SDK instance.
|
|
476
|
+
|
|
477
|
+
| Parameter | Type | Required | Description |
|
|
478
|
+
|-----------|------|----------|-------------|
|
|
479
|
+
| `apiKey` | `string` | Yes | Your Biometry project API key |
|
|
480
|
+
|
|
481
|
+
---
|
|
482
|
+
|
|
483
|
+
### `startSession()`
|
|
484
|
+
|
|
485
|
+
Starts a new session for grouping transactions.
|
|
486
|
+
|
|
487
|
+
**Returns:** `Promise<ApiResponse<SessionResponse>>`
|
|
488
|
+
|
|
489
|
+
```typescript
|
|
490
|
+
// SessionResponse
|
|
491
|
+
{ data: string; message: string }
|
|
492
|
+
```
|
|
493
|
+
|
|
494
|
+
---
|
|
495
|
+
|
|
496
|
+
### `giveAuthorizationConsent(isConsentGiven, userFullName, props?)`
|
|
497
|
+
|
|
498
|
+
Submits authorization consent. Required before recognition and verification operations.
|
|
499
|
+
|
|
500
|
+
| Parameter | Type | Required | Description |
|
|
501
|
+
|-----------|------|----------|-------------|
|
|
502
|
+
| `isConsentGiven` | `boolean` | Yes | Whether the user granted consent |
|
|
503
|
+
| `userFullName` | `string` | Yes | User's full name for record-keeping |
|
|
504
|
+
| `props.sessionId` | `string` | No | Session ID to link with |
|
|
505
|
+
| `props.deviceInfo` | `object` | No | Device metadata |
|
|
506
|
+
|
|
507
|
+
**Returns:** `Promise<ApiResponse<ConsentResponse>>`
|
|
508
|
+
|
|
509
|
+
---
|
|
510
|
+
|
|
511
|
+
### `giveStorageConsent(isStorageConsentGiven, userFullName, props?)`
|
|
512
|
+
|
|
513
|
+
Submits storage consent. Required before enrollment operations.
|
|
514
|
+
|
|
515
|
+
| Parameter | Type | Required | Description |
|
|
516
|
+
|-----------|------|----------|-------------|
|
|
517
|
+
| `isStorageConsentGiven` | `boolean` | Yes | Whether the user granted storage consent |
|
|
518
|
+
| `userFullName` | `string` | Yes | User's full name for record-keeping |
|
|
519
|
+
| `props.sessionId` | `string` | No | Session ID to link with |
|
|
520
|
+
| `props.deviceInfo` | `object` | No | Device metadata |
|
|
521
|
+
|
|
522
|
+
**Returns:** `Promise<ApiResponse<ConsentResponse>>`
|
|
523
|
+
|
|
524
|
+
---
|
|
525
|
+
|
|
526
|
+
### `enrollFace(face, userFullName, isDocument?, props?)`
|
|
527
|
+
|
|
528
|
+
Enrolls a user's face for biometric authentication.
|
|
529
|
+
|
|
530
|
+
| Parameter | Type | Required | Description |
|
|
531
|
+
|-----------|------|----------|-------------|
|
|
532
|
+
| `face` | `File` | Yes | Image file containing the face |
|
|
533
|
+
| `userFullName` | `string` | Yes | User's full name |
|
|
534
|
+
| `isDocument` | `boolean` | No | Set `true` if image is from an ID document |
|
|
535
|
+
| `props.sessionId` | `string` | No | Session ID to link with |
|
|
536
|
+
| `props.deviceInfo` | `object` | No | Device metadata |
|
|
537
|
+
|
|
538
|
+
**Returns:** `Promise<ApiResponse<FaceEnrollmentResponse>>`
|
|
539
|
+
|
|
540
|
+
Response `data` contains:
|
|
541
|
+
- `enrollment_result.code` — `0` for success, non-zero for failure
|
|
542
|
+
- `enrollment_result.description` — human-readable result
|
|
543
|
+
- `document_auth` — extracted document data (when `isDocument` is `true`)
|
|
544
|
+
|
|
545
|
+
---
|
|
546
|
+
|
|
547
|
+
### `enrollVoice(audio, userFullName, uniqueId, phrase, props?)`
|
|
548
|
+
|
|
549
|
+
Enrolls a user's voice for speaker verification.
|
|
550
|
+
|
|
551
|
+
| Parameter | Type | Required | Description |
|
|
552
|
+
|-----------|------|----------|-------------|
|
|
553
|
+
| `audio` | `File` | Yes | Audio file with the user's voice |
|
|
554
|
+
| `userFullName` | `string` | Yes | User's full name (also used as the enrollment identifier) |
|
|
555
|
+
| `uniqueId` | `string` | Yes | Unique identifier for the enrollment |
|
|
556
|
+
| `phrase` | `string` | Yes | The phrase spoken in the audio |
|
|
557
|
+
| `props.sessionId` | `string` | No | Session ID to link with |
|
|
558
|
+
| `props.deviceInfo` | `object` | No | Device metadata |
|
|
559
|
+
|
|
560
|
+
**Returns:** `Promise<ApiResponse<VoiceEnrollmentResponse>>`
|
|
561
|
+
|
|
562
|
+
Response `data` contains:
|
|
563
|
+
- `status` — `"good"` (accepted), `"enrolled"` (fully enrolled), `"qafailed"` (quality check failed), or `"error"`
|
|
564
|
+
- `qa_combined` — combined quality assessment results
|
|
565
|
+
- `qa_list` — per-file quality results
|
|
566
|
+
|
|
567
|
+
---
|
|
568
|
+
|
|
569
|
+
### `processVideo(video, phrase, userFullName?, props?)`
|
|
570
|
+
|
|
571
|
+
Processes a video for liveness detection, face recognition, active speaker detection, visual speech recognition, and voice recognition.
|
|
572
|
+
|
|
573
|
+
| Parameter | Type | Required | Description |
|
|
574
|
+
|-----------|------|----------|-------------|
|
|
575
|
+
| `video` | `File` | Yes | Video file to process |
|
|
576
|
+
| `phrase` | `string` | Yes | Digits the user speaks in the video |
|
|
577
|
+
| `userFullName` | `string` | No | User's full name (required for face/voice recognition) |
|
|
578
|
+
| `props.sessionId` | `string` | No | Session ID to link with |
|
|
579
|
+
| `props.deviceInfo` | `object` | No | Device metadata |
|
|
580
|
+
|
|
581
|
+
**Returns:** `Promise<ApiResponse<ProcessVideoResponse>>`
|
|
582
|
+
|
|
583
|
+
The `scoring_result` field indicates the overall outcome: `"pass"`, `"fail"`, or `"refer"` (needs manual review).
|
|
584
|
+
|
|
585
|
+
When both authorization and storage consent are given, face and voice are automatically enrolled in the background. The response header `X-Auto-Enroll: true` is set when auto-enrollment occurs.
|
|
586
|
+
|
|
587
|
+
---
|
|
588
|
+
|
|
589
|
+
### `matchFaces(image, video?, userFullName?, usePrefilledVideo?, props?)`
|
|
590
|
+
|
|
591
|
+
Compares a reference image against a face from a video.
|
|
592
|
+
|
|
593
|
+
| Parameter | Type | Required | Description |
|
|
594
|
+
|-----------|------|----------|-------------|
|
|
595
|
+
| `image` | `File` | Yes | Reference image containing a face |
|
|
596
|
+
| `video` | `File` | No | Video file with a face to compare. Required unless `usePrefilledVideo` is `true` |
|
|
597
|
+
| `userFullName` | `string` | No | User's full name |
|
|
598
|
+
| `usePrefilledVideo` | `boolean` | No | Reuse video from a previous `processVideo` call in the same session |
|
|
599
|
+
| `props.sessionId` | `string` | Conditional | Required if `usePrefilledVideo` is `true` |
|
|
600
|
+
| `props.deviceInfo` | `object` | No | Device metadata |
|
|
601
|
+
|
|
602
|
+
**Returns:** `Promise<ApiResponse<FaceMatchResponse>>`
|
|
603
|
+
|
|
604
|
+
Response `data` contains:
|
|
605
|
+
- `result` — `1` for match, `0` for no match
|
|
606
|
+
- `code` — `0` for successful comparison
|
|
607
|
+
- `description` — human-readable result
|
|
608
|
+
- `anchor` — face detection result for the reference image
|
|
609
|
+
- `target` — face detection result for the video
|
|
610
|
+
|
|
611
|
+
---
|
|
612
|
+
|
|
613
|
+
### `checkDocAuth(document, userFullName, props?)`
|
|
614
|
+
|
|
615
|
+
Authenticates an identity document and extracts its data.
|
|
616
|
+
|
|
617
|
+
| Parameter | Type | Required | Description |
|
|
618
|
+
|-----------|------|----------|-------------|
|
|
619
|
+
| `document` | `File` | Yes | Document image file (JPG, JPEG, or PNG only) |
|
|
620
|
+
| `userFullName` | `string` | Yes | User's full name |
|
|
621
|
+
| `props.sessionId` | `string` | No | Session ID to link with |
|
|
622
|
+
| `props.deviceInfo` | `object` | No | Device metadata |
|
|
623
|
+
| `props.inHouseCheck` | `boolean` | No | Use in-house document verification (default behavior) |
|
|
624
|
+
|
|
625
|
+
**Returns:** `Promise<ApiResponse<DocAuthInfo>>`
|
|
626
|
+
|
|
627
|
+
Response `data` contains document fields including `first_name`, `last_name`, `birth_date`, `document_number`, `document_type`, `country_code`, `portrait_photo` (base64), and `face_image_base64` (cropped face, base64).
|
|
628
|
+
|
|
629
|
+
---
|
|
630
|
+
|
|
631
|
+
### Response Headers
|
|
632
|
+
|
|
633
|
+
Useful headers returned by the API:
|
|
634
|
+
|
|
635
|
+
| Header | Description |
|
|
636
|
+
|--------|-------------|
|
|
637
|
+
| `x-request-id` | Unique request identifier for debugging |
|
|
638
|
+
| `x-auto-enroll` | Set to `"true"` when `processVideo` triggers auto-enrollment |
|
|
639
|
+
| `x-removed-services` | Set to `"true"` when consent-dependent services were removed from video processing |
|
|
640
|
+
|
|
641
|
+
```typescript
|
|
642
|
+
const response = await sdk.processVideo(videoFile, '12345678', 'Jane Doe');
|
|
643
|
+
|
|
644
|
+
console.log(response.headers['x-request-id']);
|
|
645
|
+
console.log(response.headers['x-auto-enroll']); // "true" if auto-enrolled
|
|
646
|
+
console.log(response.headers['x-removed-services']); // "true" if services were skipped
|
|
647
|
+
```
|
|
648
|
+
|
|
649
|
+
## Error Handling
|
|
650
|
+
|
|
651
|
+
All SDK methods throw errors on validation failures or unsuccessful HTTP responses. Always wrap calls in `try/catch`:
|
|
652
|
+
|
|
653
|
+
```typescript
|
|
654
|
+
try {
|
|
655
|
+
const response = await sdk.processVideo(videoFile, '12345678', 'Jane Doe');
|
|
656
|
+
// Handle success
|
|
657
|
+
} catch (error) {
|
|
658
|
+
console.error(error.message);
|
|
659
|
+
// Example: "Error 400: 'phrase' form value is required"
|
|
660
|
+
}
|
|
661
|
+
```
|
|
662
|
+
|
|
663
|
+
Common error scenarios:
|
|
664
|
+
|
|
665
|
+
| Scenario | When it happens |
|
|
666
|
+
|----------|-----------------|
|
|
667
|
+
| Missing API key | `new BiometrySDK('')` |
|
|
668
|
+
| Missing required parameter | e.g. calling `enrollFace` without a file or name |
|
|
669
|
+
| No face detected | Face enrollment with an image that has no detectable face |
|
|
670
|
+
| Multiple faces detected | Face enrollment with an image containing more than one face |
|
|
671
|
+
| Liveness check failed | Video processing detects a spoofing attempt |
|
|
672
|
+
| No speech detected | Voice enrollment with an audio file containing no speech |
|
|
673
|
+
| Network failure | Server unreachable or request timeout |
|
|
674
|
+
| Consent not given | Calling `enrollFace` or `enrollVoice` without storage consent |
|
|
675
|
+
| Prefilled video without session | Calling `matchFaces` with `usePrefilledVideo: true` but no `sessionId` |
|
|
676
|
+
| No video found for reuse | Using `usePrefilledVideo` in a session that has no prior `processVideo` call |
|
|
677
|
+
| Invalid document format | Calling `checkDocAuth` with a non-JPG/JPEG/PNG file |
|
|
678
|
+
| File size exceeded | Uploading a file larger than 50MB |
|
|
679
|
+
|
|
680
|
+
## Security & Privacy
|
|
681
|
+
|
|
682
|
+
1. **Protect your API key** — use environment variables or a server-side proxy. Never commit keys to source control.
|
|
683
|
+
2. **Obtain explicit consent** — always collect authorization and storage consent through your UI before calling biometric APIs.
|
|
684
|
+
3. **Data minimization** — only collect and store data that is necessary for your use case.
|
|
685
|
+
4. **Regulatory compliance** — check local regulations (GDPR, CCPA, etc.) regarding the collection and processing of biometric data.
|
|
686
|
+
|
|
687
|
+
## Examples
|
|
688
|
+
|
|
689
|
+
Working examples are available in the [`examples/`](./examples) directory:
|
|
690
|
+
|
|
691
|
+
- **[React example](./examples/react-example)** — full React app demonstrating SDK initialization, consent, face enrollment, and video processing
|
|
692
|
+
- **[HTML example](./examples/html-example)** — vanilla JavaScript integration without any framework
|
|
268
693
|
|
|
269
694
|
## License
|
|
270
695
|
|
|
271
|
-
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for
|
|
696
|
+
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
|
|
697
|
+
|
|
698
|
+
## Support
|
|
272
699
|
|
|
273
|
-
|
|
274
|
-
|
|
700
|
+
- [Biometry API Documentation](https://developer.biometrysolutions.com/overview/)
|
|
701
|
+
- [GitHub Issues](https://github.com/nicoogamer/biometry-web-sdk/issues)
|
|
702
|
+
- Contact our support team at [support@biometrysolutions.com](mailto:support@biometrysolutions.com)
|
package/dist/sdk/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ApiResponse } from "../types/internal";
|
|
2
|
-
import {
|
|
2
|
+
import { DocAuthResponse } from "../types/biometry/doc-auth";
|
|
3
3
|
import { ConsentResponse } from "../types/biometry/consent";
|
|
4
4
|
import { FaceEnrollmentResponse, VoiceEnrollmentResponse } from "../types/biometry/enrollment";
|
|
5
5
|
import { FaceMatchResponse } from "../types/biometry/face-match";
|
|
@@ -95,13 +95,13 @@ export declare class BiometrySDK {
|
|
|
95
95
|
* @param {string} [props.sessionId] - Session ID to link this enrollment with a specific session group.
|
|
96
96
|
* @param {object} [props.deviceInfo] - Device information object containing details about the user's device.
|
|
97
97
|
* This can include properties like operating system, browser, etc.
|
|
98
|
-
* @returns {Promise<ApiResponse<
|
|
98
|
+
* @returns {Promise<ApiResponse<DocAuthResponse>>} - A promise resolving to the document authentication response.
|
|
99
99
|
*/
|
|
100
100
|
checkDocAuth(document: File, userFullName: string, props?: {
|
|
101
101
|
sessionId?: string;
|
|
102
102
|
deviceInfo?: object;
|
|
103
103
|
inHouseCheck?: boolean;
|
|
104
|
-
}): Promise<ApiResponse<
|
|
104
|
+
}): Promise<ApiResponse<DocAuthResponse>>;
|
|
105
105
|
/**
|
|
106
106
|
* Matches a user's face from video against a reference image.
|
|
107
107
|
*
|
package/dist/sdk.js
CHANGED
|
@@ -185,7 +185,7 @@ class BiometrySDK {
|
|
|
185
185
|
* @param {string} [props.sessionId] - Session ID to link this enrollment with a specific session group.
|
|
186
186
|
* @param {object} [props.deviceInfo] - Device information object containing details about the user's device.
|
|
187
187
|
* This can include properties like operating system, browser, etc.
|
|
188
|
-
* @returns {Promise<ApiResponse<
|
|
188
|
+
* @returns {Promise<ApiResponse<DocAuthResponse>>} - A promise resolving to the document authentication response.
|
|
189
189
|
*/
|
|
190
190
|
async checkDocAuth(document, userFullName, props) {
|
|
191
191
|
if (!document)
|
package/dist/sdk.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.js","sources":["../src/sdk/index.ts"],"sourcesContent":["import { ApiResponse } from \"../types/internal\";\nimport { DocAuthInfo } from \"../types/biometry/doc-auth\";\nimport { ConsentResponse } from \"../types/biometry/consent\";\nimport { FaceEnrollmentResponse, VoiceEnrollmentResponse } from \"../types/biometry/enrollment\";\nimport { FaceMatchResponse } from \"../types/biometry/face-match\";\nimport { ProcessVideoResponse } from \"../types/biometry/process-video\";\nimport { SessionResponse } from \"../types/biometry/session\";\n\nexport class BiometrySDK {\n private apiKey: string;\n private static readonly BASE_URL: string = 'https://api.biometrysolutions.com'; //'https://dev-console.biometrysolutions.com';\n\n constructor(apiKey: string) {\n if (!apiKey) {\n throw new Error('API Key is required to initialize the SDK.');\n }\n\n this.apiKey = apiKey;\n }\n\n private async request<T>(path: string, method: string, body?: any, headers?: Record<string, string>):\n Promise<ApiResponse<T>> {\n const defaultHeaders: HeadersInit = {\n Authorization: `Bearer ${this.apiKey}`,\n };\n\n const requestHeaders = { ...defaultHeaders, ...headers };\n\n if (body && !(body instanceof FormData)) {\n requestHeaders['Content-Type'] = 'application/json';\n body = JSON.stringify(body);\n }\n const response = await fetch(`${BiometrySDK.BASE_URL}${path}`, {\n method,\n headers: requestHeaders,\n body,\n });\n\n if (!response.ok) {\n const errorData = await response.json().catch(() => ({}));\n const errorMessage = errorData?.error || errorData?.message || 'Unknown error occurred';\n\n throw new Error(`Error ${response.status}: ${errorMessage}`);\n }\n\n // 🔹 Extract ALL response headers\n const responseHeaders: Record<string, string> = {};\n response.headers.forEach((value, key) => {\n responseHeaders[key] = value;\n });\n\n const responseBody = await response.json();\n\n return {\n body: responseBody as T,\n headers: responseHeaders\n };\n }\n\n /**\n * Starts a new Session for a user.\n * \n * @returns {Promise<ApiResponse<SessionResponse>>} A promise resolving to the session ID.\n * @throws {Error} - If the request fails.\n */\n async startSession(): Promise<ApiResponse<SessionResponse>> {\n return await this.request<SessionResponse>(\n '/api-gateway/sessions/start',\n 'POST'\n );\n }\n\n /**\n * Submits Authorization consent for a user.\n * Authorization Consent is required to use the services like Face and Voice recognition.\n * \n * @param {boolean} isConsentGiven - Indicates whether the user has given consent.\n * @param {string} userFullName - The full name of the user giving consent.\n * @param {Object} [props] - Optional properties for the consent request.\n * @param {string} [props.sessionId] - Session ID to link this consent with a specific session group.\n * @param {object} [props.deviceInfo] - Device information object containing details about the user's device.\n * This can include properties like operating system, browser, etc.\n * @returns {Promise<ApiResponse<ConsentResponse>>} A promise resolving to the consent response.\n * @throws {Error} - If the user's full name is not provided or if the request fails.\n */\n async giveAuthorizationConsent(\n isConsentGiven: boolean,\n userFullName: string,\n props?: {\n sessionId?: string,\n deviceInfo?: object,\n }\n ): Promise<ApiResponse<ConsentResponse>> {\n if (!userFullName) {\n throw new Error('User Full Name is required to give consent.');\n }\n\n const body = {\n is_consent_given: isConsentGiven,\n user_fullname: userFullName,\n };\n\n const headers: Record<string, string> = {};\n\n if (props?.sessionId) {\n headers['X-Session-ID'] = props.sessionId;\n }\n\n if (props?.deviceInfo) {\n headers['X-Device-Info'] = JSON.stringify(props.deviceInfo);\n }\n\n return await this.request<ConsentResponse>(\n '/api-consent/consent',\n 'POST',\n body,\n headers\n );\n }\n\n /**\n * Submits Storage consent for a user.\n * Storage consent is granted by users, allowing us to store their biometric data for future verification.\n * \n * @param {boolean} isStorageConsentGiven - Indicates whether the user has given storage consent.\n * @param {string} userFullName - The full name of the user giving storage consent.\n * @param {Object} [props] - Optional properties for the consent request.\n * @param {string} [props.sessionId] - Session ID to link this consent with a specific session group.\n * @param {object} [props.deviceInfo] - Device information object containing details about the user's device.\n * This can include properties like operating system, browser, etc.\n * @returns {Promise<ApiResponse<ConsentResponse>>} A promise resolving to the consent response.\n * @throws {Error} - If the user's full name is not provided or if the request fails.\n */\n async giveStorageConsent(\n isStorageConsentGiven: boolean,\n userFullName: string,\n props?: {\n sessionId?: string,\n deviceInfo?: object,\n }\n ): Promise<ApiResponse<ConsentResponse>> {\n if (!userFullName) {\n throw new Error('User Full Name is required to give storage consent.');\n }\n\n const body = {\n is_consent_given: isStorageConsentGiven,\n user_fullname: userFullName,\n };\n\n const headers: Record<string, string> = {};\n\n if (props?.sessionId) {\n headers['X-Session-ID'] = props.sessionId;\n }\n\n if (props?.deviceInfo) {\n headers['X-Device-Info'] = JSON.stringify(props.deviceInfo);\n }\n\n return await this.request<ConsentResponse>(\n '/api-consent/strg-consent',\n 'POST',\n body,\n headers\n );\n }\n\n /**\n * Enrolls a user's voice for biometric authentication.\n * \n * @param {File} audio - The audio file containing the user's voice.\n * @param {string} userFullName - The full name of the user being enrolled.\n * @param {string} uniqueId - A unique identifier for the enrolling process.\n * @param {string} phrase - The phrase spoken in the audio file.\n * @param {Object} [props] - Optional properties for the enrollment request.\n * @param {string} [props.sessionId] - Session ID to link this enrollment with a specific session group.\n * @param {object} [props.deviceInfo] - Device information object containing details about the user's device.\n * This can include properties like operating system, browser, etc.\n * @returns {Promise<ApiResponse<VoiceEnrollmentResponse>>} - A promise resolving to the voice enrolling response.\n * @throws {Error} - If required parameters are missing or the request fails.\n */\n async enrollVoice(\n audio: File,\n userFullName: string,\n uniqueId: string,\n phrase: string,\n props?: {\n sessionId?: string,\n deviceInfo?: object,\n }\n ): Promise<ApiResponse<VoiceEnrollmentResponse>> {\n if (!userFullName) throw new Error('User fullname is required.');\n if (!uniqueId) throw new Error('Unique ID is required.');\n if (!phrase) throw new Error('Phrase is required.');\n if (!audio) throw new Error('Audio file is required.');\n\n const formData = new FormData();\n formData.append('unique_id', uniqueId);\n formData.append('phrase', phrase);\n formData.append('voice', audio);\n\n const headers: Record<string, string> = {\n 'X-User-Fullname': userFullName,\n };\n\n if (props?.sessionId) {\n headers['X-Session-ID'] = props.sessionId;\n }\n\n if (props?.deviceInfo) {\n headers['X-Device-Info'] = JSON.stringify(props.deviceInfo);\n }\n\n return await this.request<VoiceEnrollmentResponse>(\n '/api-gateway/enroll/voice',\n 'POST',\n formData,\n headers\n );\n }\n\n /**\n * Enrolls a user's face for biometric authentication.\n * \n * @param {File} face - Image file that contains user's face.\n * @param {string} userFullName - The full name of the user being enrolled.\n * @param {string} isDocument - Indicates whether the image is a document.\n * @param {Object} [props] - Optional properties for the enrollment request.\n * @param {string} [props.sessionId] - Session ID to link this enrollment with a specific session group.\n * @param {object} [props.deviceInfo] - Device information object containing details about the user's device.\n * This can include properties like operating system, browser, etc.\n * @returns {Promise<ApiResponse<FaceEnrollmentResponse>>} - A promise resolving to the voice enrolling response.\n * @throws {Error} - If required parameters are missing or the request fails.\n */\n async enrollFace(face: File, userFullName: string, isDocument?: boolean, props?: {\n sessionId?: string,\n deviceInfo?: object,\n }):\n Promise<ApiResponse<FaceEnrollmentResponse>> {\n if (!userFullName) throw new Error('User fullname is required.');\n if (!face) throw new Error('Face image is required.');\n\n const formData = new FormData();\n formData.append('face', face);\n if (isDocument) {\n formData.append('is_document', 'true');\n }\n\n const headers: Record<string, string> = {\n 'X-User-Fullname': userFullName,\n };\n\n if (props?.sessionId) {\n headers['X-Session-ID'] = props.sessionId;\n }\n\n if (props?.deviceInfo) {\n headers['X-Device-Info'] = JSON.stringify(props.deviceInfo);\n }\n\n return await this.request<FaceEnrollmentResponse>(\n '/api-gateway/enroll/face',\n 'POST',\n formData,\n headers\n );\n }\n\n /**\n * Check the validity of a documents.\n * \n * @param {File} document - Document image file.\n * @param {string} userFullName - The full name of the user being checked.\n * @param {Object} [props] - Optional properties for the enrollment request.\n * @param {string} [props.sessionId] - Session ID to link this enrollment with a specific session group.\n * @param {object} [props.deviceInfo] - Device information object containing details about the user's device.\n * This can include properties like operating system, browser, etc.\n * @returns {Promise<ApiResponse<DocAuthInfo>>} - A promise resolving to the document authentication information.\n */\n async checkDocAuth(\n document: File,\n userFullName: string,\n props?: {\n sessionId?: string,\n deviceInfo?: object,\n inHouseCheck?: boolean,\n }\n ): Promise<ApiResponse<DocAuthInfo>> {\n if (!document) throw new Error('Document image is required.');\n if (!userFullName) throw new Error('User fullname is required.');\n\n const formData = new FormData();\n formData.append('document', document);\n\n const headers: Record<string, string> = {\n 'X-User-Fullname': userFullName,\n };\n\n if (props?.sessionId) {\n headers['X-Session-ID'] = props.sessionId;\n }\n\n if (props?.deviceInfo) {\n headers['X-Device-Info'] = JSON.stringify(props.deviceInfo);\n }\n\n if (props?.inHouseCheck) {\n headers['X-Inhouse-Docauth'] = \"true\";\n }\n\n return await this.request<DocAuthInfo>(\n '/api-gateway/docauth/check',\n 'POST',\n formData,\n headers\n );\n }\n\n /**\n * Matches a user's face from video against a reference image.\n * \n * @param {File} image - Reference image file that contains user's face.\n * @param {string} video - Video file that contains user's face.\n * @param {string} userFullName - Pass the full name of end-user to process Voice and Face recognition services.\n * @param {string} processVideoRequestId - ID from the response header of /process-video endpoint.\n * @param {boolean} usePrefilledVideo - Pass true to use the video from the process-video endpoint.\n * @param {Object} [props] - Optional properties for the enrollment request.\n * @param {string} [props.sessionId] - Session ID to link this enrollment with a specific session group.\n * @param {object} [props.deviceInfo] - Device information object containing details about the user's device.\n * This can include properties like operating system, browser, etc.\n * @returns {Promise<FaceMatchResponse>} - A promise resolving to the voice enrolling response.\n * @throws {Error} - If required parameters are missing or the request fails.\n */\n async matchFaces(\n image: File,\n video?: File,\n userFullName?: string,\n usePrefilledVideo?: boolean,\n props?: {\n sessionId?: string,\n deviceInfo?: object,\n }\n ): Promise<ApiResponse<FaceMatchResponse>> {\n if (!image) throw new Error('Face image is required.');\n if ((!usePrefilledVideo) && !video) throw new Error('Video is required.');\n if (usePrefilledVideo && !props?.sessionId) throw new Error('Session ID is required to use a video from the process-video endpoint.');\n\n const formData = new FormData();\n if (video) {\n formData.append('video', video);\n }\n formData.append('image', image);\n\n const headers: Record<string, string> = {};\n\n if (userFullName) {\n headers['X-User-Fullname'] = userFullName;\n }\n\n if (usePrefilledVideo) {\n headers['X-Use-Prefilled-Video'] = 'true';\n }\n\n if (props?.sessionId) {\n headers['X-Session-ID'] = props.sessionId;\n }\n\n if (props?.deviceInfo) {\n headers['X-Device-Info'] = JSON.stringify(props.deviceInfo);\n }\n\n return await this.request<FaceMatchResponse>(\n '/api-gateway/match-faces',\n 'POST',\n formData,\n headers\n );\n }\n\n /**\n * Process the video through Biometry services to check liveness and authorize user\n * \n * @param {File} video - Video file that you want to process.\n * @param {string} phrase - Set of numbers that user needs to say out loud in the video.\n * @param {string} userFullName - Pass the full name of end-user to process Voice and Face recognition services.\n * @param {Object} [props] - Optional properties for the enrollment request.\n * @param {string} [props.sessionId] - Session ID to link this enrollment with a specific session group.\n * @param {object} [props.deviceInfo] - Device information object containing details about the user's device.\n * This can include properties like operating system, browser, etc.\n * @returns {Promise<ApiResponse<ProcessVideoResponse>>} - A promise resolving to the process video response.\n */\n async processVideo(\n video: File,\n phrase: string,\n userFullName?: string,\n props?: {\n sessionId?: string,\n deviceInfo?: object,\n }\n ): Promise<ApiResponse<ProcessVideoResponse>> {\n if (!video) throw new Error('Video is required.');\n if (!phrase) throw new Error('Phrase is required.');\n\n const formData = new FormData();\n formData.append('phrase', phrase);\n formData.append('video', video);\n\n const headers: Record<string, string> = {};\n\n if (userFullName) {\n headers['X-User-Fullname'] = userFullName;\n }\n\n if (props?.sessionId) {\n headers['X-Session-ID'] = props.sessionId;\n }\n\n if (props?.deviceInfo) {\n headers['X-Device-Info'] = JSON.stringify(props.deviceInfo);\n }\n\n return await this.request<ProcessVideoResponse>(\n '/api-gateway/process-video',\n 'POST',\n formData,\n headers\n );\n }\n}"],"names":[],"mappings":"MAQa,WAAW,CAAA;AAItB,IAAA,WAAA,CAAY,MAAc,EAAA;QACxB,IAAI,CAAC,MAAM,EAAE;AACX,YAAA,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC;QAC/D;AAEA,QAAA,IAAI,CAAC,MAAM,GAAG,MAAM;IACtB;IAEQ,MAAM,OAAO,CAAI,IAAY,EAAE,MAAc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AAE,UAAU,EAAE;AACrB,YAAA,OAAO,CAAC,eAAe,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC;QAC7D;AAEA,QAAA,OAAO,MAAM,IAAI,CAAC,OAAO,CACvB,4BAA4B,EAC5B,MAAM,EACN,QAAQ,EACR,OAAO,CACR;IACH;;AAlawB,WAAA,CAAA,QAAQ,GAAW,mCAAmC,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"sdk.js","sources":["../src/sdk/index.ts"],"sourcesContent":["import { ApiResponse } from \"../types/internal\";\nimport { DocAuthResponse } from \"../types/biometry/doc-auth\";\nimport { ConsentResponse } from \"../types/biometry/consent\";\nimport { FaceEnrollmentResponse, VoiceEnrollmentResponse } from \"../types/biometry/enrollment\";\nimport { FaceMatchResponse } from \"../types/biometry/face-match\";\nimport { ProcessVideoResponse } from \"../types/biometry/process-video\";\nimport { SessionResponse } from \"../types/biometry/session\";\n\nexport class BiometrySDK {\n private apiKey: string;\n private static readonly BASE_URL: string = 'https://api.biometrysolutions.com'; //'https://dev-console.biometrysolutions.com';\n\n constructor(apiKey: string) {\n if (!apiKey) {\n throw new Error('API Key is required to initialize the SDK.');\n }\n\n this.apiKey = apiKey;\n }\n\n private async request<T>(path: string, method: string, body?: any, headers?: Record<string, string>):\n Promise<ApiResponse<T>> {\n const defaultHeaders: HeadersInit = {\n Authorization: `Bearer ${this.apiKey}`,\n };\n\n const requestHeaders = { ...defaultHeaders, ...headers };\n\n if (body && !(body instanceof FormData)) {\n requestHeaders['Content-Type'] = 'application/json';\n body = JSON.stringify(body);\n }\n const response = await fetch(`${BiometrySDK.BASE_URL}${path}`, {\n method,\n headers: requestHeaders,\n body,\n });\n\n if (!response.ok) {\n const errorData = await response.json().catch(() => ({}));\n const errorMessage = errorData?.error || errorData?.message || 'Unknown error occurred';\n\n throw new Error(`Error ${response.status}: ${errorMessage}`);\n }\n\n // 🔹 Extract ALL response headers\n const responseHeaders: Record<string, string> = {};\n response.headers.forEach((value, key) => {\n responseHeaders[key] = value;\n });\n\n const responseBody = await response.json();\n\n return {\n body: responseBody as T,\n headers: responseHeaders\n };\n }\n\n /**\n * Starts a new Session for a user.\n * \n * @returns {Promise<ApiResponse<SessionResponse>>} A promise resolving to the session ID.\n * @throws {Error} - If the request fails.\n */\n async startSession(): Promise<ApiResponse<SessionResponse>> {\n return await this.request<SessionResponse>(\n '/api-gateway/sessions/start',\n 'POST'\n );\n }\n\n /**\n * Submits Authorization consent for a user.\n * Authorization Consent is required to use the services like Face and Voice recognition.\n * \n * @param {boolean} isConsentGiven - Indicates whether the user has given consent.\n * @param {string} userFullName - The full name of the user giving consent.\n * @param {Object} [props] - Optional properties for the consent request.\n * @param {string} [props.sessionId] - Session ID to link this consent with a specific session group.\n * @param {object} [props.deviceInfo] - Device information object containing details about the user's device.\n * This can include properties like operating system, browser, etc.\n * @returns {Promise<ApiResponse<ConsentResponse>>} A promise resolving to the consent response.\n * @throws {Error} - If the user's full name is not provided or if the request fails.\n */\n async giveAuthorizationConsent(\n isConsentGiven: boolean,\n userFullName: string,\n props?: {\n sessionId?: string,\n deviceInfo?: object,\n }\n ): Promise<ApiResponse<ConsentResponse>> {\n if (!userFullName) {\n throw new Error('User Full Name is required to give consent.');\n }\n\n const body = {\n is_consent_given: isConsentGiven,\n user_fullname: userFullName,\n };\n\n const headers: Record<string, string> = {};\n\n if (props?.sessionId) {\n headers['X-Session-ID'] = props.sessionId;\n }\n\n if (props?.deviceInfo) {\n headers['X-Device-Info'] = JSON.stringify(props.deviceInfo);\n }\n\n return await this.request<ConsentResponse>(\n '/api-consent/consent',\n 'POST',\n body,\n headers\n );\n }\n\n /**\n * Submits Storage consent for a user.\n * Storage consent is granted by users, allowing us to store their biometric data for future verification.\n * \n * @param {boolean} isStorageConsentGiven - Indicates whether the user has given storage consent.\n * @param {string} userFullName - The full name of the user giving storage consent.\n * @param {Object} [props] - Optional properties for the consent request.\n * @param {string} [props.sessionId] - Session ID to link this consent with a specific session group.\n * @param {object} [props.deviceInfo] - Device information object containing details about the user's device.\n * This can include properties like operating system, browser, etc.\n * @returns {Promise<ApiResponse<ConsentResponse>>} A promise resolving to the consent response.\n * @throws {Error} - If the user's full name is not provided or if the request fails.\n */\n async giveStorageConsent(\n isStorageConsentGiven: boolean,\n userFullName: string,\n props?: {\n sessionId?: string,\n deviceInfo?: object,\n }\n ): Promise<ApiResponse<ConsentResponse>> {\n if (!userFullName) {\n throw new Error('User Full Name is required to give storage consent.');\n }\n\n const body = {\n is_consent_given: isStorageConsentGiven,\n user_fullname: userFullName,\n };\n\n const headers: Record<string, string> = {};\n\n if (props?.sessionId) {\n headers['X-Session-ID'] = props.sessionId;\n }\n\n if (props?.deviceInfo) {\n headers['X-Device-Info'] = JSON.stringify(props.deviceInfo);\n }\n\n return await this.request<ConsentResponse>(\n '/api-consent/strg-consent',\n 'POST',\n body,\n headers\n );\n }\n\n /**\n * Enrolls a user's voice for biometric authentication.\n * \n * @param {File} audio - The audio file containing the user's voice.\n * @param {string} userFullName - The full name of the user being enrolled.\n * @param {string} uniqueId - A unique identifier for the enrolling process.\n * @param {string} phrase - The phrase spoken in the audio file.\n * @param {Object} [props] - Optional properties for the enrollment request.\n * @param {string} [props.sessionId] - Session ID to link this enrollment with a specific session group.\n * @param {object} [props.deviceInfo] - Device information object containing details about the user's device.\n * This can include properties like operating system, browser, etc.\n * @returns {Promise<ApiResponse<VoiceEnrollmentResponse>>} - A promise resolving to the voice enrolling response.\n * @throws {Error} - If required parameters are missing or the request fails.\n */\n async enrollVoice(\n audio: File,\n userFullName: string,\n uniqueId: string,\n phrase: string,\n props?: {\n sessionId?: string,\n deviceInfo?: object,\n }\n ): Promise<ApiResponse<VoiceEnrollmentResponse>> {\n if (!userFullName) throw new Error('User fullname is required.');\n if (!uniqueId) throw new Error('Unique ID is required.');\n if (!phrase) throw new Error('Phrase is required.');\n if (!audio) throw new Error('Audio file is required.');\n\n const formData = new FormData();\n formData.append('unique_id', uniqueId);\n formData.append('phrase', phrase);\n formData.append('voice', audio);\n\n const headers: Record<string, string> = {\n 'X-User-Fullname': userFullName,\n };\n\n if (props?.sessionId) {\n headers['X-Session-ID'] = props.sessionId;\n }\n\n if (props?.deviceInfo) {\n headers['X-Device-Info'] = JSON.stringify(props.deviceInfo);\n }\n\n return await this.request<VoiceEnrollmentResponse>(\n '/api-gateway/enroll/voice',\n 'POST',\n formData,\n headers\n );\n }\n\n /**\n * Enrolls a user's face for biometric authentication.\n * \n * @param {File} face - Image file that contains user's face.\n * @param {string} userFullName - The full name of the user being enrolled.\n * @param {string} isDocument - Indicates whether the image is a document.\n * @param {Object} [props] - Optional properties for the enrollment request.\n * @param {string} [props.sessionId] - Session ID to link this enrollment with a specific session group.\n * @param {object} [props.deviceInfo] - Device information object containing details about the user's device.\n * This can include properties like operating system, browser, etc.\n * @returns {Promise<ApiResponse<FaceEnrollmentResponse>>} - A promise resolving to the voice enrolling response.\n * @throws {Error} - If required parameters are missing or the request fails.\n */\n async enrollFace(face: File, userFullName: string, isDocument?: boolean, props?: {\n sessionId?: string,\n deviceInfo?: object,\n }):\n Promise<ApiResponse<FaceEnrollmentResponse>> {\n if (!userFullName) throw new Error('User fullname is required.');\n if (!face) throw new Error('Face image is required.');\n\n const formData = new FormData();\n formData.append('face', face);\n if (isDocument) {\n formData.append('is_document', 'true');\n }\n\n const headers: Record<string, string> = {\n 'X-User-Fullname': userFullName,\n };\n\n if (props?.sessionId) {\n headers['X-Session-ID'] = props.sessionId;\n }\n\n if (props?.deviceInfo) {\n headers['X-Device-Info'] = JSON.stringify(props.deviceInfo);\n }\n\n return await this.request<FaceEnrollmentResponse>(\n '/api-gateway/enroll/face',\n 'POST',\n formData,\n headers\n );\n }\n\n /**\n * Check the validity of a documents.\n * \n * @param {File} document - Document image file.\n * @param {string} userFullName - The full name of the user being checked.\n * @param {Object} [props] - Optional properties for the enrollment request.\n * @param {string} [props.sessionId] - Session ID to link this enrollment with a specific session group.\n * @param {object} [props.deviceInfo] - Device information object containing details about the user's device.\n * This can include properties like operating system, browser, etc.\n * @returns {Promise<ApiResponse<DocAuthResponse>>} - A promise resolving to the document authentication response.\n */\n async checkDocAuth(\n document: File,\n userFullName: string,\n props?: {\n sessionId?: string,\n deviceInfo?: object,\n inHouseCheck?: boolean,\n }\n ): Promise<ApiResponse<DocAuthResponse>> {\n if (!document) throw new Error('Document image is required.');\n if (!userFullName) throw new Error('User fullname is required.');\n\n const formData = new FormData();\n formData.append('document', document);\n\n const headers: Record<string, string> = {\n 'X-User-Fullname': userFullName,\n };\n\n if (props?.sessionId) {\n headers['X-Session-ID'] = props.sessionId;\n }\n\n if (props?.deviceInfo) {\n headers['X-Device-Info'] = JSON.stringify(props.deviceInfo);\n }\n\n if (props?.inHouseCheck) {\n headers['X-Inhouse-Docauth'] = \"true\";\n }\n\n return await this.request<DocAuthResponse>(\n '/api-gateway/docauth/check',\n 'POST',\n formData,\n headers\n );\n }\n\n /**\n * Matches a user's face from video against a reference image.\n * \n * @param {File} image - Reference image file that contains user's face.\n * @param {string} video - Video file that contains user's face.\n * @param {string} userFullName - Pass the full name of end-user to process Voice and Face recognition services.\n * @param {string} processVideoRequestId - ID from the response header of /process-video endpoint.\n * @param {boolean} usePrefilledVideo - Pass true to use the video from the process-video endpoint.\n * @param {Object} [props] - Optional properties for the enrollment request.\n * @param {string} [props.sessionId] - Session ID to link this enrollment with a specific session group.\n * @param {object} [props.deviceInfo] - Device information object containing details about the user's device.\n * This can include properties like operating system, browser, etc.\n * @returns {Promise<FaceMatchResponse>} - A promise resolving to the voice enrolling response.\n * @throws {Error} - If required parameters are missing or the request fails.\n */\n async matchFaces(\n image: File,\n video?: File,\n userFullName?: string,\n usePrefilledVideo?: boolean,\n props?: {\n sessionId?: string,\n deviceInfo?: object,\n }\n ): Promise<ApiResponse<FaceMatchResponse>> {\n if (!image) throw new Error('Face image is required.');\n if ((!usePrefilledVideo) && !video) throw new Error('Video is required.');\n if (usePrefilledVideo && !props?.sessionId) throw new Error('Session ID is required to use a video from the process-video endpoint.');\n\n const formData = new FormData();\n if (video) {\n formData.append('video', video);\n }\n formData.append('image', image);\n\n const headers: Record<string, string> = {};\n\n if (userFullName) {\n headers['X-User-Fullname'] = userFullName;\n }\n\n if (usePrefilledVideo) {\n headers['X-Use-Prefilled-Video'] = 'true';\n }\n\n if (props?.sessionId) {\n headers['X-Session-ID'] = props.sessionId;\n }\n\n if (props?.deviceInfo) {\n headers['X-Device-Info'] = JSON.stringify(props.deviceInfo);\n }\n\n return await this.request<FaceMatchResponse>(\n '/api-gateway/match-faces',\n 'POST',\n formData,\n headers\n );\n }\n\n /**\n * Process the video through Biometry services to check liveness and authorize user\n * \n * @param {File} video - Video file that you want to process.\n * @param {string} phrase - Set of numbers that user needs to say out loud in the video.\n * @param {string} userFullName - Pass the full name of end-user to process Voice and Face recognition services.\n * @param {Object} [props] - Optional properties for the enrollment request.\n * @param {string} [props.sessionId] - Session ID to link this enrollment with a specific session group.\n * @param {object} [props.deviceInfo] - Device information object containing details about the user's device.\n * This can include properties like operating system, browser, etc.\n * @returns {Promise<ApiResponse<ProcessVideoResponse>>} - A promise resolving to the process video response.\n */\n async processVideo(\n video: File,\n phrase: string,\n userFullName?: string,\n props?: {\n sessionId?: string,\n deviceInfo?: object,\n }\n ): Promise<ApiResponse<ProcessVideoResponse>> {\n if (!video) throw new Error('Video is required.');\n if (!phrase) throw new Error('Phrase is required.');\n\n const formData = new FormData();\n formData.append('phrase', phrase);\n formData.append('video', video);\n\n const headers: Record<string, string> = {};\n\n if (userFullName) {\n headers['X-User-Fullname'] = userFullName;\n }\n\n if (props?.sessionId) {\n headers['X-Session-ID'] = props.sessionId;\n }\n\n if (props?.deviceInfo) {\n headers['X-Device-Info'] = JSON.stringify(props.deviceInfo);\n }\n\n return await this.request<ProcessVideoResponse>(\n '/api-gateway/process-video',\n 'POST',\n formData,\n headers\n );\n }\n}"],"names":[],"mappings":"MAQa,WAAW,CAAA;AAItB,IAAA,WAAA,CAAY,MAAc,EAAA;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O,CAAC,iBAAiB,CAAC,GAAG,YAAY;QAC3C;AAEA,QAAA,IAAI,KAAK,EAAE,SAAS,EAAE;AACpB,YAAA,OAAO,CAAC,cAAc,CAAC,GAAG,KAAK,CAAC,SAAS;QAC3C;AAEA,QAAA,IAAI,KAAK,EAAE,UAAU,EAAE;AACrB,YAAA,OAAO,CAAC,eAAe,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC;QAC7D;AAEA,QAAA,OAAO,MAAM,IAAI,CAAC,OAAO,CACvB,4BAA4B,EAC5B,MAAM,EACN,QAAQ,EACR,OAAO,CACR;IACH;;AAlawB,WAAA,CAAA,QAAQ,GAAW,mCAAmC,CAAC;;;;"}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
type Base64String = string & {
|
|
2
2
|
readonly __brand: unique symbol;
|
|
3
3
|
};
|
|
4
|
+
export interface DocAuthResponse {
|
|
5
|
+
data: DocAuthInfo;
|
|
6
|
+
scoring_result: string;
|
|
7
|
+
message: string;
|
|
8
|
+
}
|
|
4
9
|
export interface DocAuthInfo {
|
|
5
10
|
document_type: string;
|
|
6
11
|
country_code: string;
|
|
@@ -19,7 +24,17 @@ export interface DocAuthInfo {
|
|
|
19
24
|
issuing_state: string;
|
|
20
25
|
front_document_type_id: string;
|
|
21
26
|
contains_rfid: boolean;
|
|
22
|
-
|
|
27
|
+
face_image_base64?: string;
|
|
28
|
+
current_result?: string;
|
|
29
|
+
mrz_validation?: MRZValidation;
|
|
23
30
|
errors?: string[];
|
|
24
31
|
}
|
|
32
|
+
export interface MRZValidation {
|
|
33
|
+
has_mrz: boolean;
|
|
34
|
+
raw_mrz?: string;
|
|
35
|
+
check_digits_valid: boolean;
|
|
36
|
+
fields_match: boolean;
|
|
37
|
+
discrepancies?: string[];
|
|
38
|
+
validation_performed: boolean;
|
|
39
|
+
}
|
|
25
40
|
export {};
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { DocAuthInfo } from "./doc-auth";
|
|
2
2
|
export interface VoiceEnrollmentResponse {
|
|
3
|
+
data: VoiceEnrollmentData;
|
|
4
|
+
message: string;
|
|
5
|
+
}
|
|
6
|
+
export interface VoiceEnrollmentData {
|
|
3
7
|
status: "good" | "qafailed" | "enrolled" | "error";
|
|
4
8
|
qa_combined: QualityResultList | null;
|
|
5
9
|
qa_list: QualityResultList[];
|
|
@@ -26,7 +30,7 @@ interface RecognitionHypothesis {
|
|
|
26
30
|
}
|
|
27
31
|
export interface FaceEnrollmentResponse {
|
|
28
32
|
data: {
|
|
29
|
-
|
|
33
|
+
enrollment_result: FaceEnrollmentResult;
|
|
30
34
|
document_auth?: DocAuthInfo;
|
|
31
35
|
};
|
|
32
36
|
message?: string;
|