@privateid/ultrapass-web-sdk 1.3.0 → 1.3.1-1300478
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 +75 -75
- package/dist/apiUtils.d.ts +46 -46
- package/dist/apiUtils.js +922 -921
- package/dist/apiUtils.js.map +1 -1
- package/dist/application/index.d.ts +7 -7
- package/dist/application/index.js +27 -27
- package/dist/application/modules/core/document/DocumentService.d.ts +22 -22
- package/dist/application/modules/core/document/DocumentService.js +254 -254
- package/dist/application/modules/core/document/document.constants.d.ts +15 -15
- package/dist/application/modules/core/document/document.constants.js +21 -21
- package/dist/application/modules/core/document/document.domain.d.ts +7 -7
- package/dist/application/modules/core/document/document.domain.js +1 -1
- package/dist/application/modules/core/document/document.types.d.ts +17 -17
- package/dist/application/modules/core/document/document.types.js +1 -1
- package/dist/application/modules/core/document/document.utils.d.ts +3 -3
- package/dist/application/modules/core/document/document.utils.js +58 -58
- package/dist/application/modules/core/document/index.d.ts +3 -3
- package/dist/application/modules/core/document/index.js +1 -1
- package/dist/application/modules/core/face/FaceService.d.ts +33 -33
- package/dist/application/modules/core/face/FaceService.js +228 -221
- package/dist/application/modules/core/face/FaceService.js.map +1 -1
- package/dist/application/modules/core/face/face.constants.d.ts +53 -53
- package/dist/application/modules/core/face/face.constants.js +53 -53
- package/dist/application/modules/core/face/face.domain.d.ts +10 -10
- package/dist/application/modules/core/face/face.domain.js +1 -1
- package/dist/application/modules/core/face/face.types.d.ts +41 -38
- package/dist/application/modules/core/face/face.types.js +1 -1
- package/dist/application/modules/core/face/face.utils.d.ts +15 -15
- package/dist/application/modules/core/face/face.utils.js +101 -101
- package/dist/application/modules/core/face/index.d.ts +3 -3
- package/dist/application/modules/core/face/index.js +1 -1
- package/dist/application/modules/global/shared.constants.d.ts +2 -2
- package/dist/application/modules/global/shared.constants.js +2 -2
- package/dist/application/modules/global/shared.utils.d.ts +25 -25
- package/dist/application/modules/global/shared.utils.js +100 -100
- package/dist/application/modules/global/shared.utils.js.map +1 -1
- package/dist/application/modules/internal/feature-flag/LDFeatureFlagService.d.ts +9 -0
- package/dist/application/modules/internal/feature-flag/LDFeatureFlagService.js +32 -0
- package/dist/application/modules/internal/feature-flag/LDFeatureFlagService.js.map +1 -0
- package/dist/application/modules/internal/feature-flag/feature-flag-init.d.ts +11 -0
- package/dist/application/modules/internal/feature-flag/feature-flag-init.js +24 -0
- package/dist/application/modules/internal/feature-flag/feature-flag-init.js.map +1 -0
- package/dist/application/modules/internal/feature-flag/feature-flag.domain.d.ts +10 -0
- package/dist/application/modules/internal/feature-flag/feature-flag.domain.js +7 -0
- package/dist/application/modules/internal/feature-flag/feature-flag.domain.js.map +1 -0
- package/dist/application/modules/internal/feature-flag/featureFlagInit.d.ts +11 -0
- package/dist/application/modules/internal/feature-flag/featureFlagInit.js +44 -0
- package/dist/application/modules/internal/feature-flag/featureFlagInit.js.map +1 -0
- package/dist/application/modules/internal/feature-flag/index.d.ts +2 -0
- package/dist/application/modules/internal/feature-flag/index.js +3 -0
- package/dist/application/modules/internal/feature-flag/index.js.map +1 -0
- package/dist/application/modules/internal/shared/index.d.ts +2 -0
- package/dist/application/modules/internal/shared/index.js +3 -0
- package/dist/application/modules/internal/shared/index.js.map +1 -0
- package/dist/application/modules/internal/shared/shared.constants.d.ts +2 -0
- package/dist/application/modules/internal/shared/shared.constants.js +3 -0
- package/dist/application/modules/internal/shared/shared.constants.js.map +1 -0
- package/dist/application/modules/internal/shared/shared.utils.d.ts +44 -0
- package/dist/application/modules/internal/shared/shared.utils.js +204 -0
- package/dist/application/modules/internal/shared/shared.utils.js.map +1 -0
- package/dist/application/modules/internal/wasm-orchestrator/WasmOrchestratorService.d.ts +28 -0
- package/dist/application/modules/internal/wasm-orchestrator/WasmOrchestratorService.js +380 -0
- package/dist/application/modules/internal/wasm-orchestrator/WasmOrchestratorService.js.map +1 -0
- package/dist/application/modules/internal/wasm-orchestrator/index.d.ts +6 -0
- package/dist/application/modules/internal/wasm-orchestrator/index.js +9 -0
- package/dist/application/modules/internal/wasm-orchestrator/index.js.map +1 -0
- package/dist/application/modules/internal/wasm-orchestrator/wasm-orchestrator.constants.d.ts +28 -0
- package/dist/application/modules/internal/wasm-orchestrator/wasm-orchestrator.constants.js +35 -0
- package/dist/application/modules/internal/wasm-orchestrator/wasm-orchestrator.constants.js.map +1 -0
- package/dist/application/modules/internal/wasm-orchestrator/wasm-orchestrator.domain.d.ts +51 -0
- package/dist/application/modules/internal/wasm-orchestrator/wasm-orchestrator.domain.js +2 -0
- package/dist/application/modules/internal/wasm-orchestrator/wasm-orchestrator.domain.js.map +1 -0
- package/dist/application/modules/internal/wasm-orchestrator/wasm-orchestrator.types.d.ts +142 -0
- package/dist/application/modules/internal/wasm-orchestrator/wasm-orchestrator.types.js +2 -0
- package/dist/application/modules/internal/wasm-orchestrator/wasm-orchestrator.types.js.map +1 -0
- package/dist/application/modules/internal/wasm-orchestrator/wasm-orchestrator.utils.d.ts +86 -0
- package/dist/application/modules/internal/wasm-orchestrator/wasm-orchestrator.utils.js +201 -0
- package/dist/application/modules/internal/wasm-orchestrator/wasm-orchestrator.utils.js.map +1 -0
- package/dist/application/modules/support/camera/CameraServiceFactory.d.ts +10 -10
- package/dist/application/modules/support/camera/CameraServiceFactory.js +33 -33
- package/dist/application/modules/support/camera/CameraServiceFactory.js.map +1 -1
- package/dist/application/modules/support/camera/camera.constants.d.ts +9 -9
- package/dist/application/modules/support/camera/camera.constants.js +48 -48
- package/dist/application/modules/support/camera/camera.domain.d.ts +15 -15
- package/dist/application/modules/support/camera/camera.domain.js +1 -1
- package/dist/application/modules/support/camera/camera.types.d.ts +42 -42
- package/dist/application/modules/support/camera/camera.types.js +10 -10
- package/dist/application/modules/support/camera/camera.utils.d.ts +157 -157
- package/dist/application/modules/support/camera/camera.utils.js +623 -618
- package/dist/application/modules/support/camera/camera.utils.js.map +1 -1
- package/dist/application/modules/support/camera/index.d.ts +24 -24
- package/dist/application/modules/support/camera/index.js +27 -27
- package/dist/application/modules/support/camera/services/BaseCameraService.d.ts +41 -41
- package/dist/application/modules/support/camera/services/BaseCameraService.js +278 -278
- package/dist/application/modules/support/camera/services/DesktopCameraService.d.ts +5 -5
- package/dist/application/modules/support/camera/services/DesktopCameraService.js +46 -46
- package/dist/application/modules/support/camera/services/DesktopCameraService.js.map +1 -1
- package/dist/application/modules/support/camera/services/FirefoxCameraService.d.ts +5 -5
- package/dist/application/modules/support/camera/services/FirefoxCameraService.js +46 -46
- package/dist/application/modules/support/camera/services/FirefoxCameraService.js.map +1 -1
- package/dist/application/modules/support/camera/services/MacSafariCameraService.d.ts +5 -5
- package/dist/application/modules/support/camera/services/MacSafariCameraService.js +47 -47
- package/dist/application/modules/support/camera/services/MacSafariCameraService.js.map +1 -1
- package/dist/application/modules/support/camera/services/MobileCameraService.d.ts +5 -5
- package/dist/application/modules/support/camera/services/MobileCameraService.js +133 -131
- package/dist/application/modules/support/camera/services/MobileCameraService.js.map +1 -1
- package/dist/application/modules/support/engine/EngineService.d.ts +15 -0
- package/dist/application/modules/support/engine/EngineService.js +106 -0
- package/dist/application/modules/support/engine/EngineService.js.map +1 -0
- package/dist/application/modules/support/engine/engine.constants.d.ts +33 -0
- package/dist/application/modules/support/engine/engine.constants.js +35 -0
- package/dist/application/modules/support/engine/engine.constants.js.map +1 -0
- package/dist/application/modules/support/engine/engine.domain.d.ts +23 -0
- package/dist/application/modules/support/engine/engine.domain.js +2 -0
- package/dist/application/modules/support/engine/engine.domain.js.map +1 -0
- package/dist/application/modules/support/engine/engine.types.d.ts +32 -0
- package/dist/application/modules/support/engine/engine.types.js +2 -0
- package/dist/application/modules/support/engine/engine.types.js.map +1 -0
- package/dist/application/modules/support/engine/engine.utils.d.ts +65 -0
- package/dist/application/modules/support/engine/engine.utils.js +135 -0
- package/dist/application/modules/support/engine/engine.utils.js.map +1 -0
- package/dist/application/modules/support/engine/index.d.ts +3 -0
- package/dist/application/modules/support/engine/index.js +2 -0
- package/dist/application/modules/support/engine/index.js.map +1 -0
- package/dist/application/modules/support/permissions/PermissionsService.d.ts +55 -43
- package/dist/application/modules/support/permissions/PermissionsService.js +183 -178
- package/dist/application/modules/support/permissions/PermissionsService.js.map +1 -1
- package/dist/application/modules/support/permissions/index.d.ts +4 -4
- package/dist/application/modules/support/permissions/index.js +2 -2
- package/dist/application/modules/support/permissions/permission.utils.d.ts +6 -6
- package/dist/application/modules/support/permissions/permission.utils.js +33 -33
- package/dist/application/modules/support/permissions/permissions.domain.d.ts +6 -6
- package/dist/application/modules/support/permissions/permissions.domain.js +1 -1
- package/dist/application/modules/support/permissions/permissions.types.d.ts +9 -9
- package/dist/application/modules/support/permissions/permissions.types.js +1 -1
- package/dist/application/modules/support/wasm/WasmService.d.ts +25 -25
- package/dist/application/modules/support/wasm/WasmService.js +156 -155
- package/dist/application/modules/support/wasm/WasmService.js.map +1 -1
- package/dist/application/modules/support/wasm/index.d.ts +6 -6
- package/dist/application/modules/support/wasm/index.js +8 -8
- package/dist/application/modules/support/wasm/wasm.constants.d.ts +78 -78
- package/dist/application/modules/support/wasm/wasm.constants.js +86 -86
- package/dist/application/modules/support/wasm/wasm.domain.d.ts +52 -52
- package/dist/application/modules/support/wasm/wasm.domain.js +1 -1
- package/dist/application/modules/support/wasm/wasm.types.d.ts +119 -118
- package/dist/application/modules/support/wasm/wasm.types.js +1 -1
- package/dist/application/modules/support/wasm/wasm.utils.d.ts +88 -88
- package/dist/application/modules/support/wasm/wasm.utils.js +243 -243
- package/dist/application/modules/support/wasm-orchestrator/WasmOrchestratorService.d.ts +28 -0
- package/dist/application/modules/support/wasm-orchestrator/WasmOrchestratorService.js +324 -0
- package/dist/application/modules/support/wasm-orchestrator/WasmOrchestratorService.js.map +1 -0
- package/dist/application/modules/support/wasm-orchestrator/index.d.ts +6 -0
- package/dist/application/modules/support/wasm-orchestrator/index.js +9 -0
- package/dist/application/modules/support/wasm-orchestrator/index.js.map +1 -0
- package/dist/application/modules/support/wasm-orchestrator/wasm-orchestrator.constants.d.ts +36 -0
- package/dist/application/modules/support/wasm-orchestrator/wasm-orchestrator.constants.js +44 -0
- package/dist/application/modules/support/wasm-orchestrator/wasm-orchestrator.constants.js.map +1 -0
- package/dist/application/modules/support/wasm-orchestrator/wasm-orchestrator.domain.d.ts +47 -0
- package/dist/application/modules/support/wasm-orchestrator/wasm-orchestrator.domain.js +2 -0
- package/dist/application/modules/support/wasm-orchestrator/wasm-orchestrator.domain.js.map +1 -0
- package/dist/application/modules/support/wasm-orchestrator/wasm-orchestrator.types.d.ts +136 -0
- package/dist/application/modules/support/wasm-orchestrator/wasm-orchestrator.types.js +2 -0
- package/dist/application/modules/support/wasm-orchestrator/wasm-orchestrator.types.js.map +1 -0
- package/dist/application/modules/support/wasm-orchestrator/wasm-orchestrator.utils.d.ts +91 -0
- package/dist/application/modules/support/wasm-orchestrator/wasm-orchestrator.utils.js +250 -0
- package/dist/application/modules/support/wasm-orchestrator/wasm-orchestrator.utils.js.map +1 -0
- package/dist/application/workers/index.d.ts +42 -42
- package/dist/application/workers/index.js +8 -8
- package/dist/application/workers/wasm/WasmWorkerService.d.ts +66 -0
- package/dist/application/workers/wasm/WasmWorkerService.js +801 -0
- package/dist/application/workers/wasm/WasmWorkerService.js.map +1 -0
- package/dist/application/workers/wasm/index.d.ts +4 -0
- package/dist/application/workers/wasm/index.js +9 -0
- package/dist/application/workers/wasm/index.js.map +1 -0
- package/dist/application/workers/wasm/wasm-worker.constants.d.ts +5 -0
- package/dist/application/workers/wasm/wasm-worker.constants.js +6 -0
- package/dist/application/workers/wasm/wasm-worker.constants.js.map +1 -0
- package/dist/application/workers/wasm/wasm-worker.domain.d.ts +99 -0
- package/dist/application/workers/wasm/wasm-worker.domain.js +2 -0
- package/dist/application/workers/wasm/wasm-worker.domain.js.map +1 -0
- package/dist/application/workers/wasm/wasm-worker.types.d.ts +88 -0
- package/dist/application/workers/wasm/wasm-worker.types.js +2 -0
- package/dist/application/workers/wasm/wasm-worker.types.js.map +1 -0
- package/dist/application/workers/wasm/wasm-worker.utils.d.ts +10 -0
- package/dist/application/workers/wasm/wasm-worker.utils.js +130 -0
- package/dist/application/workers/wasm/wasm-worker.utils.js.map +1 -0
- package/dist/buildConfig.d.ts +3 -0
- package/dist/buildConfig.js +7 -0
- package/dist/buildConfig.js.map +1 -0
- package/dist/cameraUtils.d.ts +77 -77
- package/dist/cameraUtils.js +361 -360
- package/dist/cameraUtils.js.map +1 -1
- package/dist/constants.d.ts +9 -9
- package/dist/constants.js +13 -12
- package/dist/constants.js.map +1 -1
- package/dist/createCallback.d.ts +56 -56
- package/dist/createCallback.js +332 -330
- package/dist/createCallback.js.map +1 -1
- package/dist/dbUtils.d.ts +14 -14
- package/dist/dbUtils.js +148 -147
- package/dist/dbUtils.js.map +1 -1
- package/dist/envUtils.d.ts +4 -4
- package/dist/envUtils.js +16 -15
- package/dist/envUtils.js.map +1 -1
- package/dist/faceModule.d.ts +196 -196
- package/dist/faceModule.js +978 -981
- package/dist/faceModule.js.map +1 -1
- package/dist/featureFlagInit.d.ts +11 -0
- package/dist/featureFlagInit.js +44 -0
- package/dist/featureFlagInit.js.map +1 -0
- package/dist/index.d.ts +38 -38
- package/dist/index.js +82 -82
- package/dist/main.d.ts +30 -24
- package/dist/main.js +84 -69
- package/dist/main.js.map +1 -1
- package/dist/types.d.ts +139 -139
- package/dist/types.js +77 -77
- package/dist/utils.d.ts +84 -84
- package/dist/utils.js +580 -579
- package/dist/utils.js.map +1 -1
- package/package.json +102 -102
- package/wasm/ultra/nosimd/{25.11.13-1357710 → 26.01.08-1300478}/privid_fhe_uber.js +18 -18
- package/wasm/ultra/nosimd/{25.11.13-1357710 → 26.01.08-1300478}/privid_fhe_uber.wasm +0 -0
- package/wasm/ultra/nosimd/version.json +2 -2
- package/wasm/ultra/simd/{25.11.13-1357710 → 26.01.08-1300478}/privid_fhe_uber.js +18 -18
- package/wasm/ultra/simd/{25.11.13-1357710 → 26.01.08-1300478}/privid_fhe_uber.wasm +0 -0
- package/wasm/ultra/simd/version.json +2 -2
- package/workers/comlink.min.js +7 -7
- package/workers/comlink.min.js.map +1 -1
- package/workers/wasm.worker.js +936 -924
|
@@ -1,255 +1,255 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
/* eslint-disable lines-between-class-members */
|
|
11
|
-
/* eslint-disable import/prefer-default-export */
|
|
12
|
-
import { detect } from 'detect-browser';
|
|
13
|
-
import { proxy } from 'comlink';
|
|
14
|
-
import { callbackTypeEnum, createCallback } from '../../../../createCallback';
|
|
15
|
-
import { ImageType } from '../../../../types';
|
|
16
|
-
import { getDebugType, getIsSIMD, printLogs, iOS } from '../../global/shared.utils';
|
|
17
|
-
import { imageDataFromBase64, releaseCanvas } from './document.utils';
|
|
18
|
-
import { DEBUG_TYPES_WITH_IMAGES, INPUT_IMAGE_FORMAT, FINGERS_OVER_DOCUMENT_THRESHOLD, DOCUMENT_THRESHOLD_X, DOCUMENT_THRESHOLD_Y, DOCUMENT_TOO_CLOSE_THRESHOLD, DOCUMENT_TOO_FAR_THRESHOLD, CALCULATE_AGE_FROM_OCR_TEXT, ERROR_RESULT, ERROR_CODE, IMAGE_EXPORT_FORMAT, DOWNLOAD_IMAGE_TYPE, FILE_EXTENSION, DOWNLOAD_DELAY_TIMEOUT, } from './document.constants';
|
|
19
|
-
import { CANVAS_ID, INVALID_VIDEO_ERROR } from '../../global/shared.constants';
|
|
20
|
-
export class DocumentService {
|
|
21
|
-
constructor(wasmService, cameraService) {
|
|
22
|
-
// TODO: Remove isSimd from here, it should belong to WasmService.
|
|
23
|
-
this.isSimd = false;
|
|
24
|
-
this.hasDebugWithImages = false;
|
|
25
|
-
getIsSIMD().then((simd) => (this.isSimd = simd));
|
|
26
|
-
const canvas = document.createElement('canvas');
|
|
27
|
-
canvas.setAttribute('id', CANVAS_ID);
|
|
28
|
-
const debugCanvas = document.createElement('canvas');
|
|
29
|
-
const debugType = getDebugType();
|
|
30
|
-
this.hasDebugWithImages = DEBUG_TYPES_WITH_IMAGES.includes(debugType);
|
|
31
|
-
this.canvas = canvas;
|
|
32
|
-
this.debugCanvas = debugCanvas;
|
|
33
|
-
this.wasmService = wasmService;
|
|
34
|
-
this.cameraService = cameraService;
|
|
35
|
-
}
|
|
36
|
-
scanGovernmentPhotoId(params) {
|
|
37
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
-
printLogs('[DocumentService] scanGovernmentPhotoId params', params);
|
|
39
|
-
try {
|
|
40
|
-
let configuration = {
|
|
41
|
-
input_image_format: INPUT_IMAGE_FORMAT,
|
|
42
|
-
fingers_over_document_threshold: FINGERS_OVER_DOCUMENT_THRESHOLD,
|
|
43
|
-
};
|
|
44
|
-
if (params.config) {
|
|
45
|
-
configuration = Object.assign(Object.assign({}, configuration), params.config);
|
|
46
|
-
}
|
|
47
|
-
const callback = createCallback({
|
|
48
|
-
type: callbackTypeEnum.frontScan,
|
|
49
|
-
callbackFunction: params.callback,
|
|
50
|
-
});
|
|
51
|
-
const workerCallback = proxy(callback);
|
|
52
|
-
const imageData = this.generateImageData();
|
|
53
|
-
if (this.hasDebugWithImages) {
|
|
54
|
-
yield this.generateDebugImages([imageData], `${ImageType.original}_front_gov_photo_id_document_scan`, 'enroll');
|
|
55
|
-
}
|
|
56
|
-
yield this.wasmService.scanFrontPhotoIdDocument(imageData, JSON.stringify(configuration), workerCallback);
|
|
57
|
-
return {
|
|
58
|
-
success: true,
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
catch (error) {
|
|
62
|
-
printLogs(`[DocumentService] scanGovernmentPhotoId error: `, error.message, 'ERROR');
|
|
63
|
-
return {
|
|
64
|
-
success: false,
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
scanPassport(params) {
|
|
70
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
71
|
-
printLogs('[DocumentService] scanPassport params', params);
|
|
72
|
-
try {
|
|
73
|
-
let configuration = {
|
|
74
|
-
input_image_format: INPUT_IMAGE_FORMAT,
|
|
75
|
-
};
|
|
76
|
-
if (params.config) {
|
|
77
|
-
configuration = Object.assign(Object.assign({}, configuration), params.config);
|
|
78
|
-
}
|
|
79
|
-
const callback = createCallback({
|
|
80
|
-
type: callbackTypeEnum.passportScan,
|
|
81
|
-
callbackFunction: params.callback,
|
|
82
|
-
});
|
|
83
|
-
const workerCallback = proxy(callback);
|
|
84
|
-
const imageData = this.generateImageData();
|
|
85
|
-
if (this.hasDebugWithImages) {
|
|
86
|
-
yield this.generateDebugImages([imageData], `${ImageType.original}_passport_scan`, 'enroll');
|
|
87
|
-
}
|
|
88
|
-
yield this.wasmService.scanPassport(imageData, JSON.stringify(configuration), workerCallback);
|
|
89
|
-
return {
|
|
90
|
-
success: true,
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
catch (error) {
|
|
94
|
-
printLogs(`[DocumentService] scanPassport error: `, error, 'ERROR');
|
|
95
|
-
return {
|
|
96
|
-
success: false,
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
scanBackDocument(params) {
|
|
102
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
103
|
-
const { callback, image, config } = params;
|
|
104
|
-
printLogs('________________ DOCUMENT SCAN ______________', '');
|
|
105
|
-
const videoEl = this.getVideoElement();
|
|
106
|
-
let configuration = {
|
|
107
|
-
input_image_format: INPUT_IMAGE_FORMAT,
|
|
108
|
-
};
|
|
109
|
-
if (config) {
|
|
110
|
-
configuration = Object.assign(Object.assign({}, configuration), config);
|
|
111
|
-
}
|
|
112
|
-
const { os } = detect();
|
|
113
|
-
if (iOS() || ['iOS', 'android', 'Android OS'].includes(os)) {
|
|
114
|
-
this.privid_wasm_result = createCallback({
|
|
115
|
-
type: callbackTypeEnum.backScan,
|
|
116
|
-
callbackFunction: callback,
|
|
117
|
-
isMobile: true,
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
else if (configuration === null || configuration === void 0 ? void 0 : configuration.document_scan_barcode_only) {
|
|
121
|
-
this.privid_wasm_result = createCallback({
|
|
122
|
-
type: callbackTypeEnum.backScan,
|
|
123
|
-
callbackFunction: callback,
|
|
124
|
-
isMobile: true,
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
else if (configuration === null || configuration === void 0 ? void 0 : configuration.detect_barcode_without_parsing) {
|
|
128
|
-
this.privid_wasm_result = createCallback({
|
|
129
|
-
type: callbackTypeEnum.backScan,
|
|
130
|
-
callbackFunction: callback,
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
else {
|
|
134
|
-
configuration = Object.assign(Object.assign({}, configuration), { detect_document_only: true });
|
|
135
|
-
this.privid_wasm_result = createCallback({ type: callbackTypeEnum.backScan, callbackFunction: callback });
|
|
136
|
-
}
|
|
137
|
-
configuration = JSON.stringify(configuration);
|
|
138
|
-
if (!videoEl) {
|
|
139
|
-
printLogs(`Capture need the video element id`, '', 'ERROR');
|
|
140
|
-
return { result: ERROR_RESULT };
|
|
141
|
-
}
|
|
142
|
-
const imageData = this.generateImageData();
|
|
143
|
-
if ((imageData === null || imageData === void 0 ? void 0 : imageData.width) === 0)
|
|
144
|
-
return { result: ERROR_RESULT };
|
|
145
|
-
let result = null;
|
|
146
|
-
if (this.hasDebugWithImages) {
|
|
147
|
-
yield this.generateDebugImages([imageData], ImageType.original, 'enroll');
|
|
148
|
-
}
|
|
149
|
-
try {
|
|
150
|
-
printLogs(`Configuration: back scan: `, configuration);
|
|
151
|
-
result = yield this.wasmService.scanBackDocument(imageData, this.isSimd, configuration, proxy(this.privid_wasm_result));
|
|
152
|
-
// TODO: Validate if we need to release, and when, since we will have only one instance of canvas
|
|
153
|
-
releaseCanvas(this.canvas);
|
|
154
|
-
return Object.assign({}, result);
|
|
155
|
-
}
|
|
156
|
-
catch (e) {
|
|
157
|
-
printLogs(`isValidPhotoID error: `, e, 'ERROR');
|
|
158
|
-
return {
|
|
159
|
-
result: ERROR_CODE,
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
documentOcr(params) {
|
|
165
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
166
|
-
printLogs('________________ DOCUMENT OCR ______________', '');
|
|
167
|
-
let configuration = {
|
|
168
|
-
input_image_format: INPUT_IMAGE_FORMAT,
|
|
169
|
-
calculate_age_from_ocr_text: CALCULATE_AGE_FROM_OCR_TEXT,
|
|
170
|
-
threshold_doc_x: DOCUMENT_THRESHOLD_X,
|
|
171
|
-
threshold_doc_y: DOCUMENT_THRESHOLD_Y,
|
|
172
|
-
threshold_doc_too_close: DOCUMENT_TOO_CLOSE_THRESHOLD,
|
|
173
|
-
threshold_doc_too_far: DOCUMENT_TOO_FAR_THRESHOLD,
|
|
174
|
-
};
|
|
175
|
-
if (params.config) {
|
|
176
|
-
configuration = Object.assign(Object.assign({}, configuration), params.config);
|
|
177
|
-
}
|
|
178
|
-
this.privid_wasm_result = createCallback({ type: callbackTypeEnum.documentOcr, callbackFunction: params.callback });
|
|
179
|
-
const cb = proxy(this.privid_wasm_result);
|
|
180
|
-
if (this.hasDebugWithImages) {
|
|
181
|
-
const imageData = yield imageDataFromBase64(params.inputImage);
|
|
182
|
-
yield this.generateDebugImages([imageData], `${ImageType.original}_document_ocr`, 'enroll');
|
|
183
|
-
}
|
|
184
|
-
try {
|
|
185
|
-
configuration = JSON.stringify(configuration);
|
|
186
|
-
return yield this.wasmService.documentOcr(params.inputImage, configuration, cb);
|
|
187
|
-
}
|
|
188
|
-
catch (e) {
|
|
189
|
-
printLogs(`isValidPhotoID error: `, e, 'ERROR');
|
|
190
|
-
return {
|
|
191
|
-
result: ERROR_CODE,
|
|
192
|
-
};
|
|
193
|
-
}
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
getVideoElement() {
|
|
197
|
-
return this.cameraService.getVideoElementDOM();
|
|
198
|
-
}
|
|
199
|
-
generateDebugImages(images, title, action) {
|
|
200
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
201
|
-
const a = document.createElement('a');
|
|
202
|
-
a.type = DOWNLOAD_IMAGE_TYPE;
|
|
203
|
-
document.body.appendChild(a);
|
|
204
|
-
for (const imageContent of images) {
|
|
205
|
-
this.debugCanvas.width = imageContent.width;
|
|
206
|
-
this.debugCanvas.height = imageContent.height;
|
|
207
|
-
const ctx = this.debugCanvas.getContext('2d');
|
|
208
|
-
ctx.putImageData(imageContent, 0, 0);
|
|
209
|
-
const blob = yield new Promise((resolve) => this.debugCanvas.toBlob((b) => resolve(b), IMAGE_EXPORT_FORMAT));
|
|
210
|
-
if (blob) {
|
|
211
|
-
const url = URL.createObjectURL(blob);
|
|
212
|
-
try {
|
|
213
|
-
a.href = url;
|
|
214
|
-
a.download = `${title}_${action}${FILE_EXTENSION}`;
|
|
215
|
-
a.click();
|
|
216
|
-
yield new Promise((r) => setTimeout(r, DOWNLOAD_DELAY_TIMEOUT));
|
|
217
|
-
}
|
|
218
|
-
catch (error) {
|
|
219
|
-
printLogs('[DocumentService] generateDebugImages error', error, 'ERROR');
|
|
220
|
-
}
|
|
221
|
-
finally {
|
|
222
|
-
URL.revokeObjectURL(url);
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
a.remove();
|
|
227
|
-
});
|
|
228
|
-
}
|
|
229
|
-
// TODO: Both DocumentService and FaceService uses generateImageData and prepareCanvas
|
|
230
|
-
// but in different ways, should we create an interface to secure these implementations?
|
|
231
|
-
// Or should we bring that to a different Class called CanvasService?
|
|
232
|
-
generateImageData() {
|
|
233
|
-
var _a;
|
|
234
|
-
const videoElement = this.cameraService.getVideoElementDOM();
|
|
235
|
-
printLogs('[DocumentService] generateImageData videoElement', videoElement);
|
|
236
|
-
const canvas = this.prepareCanvas(videoElement);
|
|
237
|
-
const context = this.canvas.getContext('2d', { willReadFrequently: true });
|
|
238
|
-
(_a = context.resetTransform) === null || _a === void 0 ? void 0 : _a.call(context);
|
|
239
|
-
context.clearRect(0, 0, canvas.width, canvas.height);
|
|
240
|
-
context.drawImage(videoElement, 0, 0, canvas.width, canvas.height);
|
|
241
|
-
return context.getImageData(0, 0, canvas.width, canvas.height);
|
|
242
|
-
}
|
|
243
|
-
prepareCanvas(videoElement) {
|
|
244
|
-
const height = videoElement.videoHeight || 0;
|
|
245
|
-
const width = videoElement.videoWidth || 0;
|
|
246
|
-
if (width === 0) {
|
|
247
|
-
throw new Error(INVALID_VIDEO_ERROR);
|
|
248
|
-
}
|
|
249
|
-
this.canvas.setAttribute('height', `${height}`);
|
|
250
|
-
this.canvas.setAttribute('width', `${width}`);
|
|
251
|
-
this.canvas.setAttribute('id', CANVAS_ID);
|
|
252
|
-
return this.canvas;
|
|
253
|
-
}
|
|
254
|
-
}
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
/* eslint-disable lines-between-class-members */
|
|
11
|
+
/* eslint-disable import/prefer-default-export */
|
|
12
|
+
import { detect } from 'detect-browser';
|
|
13
|
+
import { proxy } from 'comlink';
|
|
14
|
+
import { callbackTypeEnum, createCallback } from '../../../../createCallback';
|
|
15
|
+
import { ImageType } from '../../../../types';
|
|
16
|
+
import { getDebugType, getIsSIMD, printLogs, iOS } from '../../global/shared.utils';
|
|
17
|
+
import { imageDataFromBase64, releaseCanvas } from './document.utils';
|
|
18
|
+
import { DEBUG_TYPES_WITH_IMAGES, INPUT_IMAGE_FORMAT, FINGERS_OVER_DOCUMENT_THRESHOLD, DOCUMENT_THRESHOLD_X, DOCUMENT_THRESHOLD_Y, DOCUMENT_TOO_CLOSE_THRESHOLD, DOCUMENT_TOO_FAR_THRESHOLD, CALCULATE_AGE_FROM_OCR_TEXT, ERROR_RESULT, ERROR_CODE, IMAGE_EXPORT_FORMAT, DOWNLOAD_IMAGE_TYPE, FILE_EXTENSION, DOWNLOAD_DELAY_TIMEOUT, } from './document.constants';
|
|
19
|
+
import { CANVAS_ID, INVALID_VIDEO_ERROR } from '../../global/shared.constants';
|
|
20
|
+
export class DocumentService {
|
|
21
|
+
constructor(wasmService, cameraService) {
|
|
22
|
+
// TODO: Remove isSimd from here, it should belong to WasmService.
|
|
23
|
+
this.isSimd = false;
|
|
24
|
+
this.hasDebugWithImages = false;
|
|
25
|
+
getIsSIMD().then((simd) => (this.isSimd = simd));
|
|
26
|
+
const canvas = document.createElement('canvas');
|
|
27
|
+
canvas.setAttribute('id', CANVAS_ID);
|
|
28
|
+
const debugCanvas = document.createElement('canvas');
|
|
29
|
+
const debugType = getDebugType();
|
|
30
|
+
this.hasDebugWithImages = DEBUG_TYPES_WITH_IMAGES.includes(debugType);
|
|
31
|
+
this.canvas = canvas;
|
|
32
|
+
this.debugCanvas = debugCanvas;
|
|
33
|
+
this.wasmService = wasmService;
|
|
34
|
+
this.cameraService = cameraService;
|
|
35
|
+
}
|
|
36
|
+
scanGovernmentPhotoId(params) {
|
|
37
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
+
printLogs('[DocumentService] scanGovernmentPhotoId params', params);
|
|
39
|
+
try {
|
|
40
|
+
let configuration = {
|
|
41
|
+
input_image_format: INPUT_IMAGE_FORMAT,
|
|
42
|
+
fingers_over_document_threshold: FINGERS_OVER_DOCUMENT_THRESHOLD,
|
|
43
|
+
};
|
|
44
|
+
if (params.config) {
|
|
45
|
+
configuration = Object.assign(Object.assign({}, configuration), params.config);
|
|
46
|
+
}
|
|
47
|
+
const callback = createCallback({
|
|
48
|
+
type: callbackTypeEnum.frontScan,
|
|
49
|
+
callbackFunction: params.callback,
|
|
50
|
+
});
|
|
51
|
+
const workerCallback = proxy(callback);
|
|
52
|
+
const imageData = this.generateImageData();
|
|
53
|
+
if (this.hasDebugWithImages) {
|
|
54
|
+
yield this.generateDebugImages([imageData], `${ImageType.original}_front_gov_photo_id_document_scan`, 'enroll');
|
|
55
|
+
}
|
|
56
|
+
yield this.wasmService.scanFrontPhotoIdDocument(imageData, JSON.stringify(configuration), workerCallback);
|
|
57
|
+
return {
|
|
58
|
+
success: true,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
printLogs(`[DocumentService] scanGovernmentPhotoId error: `, error.message, 'ERROR');
|
|
63
|
+
return {
|
|
64
|
+
success: false,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
scanPassport(params) {
|
|
70
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
71
|
+
printLogs('[DocumentService] scanPassport params', params);
|
|
72
|
+
try {
|
|
73
|
+
let configuration = {
|
|
74
|
+
input_image_format: INPUT_IMAGE_FORMAT,
|
|
75
|
+
};
|
|
76
|
+
if (params.config) {
|
|
77
|
+
configuration = Object.assign(Object.assign({}, configuration), params.config);
|
|
78
|
+
}
|
|
79
|
+
const callback = createCallback({
|
|
80
|
+
type: callbackTypeEnum.passportScan,
|
|
81
|
+
callbackFunction: params.callback,
|
|
82
|
+
});
|
|
83
|
+
const workerCallback = proxy(callback);
|
|
84
|
+
const imageData = this.generateImageData();
|
|
85
|
+
if (this.hasDebugWithImages) {
|
|
86
|
+
yield this.generateDebugImages([imageData], `${ImageType.original}_passport_scan`, 'enroll');
|
|
87
|
+
}
|
|
88
|
+
yield this.wasmService.scanPassport(imageData, JSON.stringify(configuration), workerCallback);
|
|
89
|
+
return {
|
|
90
|
+
success: true,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
printLogs(`[DocumentService] scanPassport error: `, error, 'ERROR');
|
|
95
|
+
return {
|
|
96
|
+
success: false,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
scanBackDocument(params) {
|
|
102
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
103
|
+
const { callback, image, config } = params;
|
|
104
|
+
printLogs('________________ DOCUMENT SCAN ______________', '');
|
|
105
|
+
const videoEl = this.getVideoElement();
|
|
106
|
+
let configuration = {
|
|
107
|
+
input_image_format: INPUT_IMAGE_FORMAT,
|
|
108
|
+
};
|
|
109
|
+
if (config) {
|
|
110
|
+
configuration = Object.assign(Object.assign({}, configuration), config);
|
|
111
|
+
}
|
|
112
|
+
const { os } = detect();
|
|
113
|
+
if (iOS() || ['iOS', 'android', 'Android OS'].includes(os)) {
|
|
114
|
+
this.privid_wasm_result = createCallback({
|
|
115
|
+
type: callbackTypeEnum.backScan,
|
|
116
|
+
callbackFunction: callback,
|
|
117
|
+
isMobile: true,
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
else if (configuration === null || configuration === void 0 ? void 0 : configuration.document_scan_barcode_only) {
|
|
121
|
+
this.privid_wasm_result = createCallback({
|
|
122
|
+
type: callbackTypeEnum.backScan,
|
|
123
|
+
callbackFunction: callback,
|
|
124
|
+
isMobile: true,
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
else if (configuration === null || configuration === void 0 ? void 0 : configuration.detect_barcode_without_parsing) {
|
|
128
|
+
this.privid_wasm_result = createCallback({
|
|
129
|
+
type: callbackTypeEnum.backScan,
|
|
130
|
+
callbackFunction: callback,
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
configuration = Object.assign(Object.assign({}, configuration), { detect_document_only: true });
|
|
135
|
+
this.privid_wasm_result = createCallback({ type: callbackTypeEnum.backScan, callbackFunction: callback });
|
|
136
|
+
}
|
|
137
|
+
configuration = JSON.stringify(configuration);
|
|
138
|
+
if (!videoEl) {
|
|
139
|
+
printLogs(`Capture need the video element id`, '', 'ERROR');
|
|
140
|
+
return { result: ERROR_RESULT };
|
|
141
|
+
}
|
|
142
|
+
const imageData = this.generateImageData();
|
|
143
|
+
if ((imageData === null || imageData === void 0 ? void 0 : imageData.width) === 0)
|
|
144
|
+
return { result: ERROR_RESULT };
|
|
145
|
+
let result = null;
|
|
146
|
+
if (this.hasDebugWithImages) {
|
|
147
|
+
yield this.generateDebugImages([imageData], ImageType.original, 'enroll');
|
|
148
|
+
}
|
|
149
|
+
try {
|
|
150
|
+
printLogs(`Configuration: back scan: `, configuration);
|
|
151
|
+
result = yield this.wasmService.scanBackDocument(imageData, this.isSimd, configuration, proxy(this.privid_wasm_result));
|
|
152
|
+
// TODO: Validate if we need to release, and when, since we will have only one instance of canvas
|
|
153
|
+
releaseCanvas(this.canvas);
|
|
154
|
+
return Object.assign({}, result);
|
|
155
|
+
}
|
|
156
|
+
catch (e) {
|
|
157
|
+
printLogs(`isValidPhotoID error: `, e, 'ERROR');
|
|
158
|
+
return {
|
|
159
|
+
result: ERROR_CODE,
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
documentOcr(params) {
|
|
165
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
166
|
+
printLogs('________________ DOCUMENT OCR ______________', '');
|
|
167
|
+
let configuration = {
|
|
168
|
+
input_image_format: INPUT_IMAGE_FORMAT,
|
|
169
|
+
calculate_age_from_ocr_text: CALCULATE_AGE_FROM_OCR_TEXT,
|
|
170
|
+
threshold_doc_x: DOCUMENT_THRESHOLD_X,
|
|
171
|
+
threshold_doc_y: DOCUMENT_THRESHOLD_Y,
|
|
172
|
+
threshold_doc_too_close: DOCUMENT_TOO_CLOSE_THRESHOLD,
|
|
173
|
+
threshold_doc_too_far: DOCUMENT_TOO_FAR_THRESHOLD,
|
|
174
|
+
};
|
|
175
|
+
if (params.config) {
|
|
176
|
+
configuration = Object.assign(Object.assign({}, configuration), params.config);
|
|
177
|
+
}
|
|
178
|
+
this.privid_wasm_result = createCallback({ type: callbackTypeEnum.documentOcr, callbackFunction: params.callback });
|
|
179
|
+
const cb = proxy(this.privid_wasm_result);
|
|
180
|
+
if (this.hasDebugWithImages) {
|
|
181
|
+
const imageData = yield imageDataFromBase64(params.inputImage);
|
|
182
|
+
yield this.generateDebugImages([imageData], `${ImageType.original}_document_ocr`, 'enroll');
|
|
183
|
+
}
|
|
184
|
+
try {
|
|
185
|
+
configuration = JSON.stringify(configuration);
|
|
186
|
+
return yield this.wasmService.documentOcr(params.inputImage, configuration, cb);
|
|
187
|
+
}
|
|
188
|
+
catch (e) {
|
|
189
|
+
printLogs(`isValidPhotoID error: `, e, 'ERROR');
|
|
190
|
+
return {
|
|
191
|
+
result: ERROR_CODE,
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
getVideoElement() {
|
|
197
|
+
return this.cameraService.getVideoElementDOM();
|
|
198
|
+
}
|
|
199
|
+
generateDebugImages(images, title, action) {
|
|
200
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
201
|
+
const a = document.createElement('a');
|
|
202
|
+
a.type = DOWNLOAD_IMAGE_TYPE;
|
|
203
|
+
document.body.appendChild(a);
|
|
204
|
+
for (const imageContent of images) {
|
|
205
|
+
this.debugCanvas.width = imageContent.width;
|
|
206
|
+
this.debugCanvas.height = imageContent.height;
|
|
207
|
+
const ctx = this.debugCanvas.getContext('2d');
|
|
208
|
+
ctx.putImageData(imageContent, 0, 0);
|
|
209
|
+
const blob = yield new Promise((resolve) => this.debugCanvas.toBlob((b) => resolve(b), IMAGE_EXPORT_FORMAT));
|
|
210
|
+
if (blob) {
|
|
211
|
+
const url = URL.createObjectURL(blob);
|
|
212
|
+
try {
|
|
213
|
+
a.href = url;
|
|
214
|
+
a.download = `${title}_${action}${FILE_EXTENSION}`;
|
|
215
|
+
a.click();
|
|
216
|
+
yield new Promise((r) => setTimeout(r, DOWNLOAD_DELAY_TIMEOUT));
|
|
217
|
+
}
|
|
218
|
+
catch (error) {
|
|
219
|
+
printLogs('[DocumentService] generateDebugImages error', error, 'ERROR');
|
|
220
|
+
}
|
|
221
|
+
finally {
|
|
222
|
+
URL.revokeObjectURL(url);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
a.remove();
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
// TODO: Both DocumentService and FaceService uses generateImageData and prepareCanvas
|
|
230
|
+
// but in different ways, should we create an interface to secure these implementations?
|
|
231
|
+
// Or should we bring that to a different Class called CanvasService?
|
|
232
|
+
generateImageData() {
|
|
233
|
+
var _a;
|
|
234
|
+
const videoElement = this.cameraService.getVideoElementDOM();
|
|
235
|
+
printLogs('[DocumentService] generateImageData videoElement', videoElement);
|
|
236
|
+
const canvas = this.prepareCanvas(videoElement);
|
|
237
|
+
const context = this.canvas.getContext('2d', { willReadFrequently: true });
|
|
238
|
+
(_a = context.resetTransform) === null || _a === void 0 ? void 0 : _a.call(context);
|
|
239
|
+
context.clearRect(0, 0, canvas.width, canvas.height);
|
|
240
|
+
context.drawImage(videoElement, 0, 0, canvas.width, canvas.height);
|
|
241
|
+
return context.getImageData(0, 0, canvas.width, canvas.height);
|
|
242
|
+
}
|
|
243
|
+
prepareCanvas(videoElement) {
|
|
244
|
+
const height = videoElement.videoHeight || 0;
|
|
245
|
+
const width = videoElement.videoWidth || 0;
|
|
246
|
+
if (width === 0) {
|
|
247
|
+
throw new Error(INVALID_VIDEO_ERROR);
|
|
248
|
+
}
|
|
249
|
+
this.canvas.setAttribute('height', `${height}`);
|
|
250
|
+
this.canvas.setAttribute('width', `${width}`);
|
|
251
|
+
this.canvas.setAttribute('id', CANVAS_ID);
|
|
252
|
+
return this.canvas;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
255
|
//# sourceMappingURL=DocumentService.js.map
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
export declare const DEBUG_TYPES_WITH_IMAGES: string[];
|
|
2
|
-
export declare const INPUT_IMAGE_FORMAT = "rgba";
|
|
3
|
-
export declare const CANVAS_RELEASE_DIMENSION = 1;
|
|
4
|
-
export declare const FINGERS_OVER_DOCUMENT_THRESHOLD = 0.2;
|
|
5
|
-
export declare const DOCUMENT_THRESHOLD_X = 0;
|
|
6
|
-
export declare const DOCUMENT_THRESHOLD_Y = 0;
|
|
7
|
-
export declare const DOCUMENT_TOO_CLOSE_THRESHOLD = 0.99;
|
|
8
|
-
export declare const DOCUMENT_TOO_FAR_THRESHOLD = 0.1;
|
|
9
|
-
export declare const CALCULATE_AGE_FROM_OCR_TEXT = true;
|
|
10
|
-
export declare const ERROR_RESULT = "error";
|
|
11
|
-
export declare const ERROR_CODE = -1;
|
|
12
|
-
export declare const IMAGE_EXPORT_FORMAT = "image/jpeg";
|
|
13
|
-
export declare const DOWNLOAD_IMAGE_TYPE = "image/png";
|
|
14
|
-
export declare const FILE_EXTENSION = ".png";
|
|
15
|
-
export declare const DOWNLOAD_DELAY_TIMEOUT = 1000;
|
|
1
|
+
export declare const DEBUG_TYPES_WITH_IMAGES: string[];
|
|
2
|
+
export declare const INPUT_IMAGE_FORMAT = "rgba";
|
|
3
|
+
export declare const CANVAS_RELEASE_DIMENSION = 1;
|
|
4
|
+
export declare const FINGERS_OVER_DOCUMENT_THRESHOLD = 0.2;
|
|
5
|
+
export declare const DOCUMENT_THRESHOLD_X = 0;
|
|
6
|
+
export declare const DOCUMENT_THRESHOLD_Y = 0;
|
|
7
|
+
export declare const DOCUMENT_TOO_CLOSE_THRESHOLD = 0.99;
|
|
8
|
+
export declare const DOCUMENT_TOO_FAR_THRESHOLD = 0.1;
|
|
9
|
+
export declare const CALCULATE_AGE_FROM_OCR_TEXT = true;
|
|
10
|
+
export declare const ERROR_RESULT = "error";
|
|
11
|
+
export declare const ERROR_CODE = -1;
|
|
12
|
+
export declare const IMAGE_EXPORT_FORMAT = "image/jpeg";
|
|
13
|
+
export declare const DOWNLOAD_IMAGE_TYPE = "image/png";
|
|
14
|
+
export declare const FILE_EXTENSION = ".png";
|
|
15
|
+
export declare const DOWNLOAD_DELAY_TIMEOUT = 1000;
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
// Debug configuration
|
|
2
|
-
export const DEBUG_TYPES_WITH_IMAGES = ['900', '901', '902', '903'];
|
|
3
|
-
// Image and canvas configuration
|
|
4
|
-
export const INPUT_IMAGE_FORMAT = 'rgba';
|
|
5
|
-
export const CANVAS_RELEASE_DIMENSION = 1;
|
|
6
|
-
// Document scanning thresholds
|
|
7
|
-
export const FINGERS_OVER_DOCUMENT_THRESHOLD = 0.2;
|
|
8
|
-
export const DOCUMENT_THRESHOLD_X = 0.0;
|
|
9
|
-
export const DOCUMENT_THRESHOLD_Y = 0.0;
|
|
10
|
-
export const DOCUMENT_TOO_CLOSE_THRESHOLD = 0.99;
|
|
11
|
-
export const DOCUMENT_TOO_FAR_THRESHOLD = 0.1;
|
|
12
|
-
// OCR configuration
|
|
13
|
-
export const CALCULATE_AGE_FROM_OCR_TEXT = true;
|
|
14
|
-
// Error handling
|
|
15
|
-
export const ERROR_RESULT = 'error';
|
|
16
|
-
export const ERROR_CODE = -1;
|
|
17
|
-
// Image processing
|
|
18
|
-
export const IMAGE_EXPORT_FORMAT = 'image/jpeg';
|
|
19
|
-
export const DOWNLOAD_IMAGE_TYPE = 'image/png';
|
|
20
|
-
export const FILE_EXTENSION = '.png';
|
|
21
|
-
export const DOWNLOAD_DELAY_TIMEOUT = 1000;
|
|
1
|
+
// Debug configuration
|
|
2
|
+
export const DEBUG_TYPES_WITH_IMAGES = ['900', '901', '902', '903'];
|
|
3
|
+
// Image and canvas configuration
|
|
4
|
+
export const INPUT_IMAGE_FORMAT = 'rgba';
|
|
5
|
+
export const CANVAS_RELEASE_DIMENSION = 1;
|
|
6
|
+
// Document scanning thresholds
|
|
7
|
+
export const FINGERS_OVER_DOCUMENT_THRESHOLD = 0.2;
|
|
8
|
+
export const DOCUMENT_THRESHOLD_X = 0.0;
|
|
9
|
+
export const DOCUMENT_THRESHOLD_Y = 0.0;
|
|
10
|
+
export const DOCUMENT_TOO_CLOSE_THRESHOLD = 0.99;
|
|
11
|
+
export const DOCUMENT_TOO_FAR_THRESHOLD = 0.1;
|
|
12
|
+
// OCR configuration
|
|
13
|
+
export const CALCULATE_AGE_FROM_OCR_TEXT = true;
|
|
14
|
+
// Error handling
|
|
15
|
+
export const ERROR_RESULT = 'error';
|
|
16
|
+
export const ERROR_CODE = -1;
|
|
17
|
+
// Image processing
|
|
18
|
+
export const IMAGE_EXPORT_FORMAT = 'image/jpeg';
|
|
19
|
+
export const DOWNLOAD_IMAGE_TYPE = 'image/png';
|
|
20
|
+
export const FILE_EXTENSION = '.png';
|
|
21
|
+
export const DOWNLOAD_DELAY_TIMEOUT = 1000;
|
|
22
22
|
//# sourceMappingURL=document.constants.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { BackScanParams, DocumentOcrParams, FrontDocumentScanParams, DocumentScanResponse } from './document.types';
|
|
2
|
-
export interface Document {
|
|
3
|
-
scanGovernmentPhotoId: (params: FrontDocumentScanParams) => Promise<DocumentScanResponse>;
|
|
4
|
-
scanPassport: (params: FrontDocumentScanParams) => Promise<DocumentScanResponse>;
|
|
5
|
-
scanBackDocument: (params: BackScanParams) => Promise<void>;
|
|
6
|
-
documentOcr: (params: DocumentOcrParams) => Promise<void>;
|
|
7
|
-
}
|
|
1
|
+
import { BackScanParams, DocumentOcrParams, FrontDocumentScanParams, DocumentScanResponse } from './document.types';
|
|
2
|
+
export interface Document {
|
|
3
|
+
scanGovernmentPhotoId: (params: FrontDocumentScanParams) => Promise<DocumentScanResponse>;
|
|
4
|
+
scanPassport: (params: FrontDocumentScanParams) => Promise<DocumentScanResponse>;
|
|
5
|
+
scanBackDocument: (params: BackScanParams) => Promise<void>;
|
|
6
|
+
documentOcr: (params: DocumentOcrParams) => Promise<void>;
|
|
7
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
2
2
|
//# sourceMappingURL=document.domain.js.map
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
interface BaseScanParams {
|
|
2
|
-
callback: (returnData: any) => void;
|
|
3
|
-
config?: any;
|
|
4
|
-
}
|
|
5
|
-
export interface BackScanParams extends BaseScanParams {
|
|
6
|
-
image?: ImageData;
|
|
7
|
-
}
|
|
8
|
-
export interface FrontDocumentScanParams extends BaseScanParams {
|
|
9
|
-
doOcr?: boolean;
|
|
10
|
-
}
|
|
11
|
-
export type DocumentScanResponse = {
|
|
12
|
-
success: boolean;
|
|
13
|
-
};
|
|
14
|
-
export interface DocumentOcrParams extends BaseScanParams {
|
|
15
|
-
inputImage: string;
|
|
16
|
-
}
|
|
17
|
-
export {};
|
|
1
|
+
interface BaseScanParams {
|
|
2
|
+
callback: (returnData: any) => void;
|
|
3
|
+
config?: any;
|
|
4
|
+
}
|
|
5
|
+
export interface BackScanParams extends BaseScanParams {
|
|
6
|
+
image?: ImageData;
|
|
7
|
+
}
|
|
8
|
+
export interface FrontDocumentScanParams extends BaseScanParams {
|
|
9
|
+
doOcr?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export type DocumentScanResponse = {
|
|
12
|
+
success: boolean;
|
|
13
|
+
};
|
|
14
|
+
export interface DocumentOcrParams extends BaseScanParams {
|
|
15
|
+
inputImage: string;
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
2
2
|
//# sourceMappingURL=document.types.js.map
|