veryfi-lens-wasm 3.1.1 → 3.1.3
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 +1 -0
- package/core/capture/prescription_label.js +1 -1
- package/core/constants.js +22 -7
- package/core/state.js +1 -0
- package/package.json +1 -1
- package/veryfi-lens.js +5 -2
package/README.md
CHANGED
|
@@ -113,6 +113,7 @@ VeryfiLens.onFailure((error) => { /* error occurred */ });
|
|
|
113
113
|
| `enableSubmit` | `boolean` | `true` | Show submit button after capture |
|
|
114
114
|
| `enableFullScreen` | `boolean` | `false` | Enable fullscreen mode |
|
|
115
115
|
| `debug_mode` | `boolean` | `false` | Enable console logging |
|
|
116
|
+
| `useDevApi` | `boolean` | `false` | Route API requests to `lens-dev.veryfi.com` instead of production |
|
|
116
117
|
|
|
117
118
|
### UI Controls
|
|
118
119
|
|
|
@@ -241,7 +241,7 @@ const startRecording = () => {
|
|
|
241
241
|
startCroppedDrawLoop(state.videoRef, region);
|
|
242
242
|
state.debug_mode && console.log(`[prescription_label] Cropping video to ${cropCanvas.width}x${cropCanvas.height} (source region ${Math.round(region.srcW)}x${Math.round(region.srcH)} at ${Math.round(region.srcX)},${Math.round(region.srcY)})`);
|
|
243
243
|
previewStream = cropCanvas.captureStream(30);
|
|
244
|
-
submissionStream = cropCanvas.captureStream(
|
|
244
|
+
submissionStream = cropCanvas.captureStream(2);
|
|
245
245
|
} catch (e) {
|
|
246
246
|
console.warn('[prescription_label] Failed to set up cropped recording stream, falling back to full video:', e);
|
|
247
247
|
stopCroppedDrawLoop();
|
package/core/constants.js
CHANGED
|
@@ -2,18 +2,33 @@ export const WASM = {
|
|
|
2
2
|
BASE_URL: 'https://lens.veryfi.com/static/wasm/',
|
|
3
3
|
};
|
|
4
4
|
|
|
5
|
-
export const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
export const API_BASES = {
|
|
6
|
+
PROD: 'https://lens.veryfi.com',
|
|
7
|
+
DEV: 'https://lens-dev.veryfi.com',
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const buildApiUrls = (base) => ({
|
|
11
|
+
VALIDATE_PARTNER: `${base}/rest/validate_partner`,
|
|
12
|
+
SEND_CROPPED: `${base}/rest/send-cropped`,
|
|
13
|
+
SEND_PACKAGE: `${base}/rest/send-package`,
|
|
14
|
+
PROCESS_DOCUMENT: `${base}/api/document`,
|
|
15
|
+
BLUEPRINTS: `${base}/api/blueprints`,
|
|
11
16
|
FINGERPRINT: 'https://fp.veryfi.com',
|
|
12
17
|
FINGERPRINT_SCRIPT: 'https://fp.veryfi.com/web/v<version>/<apiKey>/loader_v<loaderVersion>.js',
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
// Mutable URL bag. Other modules import this reference and read fields at
|
|
21
|
+
// fetch time, so swapping fields in place via setApiEnvironment() is enough
|
|
22
|
+
// to retarget all subsequent requests without re-importing.
|
|
23
|
+
export const API_URLS = buildApiUrls(API_BASES.PROD);
|
|
24
|
+
|
|
25
|
+
export const setApiEnvironment = (useDevApi) => {
|
|
26
|
+
const base = useDevApi ? API_BASES.DEV : API_BASES.PROD;
|
|
27
|
+
Object.assign(API_URLS, buildApiUrls(base));
|
|
13
28
|
};
|
|
14
29
|
|
|
15
30
|
export const DEFAULTS = {
|
|
16
|
-
SDK_VERSION: '3.1.
|
|
31
|
+
SDK_VERSION: '3.1.3',
|
|
17
32
|
BLUR_THRESHOLD: 0.7,
|
|
18
33
|
LCD_THRESHOLD: 0.5,
|
|
19
34
|
BOX_COLOR: 'rgba(84, 192, 139, 0.6)',
|
package/core/state.js
CHANGED
package/package.json
CHANGED
package/veryfi-lens.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { state, refs, actions } from './core/state.js';
|
|
2
|
-
import { DEFAULTS } from './core/constants.js';
|
|
2
|
+
import { DEFAULTS, setApiEnvironment } from './core/constants.js';
|
|
3
3
|
import { flattenObject, parseUA, getBrowserData } from './core/utils.js';
|
|
4
4
|
import { generateDeviceIDifNeeded, setLCDDetectionSettings, setFrontBackDetectionSettings, getDocumentLcdStatus } from './core/device.js';
|
|
5
5
|
import { toggleTorchLight, mirrorVideo, switchCamera } from './core/camera.js';
|
|
@@ -28,6 +28,10 @@ const VeryfiLens = {
|
|
|
28
28
|
config.debug_mode && (state.debug_mode = true);
|
|
29
29
|
config.debug_mode && console.log("init", config);
|
|
30
30
|
state.clientId = clientId;
|
|
31
|
+
// Apply API environment before validatePartner so the very first
|
|
32
|
+
// request hits the right host.
|
|
33
|
+
state.useDevApi = config.useDevApi ?? false;
|
|
34
|
+
setApiEnvironment(state.useDevApi);
|
|
31
35
|
state.clientData = await validatePartner(state.clientId);
|
|
32
36
|
config.debug_mode && console.log(state.clientData);
|
|
33
37
|
|
|
@@ -74,7 +78,6 @@ const VeryfiLens = {
|
|
|
74
78
|
|
|
75
79
|
state.enforceFingerprint = config.enforceFingerprint ?? false;
|
|
76
80
|
state.disableFingerprint = config.disableFingerprint ?? false;
|
|
77
|
-
state.packageMode = config.packageMode ?? true;
|
|
78
81
|
|
|
79
82
|
} catch (error) {
|
|
80
83
|
console.error("Error initializing Lens:", error);
|