verant_id_cloud_scan 1.4.5-beta.3 → 1.4.5-beta.5
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 +66 -26
- package/CloudScan.js +3 -3
- package/index.d.ts +17 -1
- package/package.json +1 -1
package/Api.js
CHANGED
|
@@ -4,47 +4,87 @@ import { FIELD_MAPPING, FIELD_DEFAULTS, getFieldValue } from "./FieldMapping.js"
|
|
|
4
4
|
import { sanitizeFieldForDmv } from "./FormatUtils.js";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* Environment Detection
|
|
7
|
+
* Environment Detection & Management
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
9
|
+
* Defaults to PRODUCTION for all hosts (including localhost).
|
|
10
|
+
* Only verify-staging.verantid.com automatically uses staging.
|
|
11
|
+
* Host apps can explicitly override via setEnvironment('staging' | 'production').
|
|
12
12
|
*/
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
|
|
14
|
+
// Current environment - starts as null to trigger detection on first use
|
|
15
|
+
let currentEnvironment = null;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Detect environment based on hostname
|
|
19
|
+
* @returns {'staging' | 'production'}
|
|
20
|
+
*/
|
|
21
|
+
function detectEnvironment() {
|
|
22
|
+
// Default to production for all hosts
|
|
15
23
|
let environment = 'production';
|
|
16
24
|
|
|
17
|
-
// Only
|
|
25
|
+
// Only auto-switch to staging for VerantID's staging domain
|
|
18
26
|
if (typeof window !== 'undefined') {
|
|
19
27
|
const hostname = window.location.hostname;
|
|
20
28
|
|
|
21
|
-
// ONLY
|
|
22
|
-
if (hostname === 'verify-staging.verantid.com'
|
|
23
|
-
hostname === 'localhost' ||
|
|
24
|
-
hostname === '127.0.0.1' ||
|
|
25
|
-
hostname.startsWith('localhost:')) {
|
|
29
|
+
// ONLY verify-staging.verantid.com uses staging by default
|
|
30
|
+
if (hostname === 'verify-staging.verantid.com') {
|
|
26
31
|
environment = 'staging';
|
|
27
32
|
}
|
|
28
33
|
|
|
29
|
-
// All other hostnames (customer sites, verify.verantid.com, etc.) use production
|
|
34
|
+
// All other hostnames (localhost, customer sites, verify.verantid.com, etc.) use production
|
|
30
35
|
}
|
|
31
36
|
|
|
32
37
|
console.log('[CloudScan] Environment detected:', environment, 'on', typeof window !== 'undefined' ? window.location.hostname : 'server');
|
|
33
38
|
return environment;
|
|
34
39
|
}
|
|
35
40
|
|
|
36
|
-
|
|
41
|
+
/**
|
|
42
|
+
* Get current environment (detects if not already set)
|
|
43
|
+
* @returns {'staging' | 'production'}
|
|
44
|
+
*/
|
|
45
|
+
function getEnvironment() {
|
|
46
|
+
if (currentEnvironment === null) {
|
|
47
|
+
currentEnvironment = detectEnvironment();
|
|
48
|
+
}
|
|
49
|
+
return currentEnvironment;
|
|
50
|
+
}
|
|
37
51
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
52
|
+
/**
|
|
53
|
+
* Explicitly set the environment
|
|
54
|
+
* @param {'staging' | 'production'} environment
|
|
55
|
+
* @throws {Error} If environment is not 'staging' or 'production'
|
|
56
|
+
*/
|
|
57
|
+
export function setEnvironment(environment) {
|
|
58
|
+
if (environment !== 'staging' && environment !== 'production') {
|
|
59
|
+
throw new Error(`Invalid environment: "${environment}". Must be "staging" or "production".`);
|
|
60
|
+
}
|
|
61
|
+
currentEnvironment = environment;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Get license server address based on current environment
|
|
66
|
+
* @returns {string}
|
|
67
|
+
*/
|
|
68
|
+
function getLicenseServerAddress() {
|
|
69
|
+
const env = getEnvironment();
|
|
70
|
+
return env === 'staging'
|
|
71
|
+
? "https://lic-staging.verantid.com/api/v1"
|
|
72
|
+
: "https://lic.verantid.com/api/v1";
|
|
73
|
+
}
|
|
41
74
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
75
|
+
/**
|
|
76
|
+
* Get DMV server address based on current environment
|
|
77
|
+
* @returns {string}
|
|
78
|
+
*/
|
|
79
|
+
function getDmvServerAddress() {
|
|
80
|
+
const env = getEnvironment();
|
|
81
|
+
return env === 'staging'
|
|
82
|
+
? "https://dmv-check-server-staging-fcaab48bec21.herokuapp.com/api/v1/dmv_check"
|
|
83
|
+
: "https://dmv.verantid.com/api/v1/dmv_check";
|
|
84
|
+
}
|
|
45
85
|
|
|
46
86
|
export const dmvCheck = async (clientId, scannerType, licenseData) => {
|
|
47
|
-
const url =
|
|
87
|
+
const url = getDmvServerAddress();
|
|
48
88
|
|
|
49
89
|
// Build the driver object dynamically.
|
|
50
90
|
const driver = {};
|
|
@@ -135,7 +175,7 @@ export const dmvCheck = async (clientId, scannerType, licenseData) => {
|
|
|
135
175
|
};
|
|
136
176
|
|
|
137
177
|
export const checkDmvFeatureLicense = async (clientId) => {
|
|
138
|
-
const url =
|
|
178
|
+
const url = getLicenseServerAddress() + "/dmv_verifications/check_license";
|
|
139
179
|
const data = { client_id: clientId };
|
|
140
180
|
|
|
141
181
|
try {
|
|
@@ -169,7 +209,7 @@ export const checkDmvFeatureLicense = async (clientId) => {
|
|
|
169
209
|
};
|
|
170
210
|
|
|
171
211
|
export const checkFaceComparisonFeatureLicense = async (clientId) => {
|
|
172
|
-
const url =
|
|
212
|
+
const url = getLicenseServerAddress() + "/facial_scans/check_license";
|
|
173
213
|
const data = { client_id: clientId };
|
|
174
214
|
|
|
175
215
|
try {
|
|
@@ -203,7 +243,7 @@ export const checkFaceComparisonFeatureLicense = async (clientId) => {
|
|
|
203
243
|
}
|
|
204
244
|
|
|
205
245
|
export const checkLicense = async (clientId, macAddress) => {
|
|
206
|
-
const url =
|
|
246
|
+
const url = getLicenseServerAddress() + "/check_license";
|
|
207
247
|
const data = { client_id: clientId, mac_address: macAddress };
|
|
208
248
|
|
|
209
249
|
try {
|
|
@@ -238,7 +278,7 @@ export const checkLicense = async (clientId, macAddress) => {
|
|
|
238
278
|
* @returns {Promise<boolean>} True if autoDmv is enabled
|
|
239
279
|
*/
|
|
240
280
|
export const checkAutoDmvEnabled = async (clientId) => {
|
|
241
|
-
const url =
|
|
281
|
+
const url = getLicenseServerAddress() + "/check_feature_license";
|
|
242
282
|
const data = { client_id: clientId };
|
|
243
283
|
|
|
244
284
|
try {
|
|
@@ -263,7 +303,7 @@ export const checkAutoDmvEnabled = async (clientId) => {
|
|
|
263
303
|
}
|
|
264
304
|
};
|
|
265
305
|
export const getBarcodeLicenseKey = async () => {
|
|
266
|
-
const url =
|
|
306
|
+
const url = getLicenseServerAddress() + "/get_barcode_license_key";
|
|
267
307
|
|
|
268
308
|
try {
|
|
269
309
|
const response = await fetch(url, {
|
package/CloudScan.js
CHANGED
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
scannerPresent,
|
|
16
16
|
} from "./ScannerApi.js";
|
|
17
17
|
import { VerificationModal } from "./VerificationModal.js";
|
|
18
|
-
import { checkAutoDmvEnabled } from "./Api.js";
|
|
18
|
+
import { checkAutoDmvEnabled, setEnvironment } from "./Api.js";
|
|
19
19
|
import { formatSexCodeForDisplay, formatHeightForDisplay } from "./FormatUtils.js";
|
|
20
20
|
|
|
21
21
|
let cachedLicenseFrontBase64 = "";
|
|
@@ -36,7 +36,7 @@ export const checkFaceCompareFeature = async (clientId) => {
|
|
|
36
36
|
return await checkFaceComparisonFeatureLicense(clientId);
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
export { scannerPresent };
|
|
39
|
+
export { scannerPresent, setEnvironment };
|
|
40
40
|
|
|
41
41
|
export async function readImageBarcode(imageFile, clientId = null, scannerType = 'Upload') {
|
|
42
42
|
let returnObj = {
|
|
@@ -175,7 +175,7 @@ export const scanId = async (
|
|
|
175
175
|
console.log('[AUTO-DMV] Feature enabled, showing verification modal');
|
|
176
176
|
|
|
177
177
|
// Determine scanner type - you can customize this based on your needs
|
|
178
|
-
const scannerType = 'DigitalCheck'; // Default scanner type
|
|
178
|
+
const scannerType = scannerResponseObj.scannerProfile || 'DigitalCheck'; // Default scanner type
|
|
179
179
|
|
|
180
180
|
// Create and open the modal
|
|
181
181
|
const modal = new VerificationModal(clientId, scannerType, barcodeResultsObject, {
|
package/index.d.ts
CHANGED
|
@@ -52,7 +52,15 @@ declare module "verant_id_cloud_scan" {
|
|
|
52
52
|
export function localScanId(
|
|
53
53
|
scannerAddress: string,
|
|
54
54
|
clientId: string,
|
|
55
|
-
): Promise<
|
|
55
|
+
): Promise<
|
|
56
|
+
| boolean
|
|
57
|
+
| {
|
|
58
|
+
barcodeResultsObject: any;
|
|
59
|
+
licenseFrontBase64: string;
|
|
60
|
+
licenseBackBase64: string;
|
|
61
|
+
errorMessages: string;
|
|
62
|
+
}
|
|
63
|
+
>;
|
|
56
64
|
|
|
57
65
|
export function localContinueScanId(
|
|
58
66
|
scannerAddress: string,
|
|
@@ -69,3 +77,11 @@ declare module "verant_id_cloud_scan" {
|
|
|
69
77
|
}
|
|
70
78
|
|
|
71
79
|
export function scannerPresent(scannerAddress: string): Promise<boolean>;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Explicitly set the API environment.
|
|
83
|
+
* By default, production is used for all hosts (including localhost).
|
|
84
|
+
* Only verify-staging.verantid.com automatically uses staging.
|
|
85
|
+
* @param environment - 'staging' or 'production'
|
|
86
|
+
*/
|
|
87
|
+
export function setEnvironment(environment: 'staging' | 'production'): void;
|