verant_id_cloud_scan 1.4.4-beta.1 → 1.4.4-beta.2
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/Api.js +45 -1
- package/CloudScan.js +3 -0
- package/ScannerApi.js +4 -0
- package/index.d.ts +2 -0
- package/package.json +1 -1
package/Api.js
CHANGED
|
@@ -268,7 +268,13 @@ const postToScannerApi = async (
|
|
|
268
268
|
commandObj,
|
|
269
269
|
timeout = 10000
|
|
270
270
|
) => {
|
|
271
|
-
|
|
271
|
+
// Ensure the scanner address has a protocol (http:// or https://)
|
|
272
|
+
let formattedAddress = scannerAddress;
|
|
273
|
+
if (!scannerAddress.startsWith('http://') && !scannerAddress.startsWith('https://')) {
|
|
274
|
+
formattedAddress = `http://${scannerAddress}`;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
let apiAddress = `${formattedAddress}/securelink`;
|
|
272
278
|
|
|
273
279
|
const controller = new AbortController();
|
|
274
280
|
const signal = controller.signal;
|
|
@@ -320,3 +326,41 @@ export const stopScanning = (scannerAddress, commandObj) =>
|
|
|
320
326
|
|
|
321
327
|
export const closeConnection = (scannerAddress, commandObj) =>
|
|
322
328
|
postToScannerApi(scannerAddress, commandObj);
|
|
329
|
+
|
|
330
|
+
// Check if scanner is present by attempting to connect and disconnect
|
|
331
|
+
export const checkScannerPresent = async (scannerAddress) => {
|
|
332
|
+
try {
|
|
333
|
+
// Generate a unique message ID for this check
|
|
334
|
+
const messageId = new Date().toISOString();
|
|
335
|
+
|
|
336
|
+
// Attempt to establish connection
|
|
337
|
+
const connectCommand = {
|
|
338
|
+
Command: "Connect",
|
|
339
|
+
MessageId: messageId,
|
|
340
|
+
Exclusive: "false", // Use non-exclusive mode for just checking
|
|
341
|
+
IdleTimeout: "5",
|
|
342
|
+
};
|
|
343
|
+
|
|
344
|
+
const connectResponse = await postToScannerApi(scannerAddress, connectCommand, 5000);
|
|
345
|
+
|
|
346
|
+
// If connection failed or no session ID, scanner not present
|
|
347
|
+
if (!connectResponse || !connectResponse.SessionId) {
|
|
348
|
+
return false;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
// Got a session ID, now disconnect
|
|
352
|
+
const disconnectCommand = {
|
|
353
|
+
Command: "Disconnect",
|
|
354
|
+
MessageId: new Date().toISOString(),
|
|
355
|
+
SessionId: connectResponse.SessionId,
|
|
356
|
+
};
|
|
357
|
+
|
|
358
|
+
await postToScannerApi(scannerAddress, disconnectCommand, 5000);
|
|
359
|
+
|
|
360
|
+
// Successfully connected and disconnected
|
|
361
|
+
return true;
|
|
362
|
+
} catch (error) {
|
|
363
|
+
// Any error means scanner is not reachable
|
|
364
|
+
return false;
|
|
365
|
+
}
|
|
366
|
+
};
|
package/CloudScan.js
CHANGED
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
dmvCheck,
|
|
13
13
|
getBarcodeLicenseKey,
|
|
14
14
|
scannerChain,
|
|
15
|
+
scannerPresent,
|
|
15
16
|
} from "./ScannerApi.js";
|
|
16
17
|
import { VerificationModal } from "./VerificationModal.js";
|
|
17
18
|
import { checkAutoDmvEnabled } from "./Api.js";
|
|
@@ -34,6 +35,8 @@ export const checkFaceCompareFeature = async (clientId) => {
|
|
|
34
35
|
return await checkFaceComparisonFeatureLicense(clientId);
|
|
35
36
|
}
|
|
36
37
|
|
|
38
|
+
export { scannerPresent };
|
|
39
|
+
|
|
37
40
|
export async function readImageBarcode(imageFile) {
|
|
38
41
|
let returnObj = {
|
|
39
42
|
barcodeResultsObject: {},
|
package/ScannerApi.js
CHANGED
|
@@ -41,6 +41,10 @@ export async function dmvCheck(clientId, scannerType, licenseData) {
|
|
|
41
41
|
return await API.dmvCheck(clientId, scannerType, licenseData);
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
export async function scannerPresent(scannerAddress) {
|
|
45
|
+
return await API.checkScannerPresent(scannerAddress);
|
|
46
|
+
}
|
|
47
|
+
|
|
44
48
|
//This is the top level function that calls the other functions in order
|
|
45
49
|
export async function scannerChain(
|
|
46
50
|
scannerAddress,
|
package/index.d.ts
CHANGED