biometry-sdk 2.3.5 → 2.3.7

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 CHANGED
@@ -1,274 +1,698 @@
1
- # biometry-sdk
2
-
3
- ## Overview
4
- The **Biometry Web SDK** is a software development kit designed to simplify the integration of Biometry's API services into your web application. Providing tools and utilities enables biometric enrollment (face and voice), liveness checks, and user consent.
5
-
6
- We also have UI component library for [React](https://www.npmjs.com/package/biometry-react-components). You can you this SDK in combination with it.
7
-
8
- ## Table of Contents:
9
- - [Installation](#installation)
10
- - [Basic Usage (Direct SDK Methods)](#basic-usage-direct-sdk-methods)
11
- - [Sessions](#1-sessions)
12
- - [Consents](#2-consents)
13
- - [1.1 Give Authorization Consent](#21-give-authorization-consent)
14
- - [1.2 Give Storage Consent](#22-give-storage-consent)
15
- - [Face Enrollment](#3-face-enrollment)
16
- - [Voice Enrollment](#4-voice-enrollment)
17
- - [Process Video](#5-process-video)
18
- - [Face Match](#6-face-match)
19
- - [DocAuth](#7-docauth)
20
- - [Advanced Usage And Best Practices](#advanced-usage-and-best-practices)
21
- - [Typical FaceMatch Flow](#typical-facematch-flow)
22
- - [Error Handling](#error-handling)
23
- - [Header Retrieval](#header-retrieval)
24
- - [Security And Privacy Considerations](#security-and-privacy-considerations)
25
- - [License](#license)
26
- - [More Information](#more-information)
27
- - [Quick Reference](#quick-reference)
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
+ - **Face matching** compare a reference image against a video to verify identity
15
+ - **Document authentication** — extract and validate data from ID documents (passports, ID cards, etc.)
16
+ - **Full TypeScript support** — ships with complete type definitions
17
+ - **Framework-agnostic** — works with React, Angular, Vue, vanilla JS, or any web framework
18
+
19
+ ## Getting Started
20
+
21
+ ### Prerequisites
22
+
23
+ - An active Biometry project with an **API key** (obtain one from the [Biometry Dashboard](https://console.biometrysolutions.com))
24
+ - Node.js 16+ (for npm-based projects) or any modern browser with ES module support
25
+
26
+ ### Installation
27
+
31
28
  ```bash
32
29
  npm install biometry-sdk
33
30
  ```
34
31
 
35
- ## Basic Usage (Direct SDK Methods)
36
- After installing, import and instantiate the BiometrySDK:
32
+ ### Initialization
33
+
37
34
  ```typescript
38
35
  import { BiometrySDK } from 'biometry-sdk';
39
36
 
40
- // Initialize the SDK with your API key
41
37
  const sdk = new BiometrySDK('YOUR_API_KEY');
42
38
  ```
43
39
 
44
- ### Example
45
- You can find an example in the example/ directory. The example demonstrates how you might integrate the BiometrySDK in a React component with the state.
46
-
47
- ## 1. Sessions
48
- Session is a way to group transactions together. It is useful when you want to group transactions that are related to each other. For example, you can start a session and then use the session ID to link transactions within a unified group.
49
-
50
- Note: Use sessions generated by Biometry for API calls. Biometry sessions always have `sess_` prefix. Do not use own uuids or any other values.
51
-
52
- Example:
53
- ```javascript
54
- const response = await sdk.startSession(); // returns uuid with `sess_` prefix
55
- const sessionId = response.data;
56
-
57
- const voiceFile = new File([/* voice audio bytes */], 'voice.wav', { type: 'audio/wav' });
58
- const faceFile = new File([/* face image bytes */], 'face.jpg', { type: 'image/jpeg' });
59
-
60
- // Use the session ID in X-Session-Id header to link transactions within a unified group
61
- await sdk.giveStorageConsent(true, 'John Doe', { sessionId });
62
- await sdk.enrollFace(faceFile, 'John Doe', { sessionId });
63
- await sdk.enrollVoice(voiceFile, 'John Doe', { sessionId });
64
-
65
- // Go to the Results page in your dashboard and see the transactions grouped by the session ID
66
- ```
67
-
68
- ## 2. Consents
69
- ### 2.1 Give Authorization Consent
70
- You **must** obtain user authorization consent before performing any biometric operations (Face Recognition, Voice Recognition, etc.):
71
- ```javascript
72
- await sdk.giveAuthorizationConsent(true, 'John Doe');
73
- // or
74
- sdk.giveAuthorizationConsent(true, 'John Doe').then(() => {
75
- console.log('Consent given');
76
- });
77
- ```
78
- - The first argument (`true`) indicates that the user has granted consent.
79
- - The second argument is the user's full name (used for record-keeping within Biometry).
80
-
81
- ### 2.2 Give Storage Consent
82
- You **must** obtain user consent before storing biometric data (Face Enrollment, Voice Enrollment):
83
- ```javascript
84
- await sdk.giveStorageConsent(true, 'John Doe');
85
- // or
86
- sdk.giveStorageConsent(true, 'John Doe').then(() => {
87
- console.log('Consent given');
88
- });
89
- ```
90
- - The first argument (`true`) indicates that the user has granted consent.
91
- - The second argument is the user's full name (used for record-keeping within Biometry).
92
-
93
- ## 3. Face Enrollment
94
- Enroll a user's face for future recognition or matching:
95
- ```javascript
96
- const faceFile = new File([/* face image bytes */], 'face.jpg', { type: 'image/jpeg' });
97
-
98
- await sdk.giveStorageConsent(true, 'John Doe');
99
- const faceResponse = await sdk.enrollFace(faceFile, 'John Doe');
100
- console.log('Face Enrollment Response:', faceResponse);
101
- ```
102
-
103
- ## 4. Voice Enrollment
104
- Enroll a user's voice for future authentication checks:
105
- ```javascript
106
- const voiceFile = new File([/* voice audio bytes */], 'voice.wav', { type: 'audio/wav' });
107
-
108
- await sdk.giveStorageConsent(true, 'John Doe');
109
- const voiceResponse = await sdk.enrollVoice(voiceFile, 'John Doe');
110
- console.log('Voice Enrollment Response:', voiceResponse);
111
- ```
112
- ## 5. Process Video
113
- Process a user's video for liveness checks and identity authorization:
114
- ```javascript
115
- const videoFile = new File([/* file parts */], 'video.mp4', { type: 'video/mp4' });
116
- const phrase = "one two three four five six";
117
- const userFullName = 'John Doe';
118
-
119
- await sdk.giveAuthorizationConsent(true, userFullName);
120
-
121
- try {
122
- const response = await sdk.processVideo(videoFile, phrase, userFullName);
123
- console.log('Process Video Response:', response);
124
- } catch (error) {
125
- console.error('Error processing video:', error);
126
- }
127
- ```
128
-
129
- ### 6. Face match
130
- Use matchFaces to compare a reference image (e.g., a document or a captured selfie) with a face from a video:
131
- ```javascript
132
- const faceFile = new File([/* face image bytes */], 'face.jpg', { type: 'image/jpeg' });
133
- const videoFile = new File([/* file parts */], 'video.mp4', { type: 'video/mp4' });
134
- const userFullName = 'John Doe';
135
-
136
- const faceMatchResponse = await sdk.faceMatch(
137
- faceFile,
138
- videoFile,
139
- userFullName
140
- );
141
- ```
142
-
143
- You can also reuse a video that was previously processed with the `processVideo` method by passing the same sessionId:
144
- ```javascript
145
- const sessionId = await sdk.startSession();
146
-
147
- // First, process a video with a sessionId
148
- const processVideoResponse = await sdk.processVideo(videoFile, phrase, userFullName, { sessionId });
149
-
150
- // Later, reuse the same video for face matching by providing the sessionId
151
- const faceMatchResponse = await sdk.faceMatch(
152
- faceFile,
153
- null, // No need to pass the video file again
154
- userFullName,
155
- true, // usePrefilledVideo
156
- { sessionId }
157
- );
158
- ```
159
-
160
- ### 7. DocAuth
161
- DocAuth is a way to authenticate a user's document. It is useful when you want to authenticate a user's document.
162
- ```javascript
163
- const sessionId = await sdk.startSession();
164
-
165
- const documentFile = new File([/* file parts */], 'document.jpg', { type: 'image/jpeg' });
166
- const userFullName = 'John Doe';
167
-
168
- await sdk.giveAuthorizationConsent(true, userFullName, { sessionId });
169
-
170
- try {
171
- const response = await sdk.checkDocAuth(documentFile, userFullName, { sessionId, inHouseCheck: true });
172
- console.log('DocAuth Response:', response);
173
- } catch (error) {
174
- console.error('Error checking document:', error);
175
- }
176
- ```
177
-
178
- ## Advanced Usage And Best Practices
179
- ### Typical FaceMatch Flow
180
- One common advanced scenario involves document authentication in enrollment face and face matching:
181
- 1. Face Enrollment: Capture the user's live face or the user uploads a picture of their identity document (front side with the face)
182
- 2. Process Video: Capture the user's live face
183
- 3. Face Match: Compare the extracted face from the document with the user's live face to verify identity.
184
-
185
- Below is a possible flow (method names in your SDK may vary slightly depending on your integration setup):
186
- ```javascript
187
- // 1. Acquire user storage consent
188
- await sdk.giveStorageConsent(true, userFullName);
189
-
190
- // 2. Enroll or capture the user's face
191
- // (Either using enrollFace or processVideo, depending on your user flow)
192
- const userFaceFile = new File([/* user selfie bytes */], 'image.jpg', { type: 'image/jpeg' });
193
- const userVideoFile = new File([/* user selfie bytes */], 'video.mp4', { type: 'video/*' });
194
- const enrollResponse = await sdk.enrollFace(userFaceFile, userFullName);
195
-
196
- // 3. Acquire user authorization consent. It's required to use enrolled face for using biometric data.
197
- await sdk.giveAuthorizationConsent(true, userFullName);
198
-
199
- // 4. Face Match (Compare video face with user's enrolled face)
200
- const faceMatchResponse = await sdk.faceMatch(
201
- userFaceFile,
202
- userVideoFile,
203
- userFullName
204
- );
205
-
206
- // 5. Evaluate the faceMatch result
207
- if (faceMatchResponse.matchResult === 'match') {
208
- console.log('User video face matches user's live face. Identity verified!');
209
- } else {
210
- console.log('User video face does NOT match. Additional verification needed.');
211
- }
212
- ```
213
-
214
- ### Error Handling
215
- All SDK calls can throw errors for various reasons:
216
- - Network/Connection Issues
217
- - Invalid File Types
218
- - No Face Detected (Face Enrollment)
219
- - No Speech Detected (Voice Enrollment)
220
- - Multiple Faces Detected (Face Enrollment)
221
- - Liveness Check Failure (Process Video)
222
-
223
- Always wrap calls in try/catch and provide user-friendly messages or fallback logic.
224
- ```javascript
225
- try {
226
- const response = await sdk.faceMatch(...);
227
- // handle success
228
- } catch (error) {
229
- // handle error
230
- console.error('Face match error:', error);
231
- }
232
- ```
233
-
234
- ### Header Retrieval
235
- In addition to the response body, all SDK calls also return response headers.
236
- This is useful for retrieving metadata such as request and session IDs, or debugging information.
237
-
238
- Each API call returns an object of type:
239
-
240
- ```ts
241
- export interface ApiResponse<T> {
242
- body: T;
243
- headers: Record<string, string>;
244
- }
245
- ```
246
- For example, when calling the processVideo method, you can access both the response data and headers:
247
- ```ts
248
- try {
249
- const response = await sdk.processVideo(videoFile, "12345678", "John Doe");
250
-
251
- // Access the response body
252
- console.log("Process video result:", response.body);
253
-
254
- // Access headers (e.g., request ID)
255
- console.log("Request ID:", response.headers["x-request-id"]);
256
- } catch (error) {
257
- console.error("Process video failed:", error);
258
- }
259
- ```
260
- This pattern applies to all SDK methods, so you can always extract useful metadata from headers in addition to the main response.
261
-
262
-
263
- ### Security And Privacy Considerations
264
- 1. **Protect Your API Key:** Avoid storing your API key in client-side code if possible. Use environment variables or server-side proxies.
265
- 2. **Obtain Explicit Consent:** Ensure you have a transparent process for obtaining and storing user consent.
266
- 3. **Data Minimization:** Only store data that is required for your use case.
267
- 4. **Regulatory Compliance:** Check local regulations (GDPR, CCPA, etc.) for storing and processing biometric data.
40
+ 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.
41
+
42
+ > **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.
43
+
44
+ ## Response Structure
45
+
46
+ All gateway API responses follow a standard envelope format:
47
+
48
+ ```text
49
+ {
50
+ "data": { ... },
51
+ "scoring_result": "pass" | "fail" | "refer" | { ... },
52
+ "score": 0.95,
53
+ "decision_reasons": ["reason1", "reason2"],
54
+ "message": "human-readable status message"
55
+ }
56
+ ```
57
+
58
+ | Field | Type | Description |
59
+ |-------|------|-------------|
60
+ | `data` | `object` | The primary response payload (service results, extracted data, etc.) |
61
+ | `scoring_result` | `string \| object` | Scoring outcome — `"pass"`, `"fail"`, or `"refer"` for video processing and document auth; a detailed scoring map for face matching |
62
+ | `score` | `number` | Numeric confidence score (0–1), present on video processing responses |
63
+ | `decision_reasons` | `string[]` | Reasons for a fail/refer decision (e.g. `["liveness_failed"]`) |
64
+ | `message` | `string` | Human-readable status message |
65
+
66
+ The SDK wraps this in an `ApiResponse<T>` object that also includes the HTTP response headers:
67
+
68
+ ```typescript
69
+ interface ApiResponse<T> {
70
+ body: T; // Response payload (the envelope above)
71
+ headers: Record<string, string>; // HTTP response headers
72
+ }
73
+ ```
74
+
75
+ Not all fields are present on every response only relevant fields are included (empty/zero fields are omitted).
76
+
77
+ ## Usage
78
+
79
+ ### Sessions
80
+
81
+ Sessions group related transactions together so they appear as a single flow in the Biometry Dashboard.
82
+
83
+ ```typescript
84
+ const session = await sdk.startSession();
85
+ const sessionId = session.body.data; // "sess_xxxxxxxx-xxxx-..."
86
+
87
+ // Pass sessionId to subsequent calls to link them together
88
+ await sdk.giveStorageConsent(true, 'Jane Doe', { sessionId });
89
+ await sdk.enrollFace(faceFile, 'Jane Doe', false, { sessionId });
90
+ ```
91
+
92
+ ### Consent
93
+
94
+ Consent must be collected **before** performing biometric operations. There are two types:
95
+
96
+ | Type | Required before | Method |
97
+ |------|----------------|--------|
98
+ | **Authorization** | Face recognition, voice recognition, face matching | `giveAuthorizationConsent()` |
99
+ | **Storage** | Face enrollment, voice enrollment | `giveStorageConsent()` |
100
+
101
+ ```typescript
102
+ // Authorization consent required for recognition/verification operations
103
+ await sdk.giveAuthorizationConsent(true, 'Jane Doe');
104
+
105
+ // Storage consent required for enrollment operations
106
+ await sdk.giveStorageConsent(true, 'Jane Doe');
107
+ ```
108
+
109
+ Both methods accept optional `sessionId` and `deviceInfo`:
110
+
111
+ ```typescript
112
+ await sdk.giveAuthorizationConsent(true, 'Jane Doe', {
113
+ sessionId: 'sess_abc123',
114
+ deviceInfo: { os: 'iOS', browser: 'Safari' },
115
+ });
116
+ ```
117
+
118
+ > **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.
119
+
120
+ > **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.
121
+
122
+ ### Face Enrollment
123
+
124
+ Register a user's face for future matching. Requires **storage consent** first.
125
+
126
+ ```typescript
127
+ const faceFile = new File([imageBytes], 'face.jpg', { type: 'image/jpeg' });
128
+
129
+ await sdk.giveStorageConsent(true, 'Jane Doe');
130
+ const response = await sdk.enrollFace(faceFile, 'Jane Doe');
131
+
132
+ // Response envelope:
133
+ // {
134
+ // "data": {
135
+ // "enrollment_result": { "code": 0, "description": "Face enrolled successfully" },
136
+ // "document_auth": null
137
+ // },
138
+ // "message": "face enrolled successfully"
139
+ // }
140
+
141
+ console.log(response.body.data.enrollment_result);
142
+ // { code: 0, description: "Face enrolled successfully" }
143
+ ```
144
+
145
+ If enrolling from an ID document image (e.g. passport photo), set `isDocument` to `true`. This improves face detection accuracy for document photos:
146
+
147
+ ```typescript
148
+ const response = await sdk.enrollFace(documentImage, 'Jane Doe', true);
149
+ ```
150
+
151
+ When `isDocument` is `true`, the response may include `document_auth` with extracted document data alongside the enrollment result.
152
+
153
+ An `enrollment_result.code` of `0` means success. Non-zero codes indicate a failure (e.g. no face detected, multiple faces detected).
154
+
155
+ ### Voice Enrollment
156
+
157
+ Register a user's voice for speaker verification. Requires **storage consent** first.
158
+
159
+ ```typescript
160
+ const audioFile = new File([audioBytes], 'voice.wav', { type: 'audio/wav' });
161
+
162
+ await sdk.giveStorageConsent(true, 'Jane Doe');
163
+ const response = await sdk.enrollVoice(
164
+ audioFile,
165
+ 'Jane Doe',
166
+ 'jane-doe-id', // unique identifier
167
+ 'one two three' // the phrase spoken in the audio
168
+ );
169
+
170
+ // Response envelope:
171
+ // {
172
+ // "data": {
173
+ // "status": "good",
174
+ // "qa_combined": { ... },
175
+ // "qa_list": [...]
176
+ // },
177
+ // "message": "voice registered successfully"
178
+ // }
179
+
180
+ console.log(response.body.data.status); // "good" | "qafailed" | "enrolled" | "error"
181
+ ```
182
+
183
+ > **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.
184
+
185
+ ### Video Processing (Liveness & Recognition)
186
+
187
+ Process a video to perform up to five biometric checks in a single request:
188
+
189
+ 1. **Face Liveness Detection** determines if the face in the video is a real person (not a photo/screen replay)
190
+ 2. **Active Speaker Detection** verifies the person is actively speaking
191
+ 3. **Visual Speech Recognition** — reads lips to verify the spoken phrase matches
192
+ 4. **Face Recognition** identifies the face against enrolled faces (requires authorization consent)
193
+ 5. **Voice Recognition** — verifies the speaker's voice against enrolled voiceprints (requires authorization consent)
194
+
195
+ ```typescript
196
+ const videoFile = new File([videoBytes], 'video.mp4', { type: 'video/mp4' });
197
+
198
+ await sdk.giveAuthorizationConsent(true, 'Jane Doe');
199
+ const response = await sdk.processVideo(videoFile, '12345678', 'Jane Doe');
200
+
201
+ // Response envelope:
202
+ // {
203
+ // "data": {
204
+ // "Face Liveness Detection": { "code": 0, "description": "Real face detected", "result": true },
205
+ // "Active Speaker Detection": { "code": 0, "description": "Active speaker detected", "result": 1 },
206
+ // "Visual Speech Recognition": { "code": 0, "description": "...", "result": "12345678" },
207
+ // "Face Recognition": { "code": 0, "description": "Face identified" },
208
+ // "Voice Recognition": { "status": "good", "id": "Jane_Doe", "score": 0.92, ... }
209
+ // },
210
+ // "scoring_result": "pass",
211
+ // "score": 0.95,
212
+ // "decision_reasons": [],
213
+ // "message": "video processed successfully"
214
+ // }
215
+
216
+ console.log(response.body.scoring_result); // "pass" | "fail" | "refer"
217
+ console.log(response.body.data['Face Liveness Detection'].result); // true or false
218
+ console.log(response.body.data['Visual Speech Recognition'].result); // the recognized phrase
219
+ ```
220
+
221
+ 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.
222
+
223
+ The `scoring_result` field indicates the overall outcome:
224
+ - `"pass"` all checks passed
225
+ - `"fail"` — one or more checks failed
226
+ - `"refer"` needs manual review
227
+
228
+ When the result is `"fail"` or `"refer"`, check `decision_reasons` for specific failure causes.
229
+
230
+ #### Auto-Enrollment
231
+
232
+ 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.
233
+
234
+ Auto-enrollment behavior:
235
+ - **Face**: Enrolled from the video if the user's face is not already enrolled
236
+ - **Voice**: Enrolled from the video audio if the user's voice is not already enrolled for the given phrase
237
+ - **Response header**: `X-Auto-Enroll: true` is set when auto-enrollment is triggered
238
+ - **Non-blocking**: Enrollment happens asynchronously and does not affect the video processing response
239
+
240
+ ```typescript
241
+ // Collect both consents to enable auto-enrollment
242
+ await sdk.giveStorageConsent(true, 'Jane Doe', { sessionId });
243
+ await sdk.giveAuthorizationConsent(true, 'Jane Doe', { sessionId });
244
+
245
+ // processVideo will now auto-enroll face and voice in the background
246
+ const response = await sdk.processVideo(videoFile, '12345678', 'Jane Doe', { sessionId });
247
+
248
+ // Check if auto-enrollment was triggered
249
+ if (response.headers['x-auto-enroll'] === 'true') {
250
+ console.log('Face and voice enrolled automatically');
251
+ }
252
+ ```
253
+
254
+ > **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.
255
+
256
+ ### Face Matching
257
+
258
+ Compare a reference image (selfie, ID photo, etc.) against a face from a video to verify identity.
259
+
260
+ **Option A Provide both image and video:**
261
+
262
+ ```typescript
263
+ const imageFile = new File([imgBytes], 'face.jpg', { type: 'image/jpeg' });
264
+ const videoFile = new File([vidBytes], 'video.mp4', { type: 'video/mp4' });
265
+
266
+ const response = await sdk.matchFaces(imageFile, videoFile, 'Jane Doe');
267
+
268
+ // Response envelope:
269
+ // {
270
+ // "data": {
271
+ // "code": 0,
272
+ // "result": 1,
273
+ // "description": "Successful check",
274
+ // "anchor": { "code": 0, "description": "One face found in the image" },
275
+ // "target": { "code": 0, "description": "One face found in the video" }
276
+ // },
277
+ // "scoring_result": { "status": "pass", ... },
278
+ // "decision_reasons": [],
279
+ // "message": "faces match result is here"
280
+ // }
281
+
282
+ console.log(response.body.data.result); // 1 = match, 0 = no match
283
+ console.log(response.body.data.description); // "Successful check"
284
+ ```
285
+
286
+ | `data.result` | Meaning |
287
+ |-------|---------|
288
+ | `1` | Faces match |
289
+ | `0` | Faces do not match |
290
+
291
+ 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.
292
+
293
+ **Option B — Reuse video from a previous `processVideo` call:**
294
+
295
+ If you already called `processVideo` with a `sessionId`, you can skip uploading the video again:
296
+
297
+ ```typescript
298
+ const session = await sdk.startSession();
299
+ const sessionId = session.body.data;
300
+
301
+ // Step 1: Process video within the session
302
+ await sdk.processVideo(videoFile, '12345678', 'Jane Doe', { sessionId });
303
+
304
+ // Step 2: Match faces reusing the same video
305
+ const response = await sdk.matchFaces(
306
+ imageFile, // Reference image
307
+ undefined, // No video file needed
308
+ 'Jane Doe',
309
+ true, // usePrefilledVideo
310
+ { sessionId } // Same session ID
311
+ );
312
+ ```
313
+
314
+ ### Document Authentication
315
+
316
+ Extract and validate information from identity documents (passports, ID cards, driver's licenses). Only JPG, JPEG, and PNG images are accepted.
317
+
318
+ ```typescript
319
+ const docFile = new File([docBytes], 'passport.jpg', { type: 'image/jpeg' });
320
+
321
+ await sdk.giveAuthorizationConsent(true, 'Jane Doe', { sessionId });
322
+ const response = await sdk.checkDocAuth(docFile, 'Jane Doe', {
323
+ sessionId,
324
+ inHouseCheck: true,
325
+ });
326
+
327
+ // Response envelope:
328
+ // {
329
+ // "data": {
330
+ // "document_type": "National Identification Card",
331
+ // "first_name": "JANE",
332
+ // "last_name": "DOE",
333
+ // "birth_date": "1990-01-01",
334
+ // "document_number": "AB1234567",
335
+ // "country_code": "AUS",
336
+ // "sex": "FEMALE",
337
+ // "expiry_date": "2028-08-01",
338
+ // "portrait_photo": "<base64>",
339
+ // "face_image_base64": "<base64>",
340
+ // "current_result": "Passed",
341
+ // ...
342
+ // },
343
+ // "scoring_result": "pass",
344
+ // "message": "Document uploaded successfully, looks like it's authentic"
345
+ // }
346
+
347
+ const doc = response.body.data;
348
+ console.log(doc.first_name); // "JANE" (uppercase)
349
+ console.log(doc.last_name); // "DOE" (uppercase)
350
+ console.log(doc.document_number); // "AB1234567"
351
+ console.log(doc.document_type); // "National Identification Card"
352
+ console.log(doc.portrait_photo); // Base64-encoded photo from document OCR
353
+ console.log(doc.face_image_base64); // Base64-encoded cropped face image
354
+ ```
355
+
356
+ > **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.
357
+
358
+ The `scoring_result` field indicates document validation outcome: `"pass"` if the document looks authentic, `"fail"` otherwise.
359
+
360
+ 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.
361
+
362
+ ## Common Flows
363
+
364
+ ### Identity Verification (KYC)
365
+
366
+ A typical identity verification flow combines consent, liveness, and face matching:
367
+
368
+ ```typescript
369
+ const sdk = new BiometrySDK('YOUR_API_KEY');
370
+ const session = await sdk.startSession();
371
+ const sessionId = session.body.data;
372
+ const userName = 'Jane Doe';
373
+
374
+ // 1. Collect both consents
375
+ await sdk.giveStorageConsent(true, userName, { sessionId });
376
+ await sdk.giveAuthorizationConsent(true, userName, { sessionId });
377
+
378
+ // 2. Process live video for liveness + auto-enrollment
379
+ // (auto-enrolls face and voice since both consents are given)
380
+ const liveVideo = new File([videoBytes], 'video.mp4', { type: 'video/mp4' });
381
+ const videoResult = await sdk.processVideo(liveVideo, '12345678', userName, { sessionId });
382
+
383
+ if (videoResult.body.scoring_result !== 'pass') {
384
+ console.error('Liveness check failed:', videoResult.body.decision_reasons);
385
+ return;
386
+ }
387
+
388
+ // 3. Match the ID photo against the live video (reusing video from step 2)
389
+ const idPhoto = new File([idBytes], 'id.jpg', { type: 'image/jpeg' });
390
+ const matchResult = await sdk.matchFaces(
391
+ idPhoto, undefined, userName, true, { sessionId }
392
+ );
393
+
394
+ if (matchResult.body.data.result === 1) {
395
+ console.log('Identity verified!');
396
+ } else {
397
+ console.log('Face mismatch — verification failed');
398
+ }
399
+ ```
400
+
401
+ > **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.
402
+
403
+ ### Document-Only Verification
404
+
405
+ For flows that only need document data extraction:
406
+
407
+ ```typescript
408
+ const sdk = new BiometrySDK('YOUR_API_KEY');
409
+
410
+ await sdk.giveAuthorizationConsent(true, 'Jane Doe');
411
+
412
+ const result = await sdk.checkDocAuth(documentFile, 'Jane Doe', {
413
+ inHouseCheck: true,
414
+ });
415
+
416
+ const doc = result.body.data;
417
+ console.log(`${doc.first_name} ${doc.last_name}`);
418
+ console.log(`DOB: ${doc.birth_date}`);
419
+ console.log(`Document: ${doc.document_number}`);
420
+ console.log(`Valid: ${result.body.scoring_result}`); // "pass" or "fail"
421
+ ```
422
+
423
+ ### Full KYC with Document Authentication
424
+
425
+ Combine document authentication with liveness verification and face matching for a comprehensive KYC flow:
426
+
427
+ ```typescript
428
+ const sdk = new BiometrySDK('YOUR_API_KEY');
429
+ const session = await sdk.startSession();
430
+ const sessionId = session.body.data;
431
+ const userName = 'Jane Doe';
432
+
433
+ // 1. Collect both consents
434
+ await sdk.giveStorageConsent(true, userName, { sessionId });
435
+ await sdk.giveAuthorizationConsent(true, userName, { sessionId });
436
+
437
+ // 2. Authenticate the ID document
438
+ const docImage = new File([docBytes], 'passport.jpg', { type: 'image/jpeg' });
439
+ const docResult = await sdk.checkDocAuth(docImage, userName, {
440
+ sessionId,
441
+ inHouseCheck: true,
442
+ });
443
+
444
+ if (docResult.body.scoring_result !== 'pass') {
445
+ console.error('Document authentication failed');
446
+ return;
447
+ }
448
+
449
+ // 3. Process live video (liveness + auto-enrollment)
450
+ const liveVideo = new File([videoBytes], 'video.mp4', { type: 'video/mp4' });
451
+ const videoResult = await sdk.processVideo(liveVideo, '12345678', userName, { sessionId });
452
+
453
+ if (videoResult.body.scoring_result !== 'pass') {
454
+ console.error('Liveness check failed');
455
+ return;
456
+ }
457
+
458
+ // 4. Match document photo against live video
459
+ const matchResult = await sdk.matchFaces(
460
+ docImage, undefined, userName, true, { sessionId }
461
+ );
462
+
463
+ if (matchResult.body.data.result === 1) {
464
+ console.log('KYC complete — identity verified!');
465
+ } else {
466
+ console.log('Face mismatch — document does not match live video');
467
+ }
468
+ ```
469
+
470
+ ## API Reference
471
+
472
+ ### `new BiometrySDK(apiKey)`
473
+
474
+ Creates a new SDK instance.
475
+
476
+ | Parameter | Type | Required | Description |
477
+ |-----------|------|----------|-------------|
478
+ | `apiKey` | `string` | Yes | Your Biometry project API key |
479
+
480
+ ---
481
+
482
+ ### `startSession()`
483
+
484
+ Starts a new session for grouping transactions.
485
+
486
+ **Returns:** `Promise<ApiResponse<SessionResponse>>`
487
+
488
+ ```typescript
489
+ // SessionResponse
490
+ { data: string; message: string }
491
+ ```
492
+
493
+ ---
494
+
495
+ ### `giveAuthorizationConsent(isConsentGiven, userFullName, props?)`
496
+
497
+ Submits authorization consent. Required before recognition and verification operations.
498
+
499
+ | Parameter | Type | Required | Description |
500
+ |-----------|------|----------|-------------|
501
+ | `isConsentGiven` | `boolean` | Yes | Whether the user granted consent |
502
+ | `userFullName` | `string` | Yes | User's full name for record-keeping |
503
+ | `props.sessionId` | `string` | No | Session ID to link with |
504
+ | `props.deviceInfo` | `object` | No | Device metadata |
505
+
506
+ **Returns:** `Promise<ApiResponse<ConsentResponse>>`
507
+
508
+ ---
509
+
510
+ ### `giveStorageConsent(isStorageConsentGiven, userFullName, props?)`
511
+
512
+ Submits storage consent. Required before enrollment operations.
513
+
514
+ | Parameter | Type | Required | Description |
515
+ |-----------|------|----------|-------------|
516
+ | `isStorageConsentGiven` | `boolean` | Yes | Whether the user granted storage consent |
517
+ | `userFullName` | `string` | Yes | User's full name for record-keeping |
518
+ | `props.sessionId` | `string` | No | Session ID to link with |
519
+ | `props.deviceInfo` | `object` | No | Device metadata |
520
+
521
+ **Returns:** `Promise<ApiResponse<ConsentResponse>>`
522
+
523
+ ---
524
+
525
+ ### `enrollFace(face, userFullName, isDocument?, props?)`
526
+
527
+ Enrolls a user's face for biometric authentication.
528
+
529
+ | Parameter | Type | Required | Description |
530
+ |-----------|------|----------|-------------|
531
+ | `face` | `File` | Yes | Image file containing the face |
532
+ | `userFullName` | `string` | Yes | User's full name |
533
+ | `isDocument` | `boolean` | No | Set `true` if image is from an ID document |
534
+ | `props.sessionId` | `string` | No | Session ID to link with |
535
+ | `props.deviceInfo` | `object` | No | Device metadata |
536
+
537
+ **Returns:** `Promise<ApiResponse<FaceEnrollmentResponse>>`
538
+
539
+ Response `data` contains:
540
+ - `enrollment_result.code` — `0` for success, non-zero for failure
541
+ - `enrollment_result.description` — human-readable result
542
+ - `document_auth` — extracted document data (when `isDocument` is `true`)
543
+
544
+ ---
545
+
546
+ ### `enrollVoice(audio, userFullName, uniqueId, phrase, props?)`
547
+
548
+ Enrolls a user's voice for speaker verification.
549
+
550
+ | Parameter | Type | Required | Description |
551
+ |-----------|------|----------|-------------|
552
+ | `audio` | `File` | Yes | Audio file with the user's voice |
553
+ | `userFullName` | `string` | Yes | User's full name (also used as the enrollment identifier) |
554
+ | `uniqueId` | `string` | Yes | Unique identifier for the enrollment |
555
+ | `phrase` | `string` | Yes | The phrase spoken in the audio |
556
+ | `props.sessionId` | `string` | No | Session ID to link with |
557
+ | `props.deviceInfo` | `object` | No | Device metadata |
558
+
559
+ **Returns:** `Promise<ApiResponse<VoiceEnrollmentResponse>>`
560
+
561
+ Response `data` contains:
562
+ - `status` — `"good"` (accepted), `"enrolled"` (fully enrolled), `"qafailed"` (quality check failed), or `"error"`
563
+ - `qa_combined` — combined quality assessment results
564
+ - `qa_list` — per-file quality results
565
+
566
+ ---
567
+
568
+ ### `processVideo(video, phrase, userFullName?, props?)`
569
+
570
+ Processes a video for liveness detection, face recognition, active speaker detection, visual speech recognition, and voice recognition.
571
+
572
+ | Parameter | Type | Required | Description |
573
+ |-----------|------|----------|-------------|
574
+ | `video` | `File` | Yes | Video file to process |
575
+ | `phrase` | `string` | Yes | Digits the user speaks in the video |
576
+ | `userFullName` | `string` | No | User's full name (required for face/voice recognition) |
577
+ | `props.sessionId` | `string` | No | Session ID to link with |
578
+ | `props.deviceInfo` | `object` | No | Device metadata |
579
+
580
+ **Returns:** `Promise<ApiResponse<ProcessVideoResponse>>`
581
+
582
+ The `scoring_result` field indicates the overall outcome: `"pass"`, `"fail"`, or `"refer"` (needs manual review).
583
+
584
+ 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.
585
+
586
+ ---
587
+
588
+ ### `matchFaces(image, video?, userFullName?, usePrefilledVideo?, props?)`
589
+
590
+ Compares a reference image against a face from a video.
591
+
592
+ | Parameter | Type | Required | Description |
593
+ |-----------|------|----------|-------------|
594
+ | `image` | `File` | Yes | Reference image containing a face |
595
+ | `video` | `File` | No | Video file with a face to compare. Required unless `usePrefilledVideo` is `true` |
596
+ | `userFullName` | `string` | No | User's full name |
597
+ | `usePrefilledVideo` | `boolean` | No | Reuse video from a previous `processVideo` call in the same session |
598
+ | `props.sessionId` | `string` | Conditional | Required if `usePrefilledVideo` is `true` |
599
+ | `props.deviceInfo` | `object` | No | Device metadata |
600
+
601
+ **Returns:** `Promise<ApiResponse<FaceMatchResponse>>`
602
+
603
+ Response `data` contains:
604
+ - `result` — `1` for match, `0` for no match
605
+ - `code` — `0` for successful comparison
606
+ - `description` — human-readable result
607
+ - `anchor` — face detection result for the reference image
608
+ - `target` — face detection result for the video
609
+
610
+ ---
611
+
612
+ ### `checkDocAuth(document, userFullName, props?)`
613
+
614
+ Authenticates an identity document and extracts its data.
615
+
616
+ | Parameter | Type | Required | Description |
617
+ |-----------|------|----------|-------------|
618
+ | `document` | `File` | Yes | Document image file (JPG, JPEG, or PNG only) |
619
+ | `userFullName` | `string` | Yes | User's full name |
620
+ | `props.sessionId` | `string` | No | Session ID to link with |
621
+ | `props.deviceInfo` | `object` | No | Device metadata |
622
+ | `props.inHouseCheck` | `boolean` | No | Use in-house document verification (default behavior) |
623
+
624
+ **Returns:** `Promise<ApiResponse<DocAuthInfo>>`
625
+
626
+ 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).
627
+
628
+ ---
629
+
630
+ ### Response Headers
631
+
632
+ Useful headers returned by the API:
633
+
634
+ | Header | Description |
635
+ |--------|-------------|
636
+ | `x-request-id` | Unique request identifier for debugging |
637
+ | `x-auto-enroll` | Set to `"true"` when `processVideo` triggers auto-enrollment |
638
+ | `x-removed-services` | Set to `"true"` when consent-dependent services were removed from video processing |
639
+
640
+ ```typescript
641
+ const response = await sdk.processVideo(videoFile, '12345678', 'Jane Doe');
642
+
643
+ console.log(response.headers['x-request-id']);
644
+ console.log(response.headers['x-auto-enroll']); // "true" if auto-enrolled
645
+ console.log(response.headers['x-removed-services']); // "true" if services were skipped
646
+ ```
647
+
648
+ ## Error Handling
649
+
650
+ All SDK methods throw errors on validation failures or unsuccessful HTTP responses. Always wrap calls in `try/catch`:
651
+
652
+ ```typescript
653
+ try {
654
+ const response = await sdk.processVideo(videoFile, '12345678', 'Jane Doe');
655
+ // Handle success
656
+ } catch (error) {
657
+ console.error(error.message);
658
+ // Example: "Error 400: 'phrase' form value is required"
659
+ }
660
+ ```
661
+
662
+ Common error scenarios:
663
+
664
+ | Scenario | When it happens |
665
+ |----------|-----------------|
666
+ | Missing API key | `new BiometrySDK('')` |
667
+ | Missing required parameter | e.g. calling `enrollFace` without a file or name |
668
+ | No face detected | Face enrollment with an image that has no detectable face |
669
+ | Multiple faces detected | Face enrollment with an image containing more than one face |
670
+ | Liveness check failed | Video processing detects a spoofing attempt |
671
+ | No speech detected | Voice enrollment with an audio file containing no speech |
672
+ | Network failure | Server unreachable or request timeout |
673
+ | Consent not given | Calling `enrollFace` or `enrollVoice` without storage consent |
674
+ | Prefilled video without session | Calling `matchFaces` with `usePrefilledVideo: true` but no `sessionId` |
675
+ | No video found for reuse | Using `usePrefilledVideo` in a session that has no prior `processVideo` call |
676
+ | Invalid document format | Calling `checkDocAuth` with a non-JPG/JPEG/PNG file |
677
+ | File size exceeded | Uploading a file larger than 50MB |
678
+
679
+ ## Security & Privacy
680
+
681
+ 1. **Protect your API key** — use environment variables or a server-side proxy. Never commit keys to source control.
682
+ 2. **Obtain explicit consent** — always collect authorization and storage consent through your UI before calling biometric APIs.
683
+ 3. **Data minimization** — only collect and store data that is necessary for your use case.
684
+ 4. **Regulatory compliance** — check local regulations (GDPR, CCPA, etc.) regarding the collection and processing of biometric data.
685
+
686
+ ## Examples
687
+
688
+ If you require additional implementation guidance, please refer to the official API documentation or contact our support team.
268
689
 
269
690
  ## License
270
691
 
271
- This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for more details.
692
+ This project is licensed under the MIT License.
693
+ The full license text is available in the source repository.
694
+
695
+ ## Support
272
696
 
273
- ## More Information
274
- For more detailed information on Biometry's API endpoints, parameters, and responses, visit the official [Biometry API Documentation](https://developer.biometrysolutions.com/overview/). If you have questions or need help, please reach out to our support team or create a GitHub issue.
697
+ - [Biometry API Documentation](https://developer.biometrysolutions.com/overview/)
698
+ - Contact our support team at [support@biometrysolutions.com](mailto:support@biometrysolutions.com)
@@ -1,5 +1,5 @@
1
1
  import { ApiResponse } from "../types/internal";
2
- import { DocAuthInfo } from "../types/biometry/doc-auth";
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<DocAuthInfo>>} - A promise resolving to the document authentication information.
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<DocAuthInfo>>;
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<DocAuthInfo>>} - A promise resolving to the document authentication information.
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,EAAE,IAAU,EAAE,OAAgC,EAAA;AAEjG,QAAA,MAAM,cAAc,GAAgB;AAClC,YAAA,aAAa,EAAE,CAAA,OAAA,EAAU,IAAI,CAAC,MAAM,CAAA,CAAE;SACvC;QAED,MAAM,cAAc,GAAG,EAAE,GAAG,cAAc,EAAE,GAAG,OAAO,EAAE;QAExD,IAAI,IAAI,IAAI,EAAE,IAAI,YAAY,QAAQ,CAAC,EAAE;AACvC,YAAA,cAAc,CAAC,cAAc,CAAC,GAAG,kBAAkB;AACnD,YAAA,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;QAC7B;AACA,QAAA,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,CAAA,EAAG,WAAW,CA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AAA,OAAO,MAAM,IAAI,CAAC,OAAO,CACvB,0BAA0B,EAC1B,MAAM,EACN,QAAQ,EACR,OAAO,CACR;IACH;AAEA;;;;;;;;;;;AAWG;IACH,MAAM,YAAY,CAChB,KAAW,EACX,MAAc,EACd,YAAqB,EACrB,KAGC,EAAA;AAED,QAAA,IAAI,CAAC,KAAK;AAAE,YAAA,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC;AACjD,QAAA,IAAI,CAAC,MAAM;AAAE,YAAA,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC;AAEnD,QAAA,MAAM,QAAQ,GAAG,IAAI,QAAQ,EAAE;AAC/B,QAAA,QAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC;AACjC,QAAA,QAAQ,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC;QAE/B,MAAM,OAAO,GAA2B,EAAE;QAE1C,IAAI,YAAY,EAAE;AAChB,YAAA,OAAO,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
+ {"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;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,EAAE,IAAU,EAAE,OAAgC,EAAA;AAEjG,QAAA,MAAM,cAAc,GAAgB;AAClC,YAAA,aAAa,EAAE,CAAA,OAAA,EAAU,IAAI,CAAC,MAAM,CAAA,CAAE;SACvC;QAED,MAAM,cAAc,GAAG,EAAE,GAAG,cAAc,EAAE,GAAG,OAAO,EAAE;QAExD,IAAI,IAAI,IAAI,EAAE,IAAI,YAAY,QAAQ,CAAC,EAAE;AACvC,YAAA,cAAc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 @@
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
- current_result: string;
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
- enroll_result: FaceEnrollmentResult;
33
+ enrollment_result: FaceEnrollmentResult;
30
34
  document_auth?: DocAuthInfo;
31
35
  };
32
36
  message?: string;
@@ -1,4 +1,10 @@
1
1
  export interface FaceMatchResponse {
2
+ data: FaceMatchData;
3
+ scoring_result: Record<string, any>;
4
+ decision_reasons: string[];
5
+ message: string;
6
+ }
7
+ export interface FaceMatchData {
2
8
  code: number;
3
9
  result: number;
4
10
  description: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "biometry-sdk",
3
- "version": "2.3.5",
3
+ "version": "2.3.7",
4
4
  "type": "module",
5
5
  "main": "dist/sdk.js",
6
6
  "module": "dist/sdk.js",