veryfi-lens-wasm 3.1.2 → 3.1.4
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/constants.js +22 -7
- package/core/state.js +1 -1
- package/core/ui-renderer.js +2 -2
- 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
|
|
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.4',
|
|
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
|
@@ -74,6 +74,7 @@ export const state = {
|
|
|
74
74
|
enableSubmit: true,
|
|
75
75
|
enableFullScreen: false,
|
|
76
76
|
testBlurDetection: true,
|
|
77
|
+
useDevApi: false,
|
|
77
78
|
|
|
78
79
|
// UI Configuration
|
|
79
80
|
torchButton: true,
|
|
@@ -139,7 +140,6 @@ export const state = {
|
|
|
139
140
|
successHandler: null,
|
|
140
141
|
updateHandler: null,
|
|
141
142
|
failureHandler: null,
|
|
142
|
-
submitHandler: null,
|
|
143
143
|
|
|
144
144
|
// References
|
|
145
145
|
boxRef: null,
|
package/core/ui-renderer.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { state, refs, actions } from './state.js';
|
|
2
2
|
import { hideVideoOverlay, showVideoOverlay } from './overlay-controls.js';
|
|
3
3
|
import { toggleTorchLight, mirrorVideo, switchCamera } from './camera.js';
|
|
4
|
-
import { ensurePackageUploaded } from './api.js';
|
|
4
|
+
import { ensurePackageUploaded, handleSubmit } from './api.js';
|
|
5
5
|
import { createVideo } from '../components/video.js';
|
|
6
6
|
import { createBlurModal } from '../components/blurModal.js';
|
|
7
7
|
import { createDocumentModal } from '../components/documentModal.js';
|
|
@@ -103,7 +103,7 @@ const getModalSubmitHandler = () => {
|
|
|
103
103
|
const packageInfo = await ensurePackageUploaded();
|
|
104
104
|
state.customSubmitHandler(state.finalImage, packageInfo);
|
|
105
105
|
} else {
|
|
106
|
-
|
|
106
|
+
handleSubmit(state.finalImage);
|
|
107
107
|
}
|
|
108
108
|
};
|
|
109
109
|
};
|
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);
|