@hexar/biometric-identity-sdk-core 1.0.4 → 1.0.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.
|
@@ -124,6 +124,7 @@ export interface BackendClientConfig {
|
|
|
124
124
|
export declare class BackendClient {
|
|
125
125
|
private config;
|
|
126
126
|
private currentSessionId;
|
|
127
|
+
private sdkSessionId;
|
|
127
128
|
constructor(config: BackendClientConfig);
|
|
128
129
|
/**
|
|
129
130
|
* Check if the backend is available
|
|
@@ -137,6 +138,7 @@ export declare class BackendClient {
|
|
|
137
138
|
* Validate liveness from video frames
|
|
138
139
|
*/
|
|
139
140
|
validateLiveness(videoFrames: string[], videoDurationMs: number, challengesCompleted?: string[], deviceInfo?: Record<string, any>): Promise<LivenessResponse>;
|
|
141
|
+
private generateSDKSessionId;
|
|
140
142
|
/**
|
|
141
143
|
* Compare faces between document and live capture
|
|
142
144
|
*/
|
|
@@ -11,11 +11,13 @@ exports.BackendClient = void 0;
|
|
|
11
11
|
class BackendClient {
|
|
12
12
|
constructor(config) {
|
|
13
13
|
this.currentSessionId = null;
|
|
14
|
+
this.sdkSessionId = null;
|
|
14
15
|
this.config = {
|
|
15
|
-
apiEndpoint: config.apiEndpoint.replace(/\/$/, ''),
|
|
16
|
+
apiEndpoint: config.apiEndpoint.replace(/\/$/, ''),
|
|
16
17
|
apiKey: config.apiKey,
|
|
17
18
|
timeout: config.timeout || 60000,
|
|
18
19
|
};
|
|
20
|
+
this.sdkSessionId = this.generateSDKSessionId();
|
|
19
21
|
}
|
|
20
22
|
/**
|
|
21
23
|
* Check if the backend is available
|
|
@@ -48,14 +50,16 @@ class BackendClient {
|
|
|
48
50
|
if (!this.currentSessionId) {
|
|
49
51
|
throw new Error('No active session. Call generateChallenge() first.');
|
|
50
52
|
}
|
|
51
|
-
|
|
53
|
+
return this.request('/api/v1/liveness/validate', 'POST', {
|
|
52
54
|
session_id: this.currentSessionId,
|
|
53
55
|
video_frames: videoFrames,
|
|
54
56
|
video_duration_ms: videoDurationMs,
|
|
55
57
|
challenges_completed: challengesCompleted,
|
|
56
58
|
device_info: deviceInfo,
|
|
57
59
|
});
|
|
58
|
-
|
|
60
|
+
}
|
|
61
|
+
generateSDKSessionId() {
|
|
62
|
+
return `sdk-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
59
63
|
}
|
|
60
64
|
/**
|
|
61
65
|
* Compare faces between document and live capture
|
|
@@ -159,6 +163,7 @@ class BackendClient {
|
|
|
159
163
|
*/
|
|
160
164
|
resetSession() {
|
|
161
165
|
this.currentSessionId = null;
|
|
166
|
+
this.sdkSessionId = this.generateSDKSessionId();
|
|
162
167
|
}
|
|
163
168
|
/**
|
|
164
169
|
* Make HTTP request to backend
|
|
@@ -167,13 +172,17 @@ class BackendClient {
|
|
|
167
172
|
const url = `${this.config.apiEndpoint}${endpoint}`;
|
|
168
173
|
const controller = new AbortController();
|
|
169
174
|
const timeoutId = setTimeout(() => controller.abort(), this.config.timeout);
|
|
175
|
+
const headers = {
|
|
176
|
+
'Content-Type': 'application/json',
|
|
177
|
+
'X-API-Key': this.config.apiKey,
|
|
178
|
+
};
|
|
179
|
+
if (this.sdkSessionId) {
|
|
180
|
+
headers['X-SDK-Session-ID'] = this.sdkSessionId;
|
|
181
|
+
}
|
|
170
182
|
try {
|
|
171
183
|
const response = await fetch(url, {
|
|
172
184
|
method,
|
|
173
|
-
headers
|
|
174
|
-
'Content-Type': 'application/json',
|
|
175
|
-
'X-API-Key': this.config.apiKey,
|
|
176
|
-
},
|
|
185
|
+
headers,
|
|
177
186
|
body: body ? JSON.stringify(body) : undefined,
|
|
178
187
|
signal: controller.signal,
|
|
179
188
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hexar/biometric-identity-sdk-core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"description": "Core AI engine for biometric identity verification",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"onnxruntime-node": "^1.17.0",
|
|
15
15
|
"onnxruntime-web": "^1.17.0",
|
|
16
|
-
"react-native-quick-crypto": "^1.0.3",
|
|
17
16
|
"sharp": "^0.33.2",
|
|
18
17
|
"tesseract.js": "^5.0.4"
|
|
19
18
|
},
|
package/src/api/BackendClient.ts
CHANGED
|
@@ -134,13 +134,15 @@ export interface BackendClientConfig {
|
|
|
134
134
|
export class BackendClient {
|
|
135
135
|
private config: Required<BackendClientConfig>;
|
|
136
136
|
private currentSessionId: string | null = null;
|
|
137
|
+
private sdkSessionId: string | null = null;
|
|
137
138
|
|
|
138
139
|
constructor(config: BackendClientConfig) {
|
|
139
140
|
this.config = {
|
|
140
|
-
apiEndpoint: config.apiEndpoint.replace(/\/$/, ''),
|
|
141
|
+
apiEndpoint: config.apiEndpoint.replace(/\/$/, ''),
|
|
141
142
|
apiKey: config.apiKey,
|
|
142
143
|
timeout: config.timeout || 60000,
|
|
143
144
|
};
|
|
145
|
+
this.sdkSessionId = this.generateSDKSessionId();
|
|
144
146
|
}
|
|
145
147
|
|
|
146
148
|
/**
|
|
@@ -188,7 +190,7 @@ export class BackendClient {
|
|
|
188
190
|
throw new Error('No active session. Call generateChallenge() first.');
|
|
189
191
|
}
|
|
190
192
|
|
|
191
|
-
|
|
193
|
+
return this.request<LivenessResponse>(
|
|
192
194
|
'/api/v1/liveness/validate',
|
|
193
195
|
'POST',
|
|
194
196
|
{
|
|
@@ -199,8 +201,10 @@ export class BackendClient {
|
|
|
199
201
|
device_info: deviceInfo,
|
|
200
202
|
}
|
|
201
203
|
);
|
|
204
|
+
}
|
|
202
205
|
|
|
203
|
-
|
|
206
|
+
private generateSDKSessionId(): string {
|
|
207
|
+
return `sdk-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
204
208
|
}
|
|
205
209
|
|
|
206
210
|
/**
|
|
@@ -341,6 +345,7 @@ export class BackendClient {
|
|
|
341
345
|
*/
|
|
342
346
|
resetSession(): void {
|
|
343
347
|
this.currentSessionId = null;
|
|
348
|
+
this.sdkSessionId = this.generateSDKSessionId();
|
|
344
349
|
}
|
|
345
350
|
|
|
346
351
|
/**
|
|
@@ -356,13 +361,19 @@ export class BackendClient {
|
|
|
356
361
|
const controller = new AbortController();
|
|
357
362
|
const timeoutId = setTimeout(() => controller.abort(), this.config.timeout);
|
|
358
363
|
|
|
364
|
+
const headers: Record<string, string> = {
|
|
365
|
+
'Content-Type': 'application/json',
|
|
366
|
+
'X-API-Key': this.config.apiKey,
|
|
367
|
+
};
|
|
368
|
+
|
|
369
|
+
if (this.sdkSessionId) {
|
|
370
|
+
headers['X-SDK-Session-ID'] = this.sdkSessionId;
|
|
371
|
+
}
|
|
372
|
+
|
|
359
373
|
try {
|
|
360
374
|
const response = await fetch(url, {
|
|
361
375
|
method,
|
|
362
|
-
headers
|
|
363
|
-
'Content-Type': 'application/json',
|
|
364
|
-
'X-API-Key': this.config.apiKey,
|
|
365
|
-
},
|
|
376
|
+
headers,
|
|
366
377
|
body: body ? JSON.stringify(body) : undefined,
|
|
367
378
|
signal: controller.signal as RequestInit['signal'],
|
|
368
379
|
});
|