biometry-sdk 1.2.5 → 1.2.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 CHANGED
@@ -10,15 +10,17 @@ The **Biometry Web SDK** is a software development kit designed to simplify the
10
10
  - [Face Onboarding](#2-face-onboarding)
11
11
  - [Voice Onboarding](#3-voice-onboarding)
12
12
  - [Process Video](#4-process-video)
13
- - [Advanced Usage & Best Practices](#advanced-usage-best-practices)
14
- - [A Typical docAuth + FaceMatch Flow](#)
15
- - [Use Cases with processVideoRequestId and usePrefilledVideo](#)
16
- - [Error Handling](#)
17
- - [Security & Privacy Considerations](#)
18
- - [UI Components](#)
19
- - [Face Onboarding Component](#)
20
- - [Process Video Component](#)
21
-
13
+ - [Advanced Usage And Best Practices](#advanced-usage-and-best-practices)
14
+ - [Typical FaceMatch Flow](#typical-facematch-flow)
15
+ - [Use Cases with processVideoRequestId and usePrefilledVideo](#use-cases-with-processVideoRequestId-and-usePrefilledVideo)
16
+ - [Error Handling](#error-handling)
17
+ - [Security And Privacy Considerations](#security-and-privacy-considerations)
18
+ - [UI Components](#ui-components)
19
+ - [Face Onboarding Component](#face-onboarding-component)
20
+ - [Process Video Component](#process-video-component)
21
+ - [License](#license)
22
+ - [More Information](#more-information)
23
+ - [Quick Reference](#quick-reference)
22
24
 
23
25
  ## Installation
24
26
  Install the Biometry Web SDK via npm:
@@ -66,7 +68,7 @@ Enroll a user’s voice for future authentication checks:
66
68
  const voiceFile = new File([/* voice audio bytes */], 'voice.wav', { type: 'audio/wav' });
67
69
 
68
70
  await sdk.giveConsent(true, 'John Doe');
69
- const voiceResponse = await sdk.enrollVoice(voiceFile, 'John Doe');
71
+ const voiceResponse = await sdk.onboardVoice(voiceFile, 'John Doe');
70
72
  console.log('Voice Onboarding Response:', voiceResponse);
71
73
  ```
72
74
  ### 4. Process Video
@@ -88,11 +90,11 @@ Process a user’s video for liveness checks and identity authorization:
88
90
  console.error('Error processing video:', error);
89
91
  }
90
92
  ```
91
- ## Advanced Usage & Best Practices
92
- ### A Typical docAuth + FaceMatch Flow
93
- One common advanced scenario involves document authentication (docAuth) and face matching:
94
- 1. docAuth: The user uploads a picture of their identity document (front side with the face).
95
- 2. Face Onboarding or Process Video: Capture the user’s live face.
93
+ ## Advanced Usage And Best Practices
94
+ ### Typical FaceMatch Flow
95
+ One common advanced scenario involves document authentication in onboarding face and face matching:
96
+ 1. Face Onboarding: Capture the user’s live face or the user uploads a picture of their identity document (front side with the face)
97
+ 2. Process Video: Capture the user’s live face
96
98
  3. Face Match: Compare the extracted face from the document with the user’s live face to verify identity.
97
99
 
98
100
  Below is a possible flow (method names in your SDK may vary slightly depending on your integration setup):
@@ -100,39 +102,33 @@ Below is a possible flow (method names in your SDK may vary slightly depending o
100
102
  // 1. Acquire user consent
101
103
  await sdk.giveConsent(true, userFullName);
102
104
 
103
- // 2. User uploads or captures their ID document
104
- const docFile = new File([/* document bytes */], 'document.jpg', { type: 'image/jpeg' });
105
- const docAuthResponse = await sdk.docAuth(docFile, userFullName);
106
-
107
- // 3. Onboard or capture the user’s live face
105
+ // 2. Onboard or capture the user’s face
108
106
  // (Either using onboardFace or processVideo, depending on your user flow)
109
- const userFaceFile = new File([/* user selfie bytes */], 'selfie.jpg', { type: 'image/jpeg' });
107
+ const userFaceFile = new File([/* user selfie bytes */], 'image.jpg', { type: 'image/jpeg' });
108
+ const userVideoFile = new File([/* user selfie bytes */], 'video.mp4', { type: 'video/*' });
110
109
  const onboardResponse = await sdk.onboardFace(userFaceFile, userFullName);
111
110
 
112
- // 4. Face Match (Compare doc face with user’s onboarded face)
111
+ // 3. Face Match (Compare video face with user’s onboarded face)
113
112
  const faceMatchResponse = await sdk.faceMatch(
114
- docAuthResponse.extractedFace,
115
113
  userFaceFile,
114
+ userVideoFile,
116
115
  userFullName
117
116
  );
118
117
 
119
- // 5. Evaluate the faceMatch result
118
+ // 4. Evaluate the faceMatch result
120
119
  if (faceMatchResponse.matchResult === 'match') {
121
- console.log('User doc face matches user’s live face. Identity verified!');
120
+ console.log('User video face matches user’s live face. Identity verified!');
122
121
  } else {
123
- console.log('User doc face does NOT match. Additional verification needed.');
122
+ console.log('User video face does NOT match. Additional verification needed.');
124
123
  }
125
124
  ```
126
- **Notes:**
127
- - The `docAuth` method name may differ depending on your specific implementation. Some integrations do the doc face extraction automatically, while others provide a separate endpoint.
128
- - `extractedFace` in `docAuthResponse` can be a reference (like an ID) or raw data. Confirm your exact API response structure to properly pass it to `faceMatch`.
129
125
 
130
126
  ### Use Cases with processVideoRequestId and usePrefilledVideo
131
- - `processVideoRequestId`: After calling `sdk.processVideo()`, you typically receive a unique ID (`requestId`). You can pass this `processVideoRequestId` into subsequent calls (e.g., `faceMatch`) to reference the previously uploaded video frames.
127
+ - `processVideoRequestId`: After calling `sdk.processVideo()`, you typically receive a unique ID (`x-request-id`). You can pass this `processVideoRequestId` into subsequent calls (e.g., `faceMatch`) to reference the previously uploaded video frames.
132
128
  - `usePrefilledVideo`: When set to `true`, indicates that the SDK should reuse the video already on file from a previous `processVideo` call rather than requiring a new upload.
133
129
  Example:
134
130
  ```javascript
135
- const { requestId } = await sdk.processVideo(videoFile, phrase, userFullName);
131
+ const { x-request-id } = await sdk.processVideo(videoFile, phrase, userFullName);
136
132
 
137
133
  // Later on, we can reuse that video for face match or advanced checks
138
134
  const faceMatchResp = await sdk.faceMatch(null, null, userFullName, {
@@ -160,7 +156,7 @@ Always wrap calls in try/catch and provide user-friendly messages or fallback lo
160
156
  console.error('Face match error:', error);
161
157
  }
162
158
  ```
163
- ### Security & Privacy Considerations
159
+ ### Security And Privacy Considerations
164
160
  1. **Protect Your API Key:** Avoid storing your API key in client-side code if possible. Use environment variables or server-side proxies.
165
161
  2. **Obtain Explicit Consent:** Ensure you have a transparent process for obtaining and storing user consent.
166
162
  3. **Data Minimization:** Only store data that is required for your use case.
@@ -174,8 +170,6 @@ The Biometry Web SDK includes reusable, customizable web components for crucial
174
170
  This component provides an intuitive interface for onboarding users with their cameras. It integrates directly with the `BiometrySDK backend`, managing camera capture, consent checks, and error handling.
175
171
 
176
172
  ### Integration
177
- Here's how to integrate the `Face Onboarding` component into your application:
178
-
179
173
  **Option 1: Using npm (Recommended for full SDK usage)**
180
174
  1. Install the SDK package via **npm**:
181
175
  ```bash
@@ -189,12 +183,21 @@ Here's how to integrate the `Face Onboarding` component into your application:
189
183
  3. Connect the script to your **HTML file** and use the component:
190
184
  ```html
191
185
  <script type="module" src="./index.js"></script>
186
+
187
+ <biometry-onboarding
188
+ api-key="your-api-key"
189
+ user-fullname="John Doe">
190
+ </biometry-onboarding>
192
191
  ```
193
-
194
-
192
+
195
193
  **Option 2: Using CDN (Quick Integration)**
196
194
  ```html
197
195
  <script type="module" src="https://cdn.jsdelivr.net/npm/biometry-sdk/dist/biometry-sdk.esm.js"></script>
196
+
197
+ <biometry-onboarding
198
+ api-key="your-api-key"
199
+ user-fullname="John Doe">
200
+ </biometry-onboarding>
198
201
  ```
199
202
 
200
203
  ### Usage
@@ -203,7 +206,7 @@ Here's how to integrate the `Face Onboarding` component into your application:
203
206
  - `user-fullname`: The user’s full name (used in data storage and consent).
204
207
 
205
208
  **Slots:**
206
- - `video`: Your custom <video> element.
209
+ - `video`: Your custom `<video>` element.
207
210
  - `button`: Custom capture button.
208
211
  - `loading`, `success`, `error-no-face`, `error-multiple-faces`, `error-not-centered`, `error-other`: Custom UI messages for different states.
209
212
 
@@ -219,7 +222,7 @@ Here's how to integrate the `Face Onboarding` component into your application:
219
222
  ```html
220
223
  <biometry-onboarding
221
224
  api-key="your-api-key"
222
- user-fullname="Jane Doe">
225
+ user-fullname="John Doe">
223
226
 
224
227
  <video slot="video" autoplay playsinline style="width: 100%; border-radius: 10px;"></video>
225
228
  <button slot="button" style="padding: 10px 20px; font-size: 16px;">Capture</button>
@@ -252,11 +255,13 @@ The **Process Video** component enables you to record, upload, and process a vid
252
255
  You can skip the npm installation and include the component directly in your HTML:
253
256
  ```html
254
257
  <script type="module" src="./index.js"></script>
258
+
255
259
  <process-video ...></process-video>
256
260
  ```
257
261
  **Option 2: Using CDN (Quick Integration)**
258
262
  ```html
259
263
  <script type="module" src="https://cdn.jsdelivr.net/npm/biometry-sdk/dist/biometry-sdk.esm.js"></script>
264
+
260
265
  <process-video ...></process-video>
261
266
  ```
262
267
  ### Usage
@@ -264,7 +269,7 @@ The **Process Video** component enables you to record, upload, and process a vid
264
269
  ```html
265
270
  <process-video
266
271
  api-key="your-api-key"
267
- user-fullname="Lionel Messi"
272
+ user-fullname="John Doe"
268
273
  ></process-video>
269
274
  ```
270
275
 
@@ -272,7 +277,7 @@ The **Process Video** component enables you to record, upload, and process a vid
272
277
  ```html
273
278
  <process-video
274
279
  api-key="eyJhb...apikey"
275
- user-fullname="John Doe Uulu"
280
+ user-fullname="John Doe"
276
281
  >
277
282
  <!-- Custom video element -->
278
283
  <video slot="video" muted playsinline style="border-radius: 1rem;"></video>
@@ -297,20 +302,6 @@ The **Process Video** component enables you to record, upload, and process a vid
297
302
  - All default elements and messages are functional out-of-the-box.
298
303
  - Replace slots if you want to customize the UI or functionality.
299
304
  - Call giveConsent() before using any biometric methods to ensure compliance with data processing requirements.
300
-
301
- ## Best Practices
302
- 1. **Always Acquire Consent**
303
- - Before performing Face Onboarding or Process Video, you can call:
304
- ```javascript
305
- sdk.giveConsent(true, userFullName);
306
- ```
307
- - Or directly send a request to the `/consent` in the [official documentation](https://developer.biometrysolutions.com/overview/).
308
-
309
- This ensures legal compliance and user awareness when storing and processing biometric data.
310
- 3. **Handle Errors Gracefully**
311
- - The SDK methods throw errors if something goes wrong (e.g., network, permission, or detection errors). Use try/catch or .catch() to handle them.
312
- 4. **Security**
313
- - Protect your API key. Avoid exposing it in public repositories or client-side code if possible.
314
305
 
315
306
  ## License
316
307
 
@@ -320,8 +311,40 @@ This project is licensed under the MIT License. See the [LICENSE](LICENSE) file
320
311
  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.
321
312
 
322
313
  ## Quick Reference
323
- - Install: `npm install biometry-sdk`
324
- - Consent: `sdk.giveConsent(true, userFullName)` (Required before onboarding/processing)
325
- - Voice Onboarding: `sdk.enrollVoice(file, userFullName)`
326
- - Face Onboarding: `sdk.enrollFace(file, userFullName)`
327
- - Process Video: `sdk.processVideo(file, phrase, userFullName)`
314
+ - **Install**:
315
+ ```bash
316
+ npm install biometry-sdk
317
+ ```
318
+ - **Consent**: (Required before onboarding/processing)
319
+ ```javascript
320
+ sdk.giveConsent(true, userFullName)
321
+ ```
322
+ - **Voice Onboarding**:
323
+ ```javascript
324
+ sdk.onbaordVoice(file, userFullName)
325
+ ```
326
+ - **Face Onboarding**:
327
+ ```javascript
328
+ sdk.onboardFace(file, userFullName)
329
+ ```
330
+ - Face match
331
+ ```javascript
332
+ sdk.faceMatch(image, video, userFullName, { ...options });
333
+ ```
334
+ - Process Video (basic):
335
+ ```javascript
336
+ sdk.processVideo(file, phrase, userFullName);
337
+ ```
338
+ - Process Video (advanced w/ reusing video or linking IDs):
339
+ ```javascript
340
+ sdk.processVideo(null, phrase, userFullName, {
341
+ usePrefilledVideo: true,
342
+ processVideoRequestId: 'YOUR_REQUEST_ID',
343
+ requestUserProvidedId: 'YOUR_CUSTOM_ID'
344
+ });
345
+ ```
346
+ - UI Components:
347
+ - `<biometry-onboarding ...>` (face onboarding)
348
+ - `<process-video ...>` (video onboarding)
349
+ With these **direct SDK methods**, **UI components**, and advanced **best practices** (faceOnboard + faceMatch flows, reuse of video, error handling), you can build robust, privacy-conscious biometric solutions on your web application.
350
+
@@ -1319,6 +1319,10 @@ class ProcessVideoComponent extends HTMLElement {
1319
1319
  this.videoElement.play();
1320
1320
  this.videoElement.muted = false;
1321
1321
  this.stopTimer();
1322
+ // Clean up the object URL when the video loads
1323
+ this.videoElement.onloadeddata = () => {
1324
+ URL.revokeObjectURL(videoURL);
1325
+ };
1322
1326
  }
1323
1327
  handleFileUpload(event) {
1324
1328
  var _a, _b;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "biometry-sdk",
3
- "version": "1.2.5",
3
+ "version": "1.2.6",
4
4
  "main": "dist/biometry-sdk.esm.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "module": "dist/biometry-sdk.esm.js",