scandoc-ai-components 0.0.30 → 0.0.32

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.
Files changed (2) hide show
  1. package/dist/index.js +18 -16
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -11221,12 +11221,6 @@ class ExtractorVideo {
11221
11221
  this.validationStartTime = Date.now();
11222
11222
  }
11223
11223
  this.wasDocumentPreviouslyDetected = true;
11224
- this.candidateImages.push({
11225
- fullImg: fullImage,
11226
- validationImg: validationImage
11227
- });
11228
- const images = [...this.candidateImages];
11229
- const now = Date.now();
11230
11224
  if (this.validationStartTime && now - this.validationStartTime > cfgValues.VALIDATION_TIMEOUT_MS) {
11231
11225
  this.stopVideo();
11232
11226
  this.onExtractedResults({
@@ -11236,6 +11230,11 @@ class ExtractorVideo {
11236
11230
  });
11237
11231
  return;
11238
11232
  }
11233
+ this.candidateImages.push({
11234
+ fullImg: fullImage,
11235
+ validationImg: validationImage
11236
+ });
11237
+ const images = [...this.candidateImages];
11239
11238
  if (images.length >= ExtractorVideo.VALIDATION_BATCH_SIZE) {
11240
11239
  const [isValidationOk, response] = await (0,_requests_validation__WEBPACK_IMPORTED_MODULE_3__["default"])(images.map(e => e["validationImg"]), this.pastBlurValues, {});
11241
11240
  if (isValidationOk) {
@@ -11282,16 +11281,8 @@ class ExtractorVideo {
11282
11281
  return;
11283
11282
  }
11284
11283
  } else {
11284
+ this.wasDocumentPreviouslyDetected = false;
11285
11285
  this.candidateImages = [];
11286
- if (response?.statusCode === 401 || response?.statusCode === 403) {
11287
- this.stopVideo();
11288
- this.onExtractedResults({
11289
- success: false,
11290
- code: "004",
11291
- info: "Unauthorized. Please check your key."
11292
- });
11293
- return;
11294
- }
11295
11286
  }
11296
11287
  this.validationStartTime = null;
11297
11288
  this.candidateImages = [];
@@ -11325,7 +11316,18 @@ class ExtractorVideo {
11325
11316
  setTimeout(() => this.analyzeVideoStream(), ExtractorVideo.FREQUENCY_MS);
11326
11317
  }
11327
11318
  }
11328
- startVideo() {
11319
+ async startVideo() {
11320
+ try {
11321
+ const serviceConfig = (0,_config__WEBPACK_IMPORTED_MODULE_1__.getScanDocAIConfig)();
11322
+ await serviceConfig.getAccessToken(true);
11323
+ } catch (authError) {
11324
+ this.onExtractedResults({
11325
+ success: false,
11326
+ code: "004",
11327
+ info: "Authentication failed."
11328
+ });
11329
+ return false;
11330
+ }
11329
11331
  const videoElem = document.getElementById("ScanDocAIVideoElement");
11330
11332
  if (videoElem !== undefined) {
11331
11333
  this.video = videoElem;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "scandoc-ai-components",
3
3
  "author": "ScanDoc-AI",
4
- "version": "0.0.30",
4
+ "version": "0.0.32",
5
5
  "private": false,
6
6
  "description": "Pure JavaScript package for integrating ScanDoc-AI services.",
7
7
  "keywords": [