veryfi-lens-wasm 3.5.9 → 3.5.11

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 CHANGED
@@ -111,8 +111,8 @@ VeryfiLens.onFailure((error) => { /* error occurred */ });
111
111
  | `lensFlavor` | `string` | — | **Required.** Capture mode (see [Supported Flavors](#supported-flavors)) |
112
112
  | `container` | `string` | — | ID of an HTML element to render into. If omitted, creates a fullscreen overlay |
113
113
  | `theme` | `"light"\|"dark"\|"system"` | `"system"` | UI color theme. `"system"` follows OS changes while the lens is open |
114
- | `enableSubmit` | `boolean` | `true` | Show submit button after capture. With `false` (and `packageMode: false`) the review gallery's Submit uploads nothing: it fires the `showCamera` setter (checks: `{ frontImage, backImage, ...per-side LCD / front-back results }`; other flavors: `{ image, images }` — `image` is the last page, `images` every page in order), or calls `customSubmitHandler(image, null)` when set, then closes |
115
- | `sendCroppedImage` | `boolean` | `true` | Include the captured image in the per-capture `/rest/send-cropped` request (`packageMode: false` only). With `false` only metadata is sent; the image is still sent to `/api/document` on submit |
114
+ | `enableSubmit` | `boolean` | `true` | Show submit button after capture. With `false` (and `packageMode: false`) the review gallery's Submit does not call `/api/document`: it still posts each page to `/rest/send-cropped` (fires `document_ready`; metadata only unless `sendCroppedImage` is `true`), then fires the `showCamera` setter (checks: `{ frontImage, backImage, ...per-side LCD / front-back results }`; other flavors: `{ image, images }` — `image` is the last page, `images` every page in order), or calls `customSubmitHandler(image, null)` when set, then closes |
115
+ | `sendCroppedImage` | `boolean` | `false` | Include the captured image in the per-capture `/rest/send-cropped` request (`packageMode: false` only). With `false` only metadata is sent; the image is still sent to `/api/document` on submit. The request (and `document_ready`) is always made either way |
116
116
  | `enableFullScreen` | `boolean` | `false` | Enable fullscreen mode |
117
117
  | `debug_mode` | `boolean` | `false` | Enable console logging |
118
118
  | `useDevApi` | `boolean` | `false` | Route API requests to `lens-dev.veryfi.com` instead of production |
@@ -132,6 +132,7 @@ VeryfiLens.onFailure((error) => { /* error occurred */ });
132
132
  | `mirrorButton` | `boolean` | `true` | Show mirror/flip video button |
133
133
  | `mirrorOnDesktop` | `boolean` | `true` | Auto-mirror video on desktop (front-facing webcam) |
134
134
  | `exitButton` | `boolean` | `false` | Show exit/close button |
135
+ | `watermarkPosition` | `string` | `"top-right"` | Corner for the "Powered by Veryfi" watermark (when enabled for the client): `"top-right"`, `"top-left"`, `"bottom-right"`, `"bottom-left"` |
135
136
  | `showCameraPermissionDeniedMessage` | `boolean` | `true` | Show the in-lens message when camera access is denied. Set `false` to render it on your own error screen. A denial always hides every on-camera control and is reported via `onUpdate` as `{ status: "camera_permission_denied", message, error }` (never via `onFailure`) |
136
137
  | `onClose` | `function` | — | Callback when lens is closed |
137
138
  | `onCloseRedirectUrl` | `string` | — | URL to redirect to on close |
@@ -147,6 +148,7 @@ VeryfiLens.onFailure((error) => { /* error occurred */ });
147
148
  | `isLcdModal` | `boolean` | `true` | Show modal when LCD/screen capture detected |
148
149
  | `isDesktopModeModal` | `boolean` | `true` | Show the modal asking mobile users to leave "Desktop site" mode |
149
150
  | `isReceiptGroupingModal` | `boolean` | `false` | When a receipt (`document` flavor) frame contains several receipts, ask whether they are one transaction (submitted as one multi-page document) or separate receipts (one document each). With `false` they are always separate. Only applies when multiple documents are allowed (`multiSubmission` or `maxDocuments` other than `1`) |
151
+ | `isLongReceiptNoDocumentModal` | `boolean` | `true` | Long receipt (`long_document` flavor): when Stop is pressed but nothing was stitched, tell the user to hold the receipt closer and press Start only after the green box appears. Always fires `stitching_failed`; `failureHandler` is called only when this modal is disabled |
150
152
  | `enforceDocumentDetection` | `boolean` | `false` | Block submission if no document detected |
151
153
  | `enforceBlurDetection` | `boolean` | `false` | Block submission if image is blurry |
152
154
  | `enforceLcdDetection` | `boolean` | `false` | Block submission if screen capture detected |
@@ -307,6 +309,8 @@ When `multiSubmission` is set or `maxDocuments` is not `1`, `init()` asks the ba
307
309
  | `receiptGroupingModalMessage` | `string` | `"Several receipts were found. Are they part of one transaction?"` |
308
310
  | `receiptGroupingOneTransactionText` | `string` | `"One transaction"` |
309
311
  | `receiptGroupingSeparateText` | `string` | `"Separate receipts"` |
312
+ | `longReceiptNoDocumentMessage` | `string` | `"We could not detect the receipt. Hold the receipt closer to the camera and press Start only after you see a green box around it."` |
313
+ | `longReceiptNoDocumentRetryText` | `string` | `"Try again"` |
310
314
  | `submitButtonText` | `string` | `"Submit Anyway"` |
311
315
  | `retakeButtonText` | `string` | `"Retake a picture"` |
312
316
  | `cameraPermissionDeniedMessage` | `string` | `"Camera access was blocked. Please allow camera access in your browser settings and try again."` |
@@ -0,0 +1,22 @@
1
+ import { createModal } from './modalBase.js';
2
+
3
+ export const createLongReceiptNoDocumentModal = (container, croppedImage, onRetry, options = {}) => {
4
+ const defaults = {
5
+ message: 'We could not detect the receipt. Hold the receipt closer to the camera and press Start only after you see a green box around it.',
6
+ retryText: 'Try again',
7
+ };
8
+ const o = { ...defaults, ...options };
9
+
10
+ return createModal(container, {
11
+ id: 'veryfi-long-receipt-no-document-modal',
12
+ cssPrefix: 'long-receipt-no-document-modal',
13
+ message: o.message,
14
+ primaryButtonText: o.retryText,
15
+ primaryButtonId: 'veryfi-long-receipt-no-document-retry',
16
+ onPrimaryClick: onRetry,
17
+ croppedImage,
18
+ useBackdrop: true,
19
+ primaryClearsCanvas: false,
20
+ showCropBorder: false,
21
+ });
22
+ };
@@ -1,4 +1,7 @@
1
- export const createWatermark = (container) => {
1
+ export const WATERMARK_POSITIONS = ['top-right', 'top-left', 'bottom-right', 'bottom-left'];
2
+
3
+ export const createWatermark = (container, options = {}) => {
4
+ const position = WATERMARK_POSITIONS.includes(options.position) ? options.position : 'top-right';
2
5
  const watermark = document.createElement('div');
3
6
  watermark.id = 'veryfi-watermark';
4
7
 
@@ -44,11 +47,14 @@ export const createWatermark = (container) => {
44
47
  `;
45
48
 
46
49
  const isDesktop = window.innerWidth > 768;
50
+ const horizontalOffset = isDesktop ? '-240px' : '-200px';
51
+ const [vertical, horizontal] = position.split('-');
47
52
 
48
53
  Object.assign(watermark.style, {
49
54
  position: 'absolute',
50
- top: '50px',
51
- right: `${isDesktop ? '-240px' : '-200px'}`,
55
+ // Bottom positions sit above the bottom control row (capture/torch/exit buttons).
56
+ [vertical]: vertical === 'top' ? '50px' : '120px',
57
+ [horizontal]: horizontalOffset,
52
58
  zIndex: '999',
53
59
  pointerEvents: 'auto',
54
60
  opacity: '0.9'
package/core/camera.js CHANGED
@@ -48,7 +48,7 @@ export const getVideo = async (lensFlavor) => {
48
48
  const isAndroid = /Android/i.test(navigator.userAgent);
49
49
 
50
50
  let videoConfig = {
51
- ...(lensFlavor === 'long_document' || lensFlavor === 'prescription_label' || state.fullScreenEnabled ? {
51
+ ...(lensFlavor === 'prescription_label' || state.fullScreenEnabled ? {
52
52
  width: { ideal: 1920 },
53
53
  height: { ideal: 1080 }
54
54
  } : {
package/core/constants.js CHANGED
@@ -8,6 +8,7 @@ const WASM_PATH = '/static/wasm/';
8
8
 
9
9
  export const WASM = {
10
10
  BASE_URL: `${API_BASES.PROD}${WASM_PATH}`,
11
+ LOCAL_BASE_URL: '/wasm/',
11
12
  };
12
13
 
13
14
  const buildApiUrls = (base) => ({
@@ -39,7 +40,7 @@ export const setApiBaseUrl = (base) => {
39
40
  };
40
41
 
41
42
  export const DEFAULTS = {
42
- SDK_VERSION: '3.5.9',
43
+ SDK_VERSION: '3.5.11',
43
44
  BLUR_THRESHOLD: 0.7,
44
45
  LCD_THRESHOLD: 0.5,
45
46
  BOX_COLOR: 'rgba(84, 192, 139, 0.6)',
@@ -69,6 +70,7 @@ export const DEFAULTS = {
69
70
  GUIDE_MAX_HEIGHT_SCALE: 0.70,
70
71
  CROP_MARGIN: 0.0,
71
72
  CHECKS_CROP_MARGIN: 0.1,
73
+ LONG_DOCUMENT_FRAME_SHORT_SIDE: 1080,
72
74
  };
73
75
 
74
76
  export const MESSAGES = {
@@ -110,6 +112,8 @@ export const MESSAGES = {
110
112
  RECEIPT_GROUPING_PROMPT: 'Several receipts were found. Are they part of one transaction?',
111
113
  RECEIPT_GROUPING_ONE: 'One transaction',
112
114
  RECEIPT_GROUPING_SEPARATE: 'Separate receipts',
115
+ LONG_RECEIPT_NO_DOCUMENT: 'We could not detect the receipt. Hold the receipt closer to the camera and press Start only after you see a green box around it.',
116
+ LONG_RECEIPT_NO_DOCUMENT_RETRY: 'Try again',
113
117
  REVIEW_TITLE: 'Review',
114
118
  REVIEW_ADD_PAGE: 'Add Page',
115
119
  REVIEW_ADD_DOCUMENT: 'Add Document',
package/core/lifecycle.js CHANGED
@@ -217,29 +217,45 @@ export const stopStitching = async () => {
217
217
  state.isStitchingProcess = false;
218
218
  state.stitchingButton.setStitching(false);
219
219
 
220
- state.finalImage = await getLongImage();
221
- if (state.finalImage) {
222
- hideVideoOverlay();
223
- state.longPreview?.hide?.();
224
- state.resultSetter?.(state.finalImage);
225
- state.docReadyResult = await docReady();
226
- await fireResultSetter({ ...state.docReadyResult, image: state.finalImage });
227
- const partnerDriven =
228
- state.packageMode && !state.enableSubmit && typeof state.customSubmitHandler !== 'function';
229
- state.submitButton = createSubmitButton(
230
- state.videoOverlay.overlay,
231
- () => {
232
- if (!partnerDriven) {
233
- handleSubmit(state.finalImage);
234
- }
235
- },
236
- () => actions.removeOverlay(),
237
- { buttonText: partnerDriven ? 'Done' : 'Submit' }
238
- );
239
- (state.enableSubmit || partnerDriven) && state.submitButton.show();
240
- holdSubmitForFieldDetectionIfNeeded();
241
- void onCropPreviewReady();
220
+ // With nothing stitched (no document detected between Start and Stop) the
221
+ // WASM stitcher throws a raw C++ exception pointer instead of returning an
222
+ // empty image.
223
+ let longImage = null;
224
+ try {
225
+ longImage = await getLongImage();
226
+ } catch (error) {
227
+ state.debug_mode && console.log('[STITCHING] getLongImage failed:', error);
242
228
  }
229
+ state.finalImage = longImage;
230
+ if (!state.finalImage) {
231
+ state.updateHandler?.({ status: 'stitching_failed' });
232
+ if (state.longReceiptNoDocumentModal) {
233
+ state.longReceiptNoDocumentModal.show();
234
+ } else {
235
+ state.failureHandler?.(new Error('No document was captured while stitching'));
236
+ }
237
+ return;
238
+ }
239
+ hideVideoOverlay();
240
+ state.longPreview?.hide?.();
241
+ state.resultSetter?.(state.finalImage);
242
+ state.docReadyResult = await docReady();
243
+ await fireResultSetter({ ...state.docReadyResult, image: state.finalImage });
244
+ const partnerDriven =
245
+ state.packageMode && !state.enableSubmit && typeof state.customSubmitHandler !== 'function';
246
+ state.submitButton = createSubmitButton(
247
+ state.videoOverlay.overlay,
248
+ () => {
249
+ if (!partnerDriven) {
250
+ handleSubmit(state.finalImage);
251
+ }
252
+ },
253
+ () => actions.removeOverlay(),
254
+ { buttonText: partnerDriven ? 'Done' : 'Submit' }
255
+ );
256
+ (state.enableSubmit || partnerDriven) && state.submitButton.show();
257
+ holdSubmitForFieldDetectionIfNeeded();
258
+ void onCropPreviewReady();
243
259
  state.updateHandler?.({ status: 'stitching_completed' });
244
260
  };
245
261
 
@@ -257,17 +257,6 @@ const submitOneDocument = async (docIndex) => {
257
257
  const checksExtra = isChecks ? buildChecksExtra(doc) : null;
258
258
  const setterImage = isChecks ? (doc.pages[0]?.data ?? null) : image;
259
259
 
260
- if (isLocalOnlySubmit()) {
261
- const hasHandler = typeof state.customSubmitHandler === 'function';
262
- if (isChecks) {
263
- state.resultSetter?.(checksExtra);
264
- } else if (!hasHandler) {
265
- state.resultSetter?.({ image: originalData, images: doc.pages.map((page) => page.data) });
266
- }
267
- if (hasHandler) state.customSubmitHandler(setterImage, null);
268
- return null;
269
- }
270
-
271
260
  // Rebuild the per-document package buffer from the store so deletes/retakes
272
261
  // are reflected, and give each document its own package identity.
273
262
  if (state.packageMode) {
@@ -286,6 +275,19 @@ const submitOneDocument = async (docIndex) => {
286
275
  }
287
276
  }
288
277
 
278
+ // document_ready (/rest/send-cropped above) always fires; only the
279
+ // /api/document submit is left to the partner.
280
+ if (isLocalOnlySubmit()) {
281
+ const hasHandler = typeof state.customSubmitHandler === 'function';
282
+ if (isChecks) {
283
+ state.resultSetter?.(checksExtra);
284
+ } else if (!hasHandler) {
285
+ state.resultSetter?.({ image: originalData, images: doc.pages.map((page) => page.data) });
286
+ }
287
+ if (hasHandler) state.customSubmitHandler(setterImage, null);
288
+ return null;
289
+ }
290
+
289
291
  if (isPartnerDriven()) {
290
292
  const packageInfo = await ensurePackageUploaded();
291
293
  state.resultSetter?.({ ...(packageInfo || {}), ...(checksExtra || { image: originalData }) });
package/core/state.js CHANGED
@@ -64,6 +64,7 @@ export const state = {
64
64
  frontImage: null,
65
65
  backImage: null,
66
66
  previewData: null,
67
+ longDocumentFrameScale: 1,
67
68
 
68
69
  // Configuration
69
70
  clientId: "",
@@ -79,6 +80,7 @@ export const state = {
79
80
  enableFullScreen: false,
80
81
  testBlurDetection: true,
81
82
  useDevApi: false,
83
+ useLocalWasm: false,
82
84
 
83
85
  // UI Configuration
84
86
  theme: 'system',
@@ -91,8 +93,10 @@ export const state = {
91
93
  isLcdModal: true,
92
94
  isDesktopModeModal: true,
93
95
  isReceiptGroupingModal: false,
96
+ isLongReceiptNoDocumentModal: true,
94
97
  container: null,
95
98
  exitButton: false,
99
+ watermarkPosition: 'top-right',
96
100
  showCameraPermissionDeniedMessage: true,
97
101
  cameraPermissionDeniedMessage: MESSAGES.CAMERA_PERMISSION_DENIED,
98
102
  onCloseRedirectUrl: null,
@@ -215,6 +219,7 @@ export const state = {
215
219
  anydocFlipModal: null,
216
220
  checkFlipModal: null,
217
221
  receiptGroupingModal: null,
222
+ longReceiptNoDocumentModal: null,
218
223
  torchButtonRef: null,
219
224
  mirrorButtonRef: null,
220
225
  switchCameraButtonRef: null,
@@ -239,6 +244,8 @@ export const state = {
239
244
  receiptGroupingModalMessage: MESSAGES.RECEIPT_GROUPING_PROMPT,
240
245
  receiptGroupingOneTransactionText: MESSAGES.RECEIPT_GROUPING_ONE,
241
246
  receiptGroupingSeparateText: MESSAGES.RECEIPT_GROUPING_SEPARATE,
247
+ longReceiptNoDocumentMessage: MESSAGES.LONG_RECEIPT_NO_DOCUMENT,
248
+ longReceiptNoDocumentRetryText: MESSAGES.LONG_RECEIPT_NO_DOCUMENT_RETRY,
242
249
  submitButtonText: MESSAGES.SUBMIT_ANYWAY,
243
250
  retakeButtonText: MESSAGES.RETAKE,
244
251
 
@@ -372,6 +379,7 @@ export const resetState = () => {
372
379
  state.frontImage = null;
373
380
  state.backImage = null;
374
381
  state.previewData = null;
382
+ state.longDocumentFrameScale = 1;
375
383
  state.capCircleRadius = DEFAULTS.CAP_CIRCLE_RADIUS;
376
384
  state.bottleCapText = MESSAGES.BOTTLE_CAP;
377
385
  state.enforceAndSkipBothSides = false;
@@ -387,6 +395,7 @@ export const resetState = () => {
387
395
  state.anydocFlipModal = null;
388
396
  state.checkFlipModal = null;
389
397
  state.receiptGroupingModal = null;
398
+ state.longReceiptNoDocumentModal = null;
390
399
  state.frameRef = null;
391
400
  state.cropImgRef = null;
392
401
  state.videoRef = null;
@@ -14,6 +14,7 @@ import { createCreditCardComponent } from '../components/creditCard.js';
14
14
  import { createWrongSideModal } from '../components/wrongSideModal.js';
15
15
  import { createAnydocFlipModal } from '../components/anydocFlipModal.js';
16
16
  import { createReceiptGroupingModal } from '../components/receiptGroupingModal.js';
17
+ import { createLongReceiptNoDocumentModal } from '../components/longReceiptNoDocumentModal.js';
17
18
  import { createWatermark } from '../components/watermark.js';
18
19
  import { createCardDataButton } from '../components/cardDataButton.js';
19
20
  import { createBottleCapOverlay } from '../components/bottleCapOverlay.js';
@@ -32,7 +33,9 @@ export const renderWatermarkIfNeeded = () => {
32
33
  if (state.clientData?.show_watermark) {
33
34
  state.debug_mode && console.log("Rendering watermark");
34
35
  if (!refs.watermarkComponent) {
35
- refs.watermarkComponent = createWatermark(state.videoOverlay ? state.videoOverlay.overlay : state.container);
36
+ refs.watermarkComponent = createWatermark(state.videoOverlay ? state.videoOverlay.overlay : state.container, {
37
+ position: state.watermarkPosition,
38
+ });
36
39
  refs.watermarkComponent.show();
37
40
  }
38
41
  }
@@ -204,7 +207,9 @@ export const renderCreditCardIfNeeded = () => {
204
207
  }
205
208
 
206
209
  if (state.clientData?.show_watermark && !refs.watermarkComponent) {
207
- refs.watermarkComponent = createWatermark(state.cardOverlay.element);
210
+ refs.watermarkComponent = createWatermark(state.cardOverlay.element, {
211
+ position: state.watermarkPosition,
212
+ });
208
213
  refs.watermarkComponent.show();
209
214
  }
210
215
  };
@@ -338,6 +343,18 @@ export const renderModalsIfNeeded = () => {
338
343
  }
339
344
  );
340
345
  }
346
+
347
+ if (state.isLongReceiptNoDocumentModal && state.lensFlavor === 'long_document') {
348
+ state.longReceiptNoDocumentModal = createLongReceiptNoDocumentModal(
349
+ state.container,
350
+ state.croppedImage,
351
+ () => {},
352
+ {
353
+ message: state.longReceiptNoDocumentMessage,
354
+ retryText: state.longReceiptNoDocumentRetryText,
355
+ }
356
+ );
357
+ }
341
358
  };
342
359
 
343
360
  export const renderBottleCapOverlayIfNeeded = () => {
@@ -50,7 +50,8 @@ export const initializeWasmWrapper = async () => {
50
50
  }
51
51
  if (!refs.wasmWrapper.loaded) {
52
52
  await refs.wasmWrapper.initialize(state.clientId, {
53
- wasmBaseUrl: WASM.BASE_URL,
53
+ wasmBaseUrl: state.useLocalWasm ? WASM.LOCAL_BASE_URL : WASM.BASE_URL,
54
+ hostedLayout: !state.useLocalWasm,
54
55
  useDevApi: state.useDevApi,
55
56
  debug: state.debug_mode,
56
57
  });
@@ -121,7 +122,8 @@ export function logDocument(detectorResult, corners, nDocs) {
121
122
  }
122
123
 
123
124
  export function logLongDocument(stitcherResult, corners, nDocs, preview) {
124
- state.coordinates = corners.map((corner) => [corner.x, corner.y]);
125
+ const scale = state.longDocumentFrameScale;
126
+ state.coordinates = corners.map((corner) => [corner.x / scale, corner.y / scale]);
125
127
  state.previewData = preview;
126
128
  state.shouldUpdatePreview = stitcherResult === 0;
127
129
  state.isDocument = corners.length > 0 && stitcherResult === 0;
@@ -190,6 +192,23 @@ export const logCard = (status, name, number, date, cvv) => {
190
192
  }
191
193
  };
192
194
 
195
+ const createLongDocumentFrame = async (video) => {
196
+ const scale = Math.min(
197
+ 1,
198
+ DEFAULTS.LONG_DOCUMENT_FRAME_SHORT_SIDE / Math.min(video.videoWidth, video.videoHeight)
199
+ );
200
+ const bitmap = scale < 1
201
+ ? await createImageBitmap(video, {
202
+ resizeWidth: Math.round(video.videoWidth * scale),
203
+ resizeHeight: Math.round(video.videoHeight * scale),
204
+ resizeQuality: 'medium',
205
+ })
206
+ : await createImageBitmap(video);
207
+ // Measured from the bitmap because some browsers ignore the resize options.
208
+ state.longDocumentFrameScale = bitmap.width / video.videoWidth;
209
+ return bitmap;
210
+ };
211
+
193
212
  export const sendWasm = async (mode) => {
194
213
  if (!refs.wasmWrapper) {
195
214
  state.debug_mode && console.log("WASM wrapper not initialized");
@@ -267,7 +286,9 @@ export const sendWasm = async (mode) => {
267
286
  }
268
287
  } else {
269
288
  try {
270
- const bitmap = await createImageBitmap(video);
289
+ const bitmap = state.lensFlavor === 'long_document'
290
+ ? await createLongDocumentFrame(video)
291
+ : await createImageBitmap(video);
271
292
  if (state.fullSizeImage?.close) {
272
293
  state.fullSizeImage.close();
273
294
  }
@@ -360,6 +381,9 @@ export const sendCardWasm = async () => {
360
381
 
361
382
  export const getLongImage = async () => {
362
383
  const wasmOutput = await refs.wasmWrapper.getStitchedImage();
384
+ if (!wasmOutput?.outputWidth || !wasmOutput?.outputHeight) {
385
+ return null;
386
+ }
363
387
  const { data, blurLevel, outputHeight, outputWidth } = wasmOutput;
364
388
  const width = outputWidth;
365
389
  const height = outputHeight;
package/flavors/upload.js CHANGED
@@ -16,15 +16,14 @@ export const render = async (state, refs, actions) => {
16
16
 
17
17
  if (!state.enableSubmit) {
18
18
  state.debug_mode && console.log("Submit disabled, handling image directly");
19
- if (state.packageMode) {
20
- // packageMode + !enableSubmit: upload the cumulative zip on capture so
21
- // the showCamera setter receives bucket/package_path alongside image.
22
- state.finalImage = formattedResult.image;
23
- try {
24
- state.docReadyResult = await docReady();
25
- } catch (error) {
26
- state.debug_mode && console.error('docReady failed for gallery upload:', error);
27
- }
19
+ // document_ready always fires: packageMode queues the scan for the
20
+ // cumulative zip (uploaded by fireResultSetter so the setter receives
21
+ // bucket/package_path); legacy mode posts /rest/send-cropped now.
22
+ state.finalImage = formattedResult.image;
23
+ try {
24
+ state.docReadyResult = await docReady();
25
+ } catch (error) {
26
+ state.debug_mode && console.error('docReady failed for gallery upload:', error);
28
27
  }
29
28
  const finalized = await fireResultSetter(formattedResult);
30
29
  if (finalized) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "veryfi-lens-wasm",
3
- "version": "3.5.9",
3
+ "version": "3.5.11",
4
4
  "description": "Lens For Web SDK with WASM",
5
5
  "main": "veryfi-lens.js",
6
6
  "type": "module",
package/wasm/wasm.js CHANGED
@@ -73,6 +73,9 @@ export class WasmWrapper {
73
73
  * @param {Object} [options]
74
74
  * @param {string} [options.wasmBaseUrl] - Base URL for hosted WASM files.
75
75
  * Defaults to "/wasm/".
76
+ * @param {boolean} [options.hostedLayout] - When false, variants are read
77
+ * from `<wasmBaseUrl><variant>/` instead of `<wasmBaseUrl>hosted/<variant>/`.
78
+ * Defaults to true.
76
79
  * @param {boolean} [options.useDevApi] - When true, WASM model fetches use
77
80
  * lens-dev.veryfi.com instead of production.
78
81
  */
@@ -89,7 +92,7 @@ export class WasmWrapper {
89
92
  console.log(`[PERF][WASM] feature detection: ${(performance.now() - tFeat0).toFixed(1)}ms (simd=${useSimd})`);
90
93
 
91
94
  const simdDir = this.selectDir(useSimd);
92
- const dir = "hosted/" + simdDir;
95
+ const dir = (options.hostedLayout === false ? "" : "hosted/") + simdDir;
93
96
  console.log("[PERF][WASM] Using hosted build, variant:", simdDir);
94
97
 
95
98
  const scriptUrl = wasmBaseUrl + dir + "/veryfi-wasm.js";