scandoc-ai-components 0.1.3 → 0.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.
Files changed (2) hide show
  1. package/dist/index.js +40 -5
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -11246,6 +11246,17 @@ class ExtractorVideo {
11246
11246
  if (images.length < ExtractorVideo.VALIDATION_BATCH_SIZE) return;
11247
11247
  const [isValidationOk, response] = await (0,_requests_validation__WEBPACK_IMPORTED_MODULE_3__["default"])(images.map(e => e.validationImg), this.pastBlurValues, {});
11248
11248
  if (!isValidationOk) {
11249
+ const msg = Array.isArray(response) ? response.join(", ") : String(response || "");
11250
+ if (msg.toLowerCase().includes("token expired/invalid")) {
11251
+ this.stopVideo();
11252
+ this.showMessage("Token expired/invalid. Please provide a new token.", true);
11253
+ this.onExtractedResults({
11254
+ success: false,
11255
+ code: "004",
11256
+ info: "Token expired/invalid."
11257
+ });
11258
+ return;
11259
+ }
11249
11260
  this.candidateImages = [];
11250
11261
  return;
11251
11262
  }
@@ -11293,6 +11304,19 @@ class ExtractorVideo {
11293
11304
  this.hasShownTurnMessage = false;
11294
11305
  this.showMessage("Validation successful", true);
11295
11306
  const [isExtractionOk, extractionData] = await (0,_requests_extraction__WEBPACK_IMPORTED_MODULE_2__["default"])(this.extractionImages["FRONT"], this.extractionImages["BACK"], false);
11307
+ if (!isExtractionOk) {
11308
+ const msg = Array.isArray(extractionData) ? extractionData.join(", ") : String(extractionData || "");
11309
+ if (msg.toLowerCase().includes("token expired/invalid")) {
11310
+ this.stopVideo();
11311
+ this.showMessage("Token expired/invalid. Please provide a new token.", true);
11312
+ this.onExtractedResults({
11313
+ success: false,
11314
+ code: "004",
11315
+ info: "Token expired/invalid."
11316
+ });
11317
+ return;
11318
+ }
11319
+ }
11296
11320
  this.onExtraction(isExtractionOk, extractionData);
11297
11321
  return;
11298
11322
  }
@@ -11303,6 +11327,19 @@ class ExtractorVideo {
11303
11327
  this.showMessage("Extracting data");
11304
11328
  const image = images[imageId].fullImg;
11305
11329
  const [isExtractionOk, extractionData] = await (0,_requests_extraction__WEBPACK_IMPORTED_MODULE_2__["default"])(image, undefined, true);
11330
+ if (!isExtractionOk) {
11331
+ const msg = Array.isArray(extractionData) ? extractionData.join(", ") : String(extractionData || "");
11332
+ if (msg.toLowerCase().includes("token expired/invalid")) {
11333
+ this.stopVideo();
11334
+ this.showMessage("Token expired/invalid. Please provide a new token.", true);
11335
+ this.onExtractedResults({
11336
+ success: false,
11337
+ code: "004",
11338
+ info: "Token expired/invalid."
11339
+ });
11340
+ return;
11341
+ }
11342
+ }
11306
11343
  this.onExtraction(isExtractionOk, extractionData);
11307
11344
  return;
11308
11345
  }
@@ -12038,7 +12075,7 @@ async function callDocumentExtraction(frontImage, backImage, ignoreBackImage) {
12038
12075
  const response = await fetch(`${cfgValues.SCAN_APP_URL}extraction/`, {
12039
12076
  method: "POST",
12040
12077
  headers: {
12041
- Authorization: await serviceConfig.getAccessToken(true),
12078
+ Authorization: await serviceConfig.getAccessToken(false),
12042
12079
  Accept: "application/json",
12043
12080
  "Content-Type": "application/json"
12044
12081
  },
@@ -12065,8 +12102,7 @@ async function callDocumentExtraction(frontImage, backImage, ignoreBackImage) {
12065
12102
  }
12066
12103
  //
12067
12104
  if (response.status === 401 || response.status === 403) {
12068
- errors = ["Token expired/invalid"];
12069
- await serviceConfig.refreshTokens();
12105
+ return [false, ["Token expired/invalid"]];
12070
12106
  } else {
12071
12107
  const data = await response.json();
12072
12108
  errors = data.Errors ?? (data.detail ? [data.detail] : ["Backend error, but no details provided!"]);
@@ -12149,8 +12185,7 @@ async function callDocumentValidation(images, blur_values) {
12149
12185
  }
12150
12186
  //
12151
12187
  if (response.status === 401 || response.status === 403) {
12152
- errors = ["Token expired/invalid"];
12153
- await serviceConfig.refreshTokens();
12188
+ return [false, ["Token expired/invalid"]];
12154
12189
  } else {
12155
12190
  const data = await response.json();
12156
12191
  errors = data.Errors ?? (data.detail ? [data.detail] : ["Backend error, but no details provided!"]);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "scandoc-ai-components",
3
3
  "author": "ScanDoc-AI",
4
- "version": "0.1.3",
4
+ "version": "0.1.4",
5
5
  "private": false,
6
6
  "description": "Pure JavaScript package for integrating ScanDoc-AI services.",
7
7
  "keywords": [