scandoc-ai-components 0.0.86 → 0.0.88
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/dist/index.js +82 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -11160,7 +11160,9 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
11160
11160
|
/* harmony import */ var _config__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../config */ "./src/lib/config.js");
|
|
11161
11161
|
/* harmony import */ var _requests_extraction__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../requests/extraction */ "./src/lib/requests/extraction.js");
|
|
11162
11162
|
/* harmony import */ var _requests_validation__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../requests/validation */ "./src/lib/requests/validation.js");
|
|
11163
|
-
/* harmony import */ var
|
|
11163
|
+
/* harmony import */ var _requests_error_logging__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../requests/error_logging */ "./src/lib/requests/error_logging.js");
|
|
11164
|
+
/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./utils */ "./src/lib/components/utils.js");
|
|
11165
|
+
|
|
11164
11166
|
|
|
11165
11167
|
|
|
11166
11168
|
|
|
@@ -11233,8 +11235,8 @@ class ExtractorVideo {
|
|
|
11233
11235
|
setTimeout(() => this.analyzeVideoStream(), ExtractorVideo.FREQUENCY_MS);
|
|
11234
11236
|
return;
|
|
11235
11237
|
}
|
|
11236
|
-
const fullImage = (0,
|
|
11237
|
-
const validationImage = (0,
|
|
11238
|
+
const fullImage = (0,_utils__WEBPACK_IMPORTED_MODULE_5__.videoImgToBase64)(video, canvas, 1280, 720, false);
|
|
11239
|
+
const validationImage = (0,_utils__WEBPACK_IMPORTED_MODULE_5__.videoImgToBase64)(video, canvas, ExtractorVideo.VALIDATION_IMG_WIDTH, ExtractorVideo.VALIDATION_IMG_HEIGHT, true);
|
|
11238
11240
|
DOCUMENT_DETECTOR.isDocumentPresent(video).then(async isPresent => {
|
|
11239
11241
|
if (!isPresent) return;
|
|
11240
11242
|
this.candidateImages.push({
|
|
@@ -11244,7 +11246,19 @@ class ExtractorVideo {
|
|
|
11244
11246
|
const images = [...this.candidateImages];
|
|
11245
11247
|
if (images.length < ExtractorVideo.VALIDATION_BATCH_SIZE) return;
|
|
11246
11248
|
const [isValidationOk, response] = await (0,_requests_validation__WEBPACK_IMPORTED_MODULE_3__["default"])(images.map(e => e.validationImg), this.pastBlurValues, {});
|
|
11249
|
+
console.log("Validation Response:", response);
|
|
11250
|
+
if (!isValidationOk) {
|
|
11251
|
+
this.candidateImages = [];
|
|
11252
|
+
return;
|
|
11253
|
+
}
|
|
11247
11254
|
if (!isValidationOk) {
|
|
11255
|
+
const isDocUnsupported = response?.InfoCode === "1006";
|
|
11256
|
+
const transactionId = response?.TransactionID;
|
|
11257
|
+
if (isDocUnsupported && transactionId && this.candidateImages.length > 0) {
|
|
11258
|
+
const frontImage = this.candidateImages[this.candidateImages.length - 1].fullImg;
|
|
11259
|
+
await (0,_requests_error_logging__WEBPACK_IMPORTED_MODULE_4__["default"])(frontImage, "", transactionId);
|
|
11260
|
+
this.showMessage("Unsupported document. Logged issue.");
|
|
11261
|
+
}
|
|
11248
11262
|
this.candidateImages = [];
|
|
11249
11263
|
return;
|
|
11250
11264
|
}
|
|
@@ -11851,6 +11865,71 @@ function getScanDocAIConfig() {
|
|
|
11851
11865
|
|
|
11852
11866
|
/***/ }),
|
|
11853
11867
|
|
|
11868
|
+
/***/ "./src/lib/requests/error_logging.js":
|
|
11869
|
+
/*!*******************************************!*\
|
|
11870
|
+
!*** ./src/lib/requests/error_logging.js ***!
|
|
11871
|
+
\*******************************************/
|
|
11872
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
11873
|
+
|
|
11874
|
+
"use strict";
|
|
11875
|
+
__webpack_require__.r(__webpack_exports__);
|
|
11876
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
11877
|
+
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
11878
|
+
/* harmony export */ });
|
|
11879
|
+
/* harmony import */ var _config__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../config */ "./src/lib/config.js");
|
|
11880
|
+
/* harmony import */ var _utility_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../utility/utils */ "./src/lib/utility/utils.js");
|
|
11881
|
+
|
|
11882
|
+
|
|
11883
|
+
async function callErrorLogging(frontImage, backImage, transactionId) {
|
|
11884
|
+
try {
|
|
11885
|
+
const serviceConfig = (0,_config__WEBPACK_IMPORTED_MODULE_0__.getScanDocAIConfig)();
|
|
11886
|
+
const cfgValues = (0,_config__WEBPACK_IMPORTED_MODULE_0__.getScanDocAIConfigValues)();
|
|
11887
|
+
const {
|
|
11888
|
+
os,
|
|
11889
|
+
browser,
|
|
11890
|
+
device
|
|
11891
|
+
} = (0,_utility_utils__WEBPACK_IMPORTED_MODULE_1__.detectEnvironment)();
|
|
11892
|
+
let tryCount = 0;
|
|
11893
|
+
let errors = [];
|
|
11894
|
+
while (tryCount < cfgValues.MAX_REQUEST_TRY) {
|
|
11895
|
+
const response = await fetch(`${cfgValues.SCAN_APP_URL}error_logging/`, {
|
|
11896
|
+
method: "POST",
|
|
11897
|
+
headers: {
|
|
11898
|
+
Authorization: await serviceConfig.getAccessToken(true),
|
|
11899
|
+
Accept: "application/json",
|
|
11900
|
+
"Content-Type": "application/json"
|
|
11901
|
+
},
|
|
11902
|
+
body: JSON.stringify({
|
|
11903
|
+
AcceptTermsAndConditions: true,
|
|
11904
|
+
TransactionID: transactionId,
|
|
11905
|
+
FrontImage: frontImage,
|
|
11906
|
+
BackImage: backImage ?? "",
|
|
11907
|
+
OS: os,
|
|
11908
|
+
Device: device,
|
|
11909
|
+
Browser: browser
|
|
11910
|
+
})
|
|
11911
|
+
});
|
|
11912
|
+
if (response.status === 202) {
|
|
11913
|
+
return [true, null];
|
|
11914
|
+
}
|
|
11915
|
+
if (response.status === 401 || response.status === 403) {
|
|
11916
|
+
errors = ["Unauthorized access"];
|
|
11917
|
+
await serviceConfig.refreshTokens();
|
|
11918
|
+
} else {
|
|
11919
|
+
const data = await response.json();
|
|
11920
|
+
errors = data.Errors ?? (data.detail ? [data.detail] : ["Backend error, but no details provided!"]);
|
|
11921
|
+
}
|
|
11922
|
+
tryCount++;
|
|
11923
|
+
}
|
|
11924
|
+
return [false, errors];
|
|
11925
|
+
} catch (error) {
|
|
11926
|
+
return [false, [error.message]];
|
|
11927
|
+
}
|
|
11928
|
+
}
|
|
11929
|
+
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (callErrorLogging);
|
|
11930
|
+
|
|
11931
|
+
/***/ }),
|
|
11932
|
+
|
|
11854
11933
|
/***/ "./src/lib/requests/extraction.js":
|
|
11855
11934
|
/*!****************************************!*\
|
|
11856
11935
|
!*** ./src/lib/requests/extraction.js ***!
|