idmission-web-sdk 2.2.64 → 2.2.66
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/components/CompositeWizard.d.ts.map +1 -1
- package/dist/components/Example.d.ts +1 -1
- package/dist/components/Example.d.ts.map +1 -1
- package/dist/components/camera/CameraVideoTag.d.ts.map +1 -1
- package/dist/components/customer_flows/IdValidation.d.ts +3 -1
- package/dist/components/customer_flows/IdValidation.d.ts.map +1 -1
- package/dist/components/document_capture/DocumentCaptureStateProvider.d.ts.map +1 -1
- package/dist/components/fallback_flows/IdCapture.d.ts.map +1 -1
- package/dist/components/id_capture/CapturedDocuments.d.ts +1 -1
- package/dist/components/id_capture/CapturedDocuments.d.ts.map +1 -1
- package/dist/components/id_capture/IdCapture.d.ts +2 -2
- package/dist/components/id_capture/IdCapture.d.ts.map +1 -1
- package/dist/components/id_capture/IdCaptureModelsProvider.d.ts +2 -1
- package/dist/components/id_capture/IdCaptureModelsProvider.d.ts.map +1 -1
- package/dist/components/id_capture/IdCaptureRequirementOption.d.ts +7 -5
- package/dist/components/id_capture/IdCaptureRequirementOption.d.ts.map +1 -1
- package/dist/components/id_capture/IdCaptureStateProvider.d.ts +4 -0
- package/dist/components/id_capture/IdCaptureStateProvider.d.ts.map +1 -1
- package/dist/components/id_capture/IdCaptureSuccess.d.ts +0 -4
- package/dist/components/id_capture/IdCaptureSuccess.d.ts.map +1 -1
- package/dist/components/id_capture/IdCaptureWizard.d.ts +2 -1
- package/dist/components/id_capture/IdCaptureWizard.d.ts.map +1 -1
- package/dist/components/selfie_capture/SelfieCapture.d.ts.map +1 -1
- package/dist/components/signature_capture/SignatureCapture.d.ts.map +1 -1
- package/dist/components/submission/SubmissionProvider.d.ts.map +1 -1
- package/dist/components/video_id/IdVideoCapture.d.ts +2 -0
- package/dist/components/video_id/IdVideoCapture.d.ts.map +1 -1
- package/dist/components/video_id/IdVideoCaptureWizard.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/lib/camera/Camera.d.ts +0 -43
- package/dist/lib/camera/Camera.d.ts.map +1 -1
- package/dist/lib/camera/cameraStore.d.ts.map +1 -1
- package/dist/lib/models/DocumentDetection.d.ts +6 -2
- package/dist/lib/models/DocumentDetection.d.ts.map +1 -1
- package/dist/lib/models/Focus.d.ts +4 -0
- package/dist/lib/models/Focus.d.ts.map +1 -1
- package/dist/lib/models/defaults/DocumentDetector.d.ts +1 -1
- package/dist/sdk2.cjs.development.js +533 -464
- package/dist/sdk2.cjs.development.js.map +1 -1
- package/dist/sdk2.cjs.production.js +1 -1
- package/dist/sdk2.cjs.production.js.map +1 -1
- package/dist/sdk2.esm.js +533 -464
- package/dist/sdk2.esm.js.map +1 -1
- package/dist/sdk2.umd.development.js +533 -464
- package/dist/sdk2.umd.development.js.map +1 -1
- package/dist/sdk2.umd.production.js +1 -1
- package/dist/sdk2.umd.production.js.map +1 -1
- package/dist/themes/index.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +5 -10
- package/dist/lib/barcode/Native.d.ts +0 -2
- package/dist/lib/barcode/Native.d.ts.map +0 -1
- package/dist/lib/barcode/Scan.d.ts +0 -5
- package/dist/lib/barcode/Scan.d.ts.map +0 -1
- package/dist/lib/barcode/ZXing.d.ts +0 -2
- package/dist/lib/barcode/ZXing.d.ts.map +0 -1
- package/dist/lib/camera/videoRefStack.d.ts +0 -6
- package/dist/lib/camera/videoRefStack.d.ts.map +0 -1
package/dist/sdk2.esm.js
CHANGED
|
@@ -203,7 +203,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
203
203
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
204
204
|
};
|
|
205
205
|
|
|
206
|
-
var webSdkVersion = '2.2.
|
|
206
|
+
var webSdkVersion = '2.2.66';
|
|
207
207
|
|
|
208
208
|
function getPlatform() {
|
|
209
209
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
@@ -982,7 +982,7 @@ function debug() {
|
|
|
982
982
|
parts[_i] = arguments[_i];
|
|
983
983
|
}
|
|
984
984
|
if (logLevel < LogLevel.Debug) return;
|
|
985
|
-
console.debug.apply(console, parts); // eslint-disable-line
|
|
985
|
+
console.debug.apply(console, parts); // eslint-disable-line no-console
|
|
986
986
|
}
|
|
987
987
|
function log() {
|
|
988
988
|
var parts = [];
|
|
@@ -990,7 +990,7 @@ function log() {
|
|
|
990
990
|
parts[_i] = arguments[_i];
|
|
991
991
|
}
|
|
992
992
|
if (logLevel < LogLevel.Info) return;
|
|
993
|
-
console.log.apply(console, parts); // eslint-disable-line
|
|
993
|
+
console.log.apply(console, parts); // eslint-disable-line no-console
|
|
994
994
|
}
|
|
995
995
|
function warn() {
|
|
996
996
|
var parts = [];
|
|
@@ -998,7 +998,7 @@ function warn() {
|
|
|
998
998
|
parts[_i] = arguments[_i];
|
|
999
999
|
}
|
|
1000
1000
|
if (logLevel < LogLevel.Warn) return;
|
|
1001
|
-
console.warn.apply(console, parts); // eslint-disable-line
|
|
1001
|
+
console.warn.apply(console, parts); // eslint-disable-line no-console
|
|
1002
1002
|
}
|
|
1003
1003
|
function error() {
|
|
1004
1004
|
var parts = [];
|
|
@@ -1006,7 +1006,7 @@ function error() {
|
|
|
1006
1006
|
parts[_i] = arguments[_i];
|
|
1007
1007
|
}
|
|
1008
1008
|
if (logLevel < LogLevel.Error) return;
|
|
1009
|
-
console.error.apply(console, parts); // eslint-disable-line
|
|
1009
|
+
console.error.apply(console, parts); // eslint-disable-line no-console
|
|
1010
1010
|
}
|
|
1011
1011
|
|
|
1012
1012
|
var defaultSubmissionUrl = 'https://portal-api.idmission.com/swagger';
|
|
@@ -1303,82 +1303,33 @@ var SubmissionProvider = function SubmissionProvider(_a) {
|
|
|
1303
1303
|
onDocumentUploadFailed.current = userSuppliedOnDocumentUploadFailed;
|
|
1304
1304
|
}, [userSuppliedOnDocumentUploadFailed]);
|
|
1305
1305
|
var uploadDocument = useCallback(function (src, metadata) {
|
|
1306
|
-
return
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
filetype: blob.type,
|
|
1334
|
-
contentType: blob.type
|
|
1335
|
-
};
|
|
1336
|
-
return [4 /*yield*/, calculateMd5(blob)];
|
|
1337
|
-
case 3:
|
|
1338
|
-
upload = _b.apply(void 0, _c.concat([(_d.metadata = _assign.apply(void 0, [(_e.fingerprint = _g.sent(), _e), metadata || {}]), _d.onProgress = function (bytesUploaded, bytesTotal) {
|
|
1339
|
-
var _a;
|
|
1340
|
-
(_a = onDocumentUploadProgress.current) === null || _a === void 0 ? void 0 : _a.call(onDocumentUploadProgress, {
|
|
1341
|
-
bytesUploaded: bytesUploaded,
|
|
1342
|
-
bytesTotal: bytesTotal,
|
|
1343
|
-
percentage: (bytesUploaded / bytesTotal * 100).toFixed(2) + '%',
|
|
1344
|
-
metadata: metadata
|
|
1345
|
-
});
|
|
1346
|
-
}, _d.onAfterResponse = function (_req, res) {
|
|
1347
|
-
var contentType = res.getHeader('Content-Type');
|
|
1348
|
-
if (!(contentType === null || contentType === void 0 ? void 0 : contentType.startsWith('application/json'))) return;
|
|
1349
|
-
var body = res.getBody();
|
|
1350
|
-
if (!body) return;
|
|
1351
|
-
try {
|
|
1352
|
-
var parsedId = JSON.parse(body).id;
|
|
1353
|
-
if (parsedId.startsWith('urn:documentsv1:')) {
|
|
1354
|
-
documentId = parsedId;
|
|
1355
|
-
}
|
|
1356
|
-
} catch (e) {
|
|
1357
|
-
warn('Failed to parse documents service response body', e);
|
|
1358
|
-
}
|
|
1359
|
-
}, _d.onSuccess = function () {
|
|
1360
|
-
var _a, _b;
|
|
1361
|
-
documentId || (documentId = "urn:documentsv1:".concat(getEnvFromUrl(upload.url), ":").concat((_a = upload.url.split('/files/').pop()) === null || _a === void 0 ? void 0 : _a.split('+').shift()));
|
|
1362
|
-
(_b = onDocumentUploaded.current) === null || _b === void 0 ? void 0 : _b.call(onDocumentUploaded, documentId, metadata);
|
|
1363
|
-
resolve(documentId);
|
|
1364
|
-
}, _d.onError = function (error) {
|
|
1365
|
-
var _a;
|
|
1366
|
-
log('Failed because: ' + error);
|
|
1367
|
-
(_a = onDocumentUploadFailed.current) === null || _a === void 0 ? void 0 : _a.call(onDocumentUploadFailed, error, metadata);
|
|
1368
|
-
reject(error);
|
|
1369
|
-
}, _d)]));
|
|
1370
|
-
// Check if there are any previous uploads to continue.
|
|
1371
|
-
upload.findPreviousUploads().then(function (previousUploads) {
|
|
1372
|
-
// Found previous uploads so we select the first one.
|
|
1373
|
-
if (previousUploads.length) {
|
|
1374
|
-
upload.resumeFromPreviousUpload(previousUploads[0]);
|
|
1375
|
-
}
|
|
1376
|
-
// Start the upload
|
|
1377
|
-
upload.start();
|
|
1378
|
-
});
|
|
1379
|
-
return [2 /*return*/];
|
|
1380
|
-
}
|
|
1381
|
-
});
|
|
1306
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
1307
|
+
var blob, _a;
|
|
1308
|
+
var _b;
|
|
1309
|
+
return __generator(this, function (_c) {
|
|
1310
|
+
switch (_c.label) {
|
|
1311
|
+
case 0:
|
|
1312
|
+
blob = typeof src === 'string' ? convertBase64ToBlob(src) : src;
|
|
1313
|
+
_a = onBeforeDocumentUpload.current;
|
|
1314
|
+
if (!_a) return [3 /*break*/, 2];
|
|
1315
|
+
return [4 /*yield*/, (_b = onBeforeDocumentUpload.current) === null || _b === void 0 ? void 0 : _b.call(onBeforeDocumentUpload, blob, metadata)];
|
|
1316
|
+
case 1:
|
|
1317
|
+
_a = _c.sent() === false;
|
|
1318
|
+
_c.label = 2;
|
|
1319
|
+
case 2:
|
|
1320
|
+
if (_a) {
|
|
1321
|
+
return [2 /*return*/, blobToB64(blob)];
|
|
1322
|
+
}
|
|
1323
|
+
return [2 /*return*/, performUpload({
|
|
1324
|
+
blob: blob,
|
|
1325
|
+
endpoint: documentServiceUrl,
|
|
1326
|
+
sessionId: sessionId,
|
|
1327
|
+
metadata: metadata,
|
|
1328
|
+
onDocumentUploadProgress: onDocumentUploadProgress.current,
|
|
1329
|
+
onDocumentUploaded: onDocumentUploaded.current,
|
|
1330
|
+
onDocumentUploadFailed: onDocumentUploadFailed.current
|
|
1331
|
+
})];
|
|
1332
|
+
}
|
|
1382
1333
|
});
|
|
1383
1334
|
});
|
|
1384
1335
|
}, [documentServiceUrl, sessionId]);
|
|
@@ -1927,6 +1878,83 @@ function getEnvFromUrl(url) {
|
|
|
1927
1878
|
}
|
|
1928
1879
|
return 'unknown';
|
|
1929
1880
|
}
|
|
1881
|
+
function performUpload(_a) {
|
|
1882
|
+
return __awaiter(this, arguments, void 0, function (_b) {
|
|
1883
|
+
var fingerprint;
|
|
1884
|
+
var blob = _b.blob,
|
|
1885
|
+
endpoint = _b.endpoint,
|
|
1886
|
+
sessionId = _b.sessionId,
|
|
1887
|
+
metadata = _b.metadata,
|
|
1888
|
+
onDocumentUploadProgress = _b.onDocumentUploadProgress,
|
|
1889
|
+
onDocumentUploaded = _b.onDocumentUploaded,
|
|
1890
|
+
onDocumentUploadFailed = _b.onDocumentUploadFailed;
|
|
1891
|
+
return __generator(this, function (_c) {
|
|
1892
|
+
switch (_c.label) {
|
|
1893
|
+
case 0:
|
|
1894
|
+
return [4 /*yield*/, calculateMd5(blob)];
|
|
1895
|
+
case 1:
|
|
1896
|
+
fingerprint = _c.sent();
|
|
1897
|
+
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
1898
|
+
var documentId;
|
|
1899
|
+
var upload = createUpload(blob, {
|
|
1900
|
+
endpoint: endpoint,
|
|
1901
|
+
retryDelays: [0, 1000, 1000, 1000, 3000, 5000, 10000, 20000],
|
|
1902
|
+
headers: {
|
|
1903
|
+
'X-Session-Id': sessionId
|
|
1904
|
+
},
|
|
1905
|
+
metadata: _assign({
|
|
1906
|
+
filetype: blob.type,
|
|
1907
|
+
contentType: blob.type,
|
|
1908
|
+
fingerprint: fingerprint
|
|
1909
|
+
}, metadata || {}),
|
|
1910
|
+
onProgress: function onProgress(bytesUploaded, bytesTotal) {
|
|
1911
|
+
onDocumentUploadProgress === null || onDocumentUploadProgress === void 0 ? void 0 : onDocumentUploadProgress({
|
|
1912
|
+
bytesUploaded: bytesUploaded,
|
|
1913
|
+
bytesTotal: bytesTotal,
|
|
1914
|
+
percentage: (bytesUploaded / bytesTotal * 100).toFixed(2) + '%',
|
|
1915
|
+
metadata: metadata
|
|
1916
|
+
});
|
|
1917
|
+
},
|
|
1918
|
+
onAfterResponse: function onAfterResponse(_req, res) {
|
|
1919
|
+
var contentType = res.getHeader('Content-Type');
|
|
1920
|
+
if (!(contentType === null || contentType === void 0 ? void 0 : contentType.startsWith('application/json'))) return;
|
|
1921
|
+
var body = res.getBody();
|
|
1922
|
+
if (!body) return;
|
|
1923
|
+
try {
|
|
1924
|
+
var parsedId = JSON.parse(body).id;
|
|
1925
|
+
if (parsedId.startsWith('urn:documentsv1:')) {
|
|
1926
|
+
documentId = parsedId;
|
|
1927
|
+
}
|
|
1928
|
+
} catch (e) {
|
|
1929
|
+
warn('Failed to parse documents service response body', e);
|
|
1930
|
+
}
|
|
1931
|
+
},
|
|
1932
|
+
onSuccess: function onSuccess() {
|
|
1933
|
+
var _a;
|
|
1934
|
+
documentId || (documentId = "urn:documentsv1:".concat(getEnvFromUrl(upload.url), ":").concat((_a = upload.url.split('/files/').pop()) === null || _a === void 0 ? void 0 : _a.split('+').shift()));
|
|
1935
|
+
onDocumentUploaded === null || onDocumentUploaded === void 0 ? void 0 : onDocumentUploaded(documentId, metadata);
|
|
1936
|
+
resolve(documentId);
|
|
1937
|
+
},
|
|
1938
|
+
onError: function onError(error) {
|
|
1939
|
+
log('Failed because: ' + error);
|
|
1940
|
+
onDocumentUploadFailed === null || onDocumentUploadFailed === void 0 ? void 0 : onDocumentUploadFailed(error, metadata);
|
|
1941
|
+
reject(error);
|
|
1942
|
+
}
|
|
1943
|
+
});
|
|
1944
|
+
// Check if there are any previous uploads to continue.
|
|
1945
|
+
upload.findPreviousUploads().then(function (previousUploads) {
|
|
1946
|
+
// Found previous uploads so we select the first one.
|
|
1947
|
+
if (previousUploads.length) {
|
|
1948
|
+
upload.resumeFromPreviousUpload(previousUploads[0]);
|
|
1949
|
+
}
|
|
1950
|
+
// Start the upload
|
|
1951
|
+
upload.start();
|
|
1952
|
+
});
|
|
1953
|
+
})];
|
|
1954
|
+
}
|
|
1955
|
+
});
|
|
1956
|
+
});
|
|
1957
|
+
}
|
|
1930
1958
|
|
|
1931
1959
|
var visionTasksBasePath = "https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@0.10.7/wasm";
|
|
1932
1960
|
var visionRuntimePreloading = false;
|
|
@@ -2238,7 +2266,7 @@ function average(arr) {
|
|
|
2238
2266
|
|
|
2239
2267
|
var DEFAULT_CDN_URL = 'https://websdk-cdn-dev.idmission.com/assets';
|
|
2240
2268
|
|
|
2241
|
-
var defaultDocumentDetectorModelPath = "".concat(DEFAULT_CDN_URL, "/models/DocumentDetector/DocumentDetector-
|
|
2269
|
+
var defaultDocumentDetectorModelPath = "".concat(DEFAULT_CDN_URL, "/models/DocumentDetector/DocumentDetector-20241212_131026.tflite");
|
|
2242
2270
|
|
|
2243
2271
|
var defaultFocusModelPath = "".concat(DEFAULT_CDN_URL, "/models/Focus/Focus-20241008_102708.tflite");
|
|
2244
2272
|
|
|
@@ -2257,6 +2285,10 @@ var defaultFocusThresholds = {
|
|
|
2257
2285
|
passport: {
|
|
2258
2286
|
desktop: 0,
|
|
2259
2287
|
mobile: 0.3
|
|
2288
|
+
},
|
|
2289
|
+
singlePage: {
|
|
2290
|
+
desktop: 0,
|
|
2291
|
+
mobile: 0.3
|
|
2260
2292
|
}
|
|
2261
2293
|
};
|
|
2262
2294
|
var classifier = null;
|
|
@@ -2364,7 +2396,7 @@ function useLoadFocusModel(_a) {
|
|
|
2364
2396
|
};
|
|
2365
2397
|
}, [modelPath, modelLoadTimeoutMs, videoRef, shouldLoadModels]);
|
|
2366
2398
|
useEffect(function handleModelError() {
|
|
2367
|
-
modelError
|
|
2399
|
+
if (modelError) onModelError === null || onModelError === void 0 ? void 0 : onModelError(modelError);
|
|
2368
2400
|
}, [modelError, onModelError]);
|
|
2369
2401
|
return {
|
|
2370
2402
|
ready: ready,
|
|
@@ -2510,7 +2542,7 @@ function useLoadFaceDetector(_a) {
|
|
|
2510
2542
|
};
|
|
2511
2543
|
}, [modelLoadTimeoutMs, videoRef]);
|
|
2512
2544
|
useEffect(function handleModelError() {
|
|
2513
|
-
modelError
|
|
2545
|
+
if (modelError) onModelError === null || onModelError === void 0 ? void 0 : onModelError(modelError);
|
|
2514
2546
|
}, [modelError, onModelError]);
|
|
2515
2547
|
return {
|
|
2516
2548
|
ready: ready,
|
|
@@ -2882,16 +2914,19 @@ var defaultDocumentDetectionThresholds = {
|
|
|
2882
2914
|
idCardFront: 0.6,
|
|
2883
2915
|
idCardBack: 0.6,
|
|
2884
2916
|
passport: 0.4,
|
|
2917
|
+
singlePage: 0.4,
|
|
2885
2918
|
stability: {
|
|
2886
2919
|
idCardFront: 0.85,
|
|
2887
2920
|
idCardBack: 0.85,
|
|
2888
|
-
passport: 0.5
|
|
2921
|
+
passport: 0.5,
|
|
2922
|
+
singlePage: 0.5
|
|
2889
2923
|
}
|
|
2890
2924
|
};
|
|
2891
2925
|
var documentTypeDisplayNames = {
|
|
2892
2926
|
idCardFront: 'ID card front',
|
|
2893
2927
|
idCardBack: 'ID card back',
|
|
2894
2928
|
passport: 'Passport',
|
|
2929
|
+
singlePage: 'Single page',
|
|
2895
2930
|
none: 'None'
|
|
2896
2931
|
};
|
|
2897
2932
|
var detector = null;
|
|
@@ -3006,7 +3041,7 @@ function useLoadDocumentDetector(_a) {
|
|
|
3006
3041
|
};
|
|
3007
3042
|
}, [shouldLoadModels, modelLoadTimeoutMs, modelPath, scoreThreshold, videoRef]);
|
|
3008
3043
|
useEffect(function handleModelError() {
|
|
3009
|
-
modelError
|
|
3044
|
+
if (modelError) onModelError === null || onModelError === void 0 ? void 0 : onModelError(modelError);
|
|
3010
3045
|
}, [modelError, onModelError]);
|
|
3011
3046
|
return {
|
|
3012
3047
|
ready: ready,
|
|
@@ -3080,7 +3115,7 @@ var defaultDocumentDetectionBoundaries = {
|
|
|
3080
3115
|
right: 20
|
|
3081
3116
|
};
|
|
3082
3117
|
function processDocumentDetectorPrediction(prediction, thresholds, boundaries) {
|
|
3083
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
3118
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
3084
3119
|
if (boundaries === void 0) {
|
|
3085
3120
|
boundaries = defaultDocumentDetectionBoundaries;
|
|
3086
3121
|
}
|
|
@@ -3131,18 +3166,25 @@ function processDocumentDetectorPrediction(prediction, thresholds, boundaries) {
|
|
|
3131
3166
|
var bestPassportPage = detectedObjects.find(function (obj) {
|
|
3132
3167
|
return obj.label === 'Passport page';
|
|
3133
3168
|
});
|
|
3169
|
+
var bestSinglePage = detectedObjects.find(function (obj) {
|
|
3170
|
+
return obj.label === 'Single page';
|
|
3171
|
+
});
|
|
3134
3172
|
var idCardFrontDetectionScore = (_e = bestIdCardFront === null || bestIdCardFront === void 0 ? void 0 : bestIdCardFront.score) !== null && _e !== void 0 ? _e : 0;
|
|
3135
3173
|
var idCardBackDetectionScore = (_f = bestIdCardBack === null || bestIdCardBack === void 0 ? void 0 : bestIdCardBack.score) !== null && _f !== void 0 ? _f : 0;
|
|
3136
3174
|
var passportDetectionScore = (_g = bestPassportPage === null || bestPassportPage === void 0 ? void 0 : bestPassportPage.score) !== null && _g !== void 0 ? _g : 0;
|
|
3137
|
-
var
|
|
3138
|
-
var
|
|
3139
|
-
var
|
|
3140
|
-
var
|
|
3141
|
-
var
|
|
3142
|
-
var
|
|
3175
|
+
var singlePageDetectionScore = (_h = bestSinglePage === null || bestSinglePage === void 0 ? void 0 : bestSinglePage.score) !== null && _h !== void 0 ? _h : 0;
|
|
3176
|
+
var idCardFrontDetectionThresholdMet = idCardFrontDetectionScore >= ((_j = thresholds.idCardFront) !== null && _j !== void 0 ? _j : 0);
|
|
3177
|
+
var idCardBackDetectionThresholdMet = idCardBackDetectionScore >= ((_k = thresholds.idCardBack) !== null && _k !== void 0 ? _k : 0);
|
|
3178
|
+
var passportDetectionThresholdMet = passportDetectionScore >= ((_l = thresholds.passport) !== null && _l !== void 0 ? _l : 0);
|
|
3179
|
+
var singlePageDetectionThresholdMet = singlePageDetectionScore >= ((_m = thresholds.singlePage) !== null && _m !== void 0 ? _m : 0);
|
|
3180
|
+
var bestDocument = singlePageDetectionThresholdMet ? bestSinglePage : passportDetectionThresholdMet ? bestPassportPage : idCardBackDetectionThresholdMet ? bestIdCardBack : bestIdCardFront;
|
|
3181
|
+
var detectionThreshold = singlePageDetectionThresholdMet ? thresholds.singlePage : passportDetectionThresholdMet ? thresholds.passport : idCardBackDetectionThresholdMet ? thresholds.idCardBack : thresholds.idCardFront;
|
|
3182
|
+
var detectionScore = (_o = bestDocument === null || bestDocument === void 0 ? void 0 : bestDocument.score) !== null && _o !== void 0 ? _o : 0;
|
|
3143
3183
|
var detectionThresholdMet = detectionScore >= (detectionThreshold !== null && detectionThreshold !== void 0 ? detectionThreshold : 0);
|
|
3144
3184
|
var detectedDocumentType = 'none';
|
|
3145
|
-
if (
|
|
3185
|
+
if (singlePageDetectionThresholdMet) {
|
|
3186
|
+
detectedDocumentType = 'singlePage';
|
|
3187
|
+
} else if (passportDetectionThresholdMet) {
|
|
3146
3188
|
detectedDocumentType = 'passport';
|
|
3147
3189
|
} else if (idCardBackDetectionThresholdMet) {
|
|
3148
3190
|
detectedDocumentType = 'idCardBack';
|
|
@@ -3156,12 +3198,12 @@ function processDocumentDetectorPrediction(prediction, thresholds, boundaries) {
|
|
|
3156
3198
|
var documentIsStable = false;
|
|
3157
3199
|
var documentTooClose = false;
|
|
3158
3200
|
if (bestDocument) {
|
|
3159
|
-
var
|
|
3160
|
-
docWidth =
|
|
3161
|
-
docHeight =
|
|
3201
|
+
var _q = [bestDocument.box.width / frameWidth, bestDocument.box.height / frameHeight],
|
|
3202
|
+
docWidth = _q[0],
|
|
3203
|
+
docHeight = _q[1];
|
|
3162
3204
|
documentTooClose = docWidth > 0.85 || docHeight > 0.85;
|
|
3163
3205
|
if (detectionThresholdMet && documentInBounds && !documentTooClose) {
|
|
3164
|
-
var thresholdSet = (
|
|
3206
|
+
var thresholdSet = (_p = thresholds.stability) !== null && _p !== void 0 ? _p : defaultDocumentDetectionThresholds.stability;
|
|
3165
3207
|
var threshold_1 = thresholdSet[detectedDocumentType];
|
|
3166
3208
|
var framesNeeded = Math.ceil(average(framesNeededSamples));
|
|
3167
3209
|
trackBox(bestDocument.box, framesNeeded);
|
|
@@ -3183,6 +3225,8 @@ function processDocumentDetectorPrediction(prediction, thresholds, boundaries) {
|
|
|
3183
3225
|
idCardBackDetectionThresholdMet: idCardBackDetectionThresholdMet,
|
|
3184
3226
|
passportDetectionScore: passportDetectionScore,
|
|
3185
3227
|
passportDetectionThresholdMet: passportDetectionThresholdMet,
|
|
3228
|
+
singlePageDetectionScore: singlePageDetectionScore,
|
|
3229
|
+
singlePageDetectionThresholdMet: singlePageDetectionThresholdMet,
|
|
3186
3230
|
bestDocument: bestDocument,
|
|
3187
3231
|
documentInBounds: documentInBounds,
|
|
3188
3232
|
documentTooClose: documentTooClose,
|
|
@@ -3248,8 +3292,8 @@ function useFrameLoop(fn, _a) {
|
|
|
3248
3292
|
renderPrediction().then();
|
|
3249
3293
|
return function () {
|
|
3250
3294
|
loopId.current += 1;
|
|
3251
|
-
frameId.current
|
|
3252
|
-
timer
|
|
3295
|
+
if (frameId.current) cancelAnimationFrame(frameId.current);
|
|
3296
|
+
if (timer) clearTimeout(timer);
|
|
3253
3297
|
};
|
|
3254
3298
|
}, [fn, running, throttleMs]);
|
|
3255
3299
|
var start = useCallback(function () {
|
|
@@ -3414,7 +3458,7 @@ var createCameraStore = function createCameraStore(config) {
|
|
|
3414
3458
|
},
|
|
3415
3459
|
requestCameraAccess: function requestCameraAccess() {
|
|
3416
3460
|
return __awaiter(this, void 0, void 0, function () {
|
|
3417
|
-
var _a, videoRef, releaseCameraAccess, preferFrontFacingCamera, preferIphoneContinuityCamera, iphoneContinuityCameraDenied, availableCameras, selectedCamera, platform_1, iphoneContinuityCamera, constraints, stream_1, e_1, handleStreamEnded_1, videoTrack_1, camera_1, e_3;
|
|
3461
|
+
var _a, videoRef, releaseCameraAccess, preferFrontFacingCamera, preferIphoneContinuityCamera, iphoneContinuityCameraDenied, availableCameras, selectedCamera, platform_1, iphoneContinuityCamera, constraints, stream_1, e_1, e_2, handleStreamEnded_1, videoTrack_1, camera_1, e_3;
|
|
3418
3462
|
var _b, _c, _d;
|
|
3419
3463
|
return __generator(this, function (_e) {
|
|
3420
3464
|
switch (_e.label) {
|
|
@@ -3534,13 +3578,13 @@ var createCameraStore = function createCameraStore(config) {
|
|
|
3534
3578
|
debug('opened stream with no width and height constraints');
|
|
3535
3579
|
return [3 /*break*/, 10];
|
|
3536
3580
|
case 9:
|
|
3537
|
-
_e.sent();
|
|
3538
|
-
debug('cannot open stream at all');
|
|
3581
|
+
e_2 = _e.sent();
|
|
3582
|
+
debug('cannot open stream at all', e_2);
|
|
3539
3583
|
return [3 /*break*/, 10];
|
|
3540
3584
|
case 10:
|
|
3541
3585
|
if (!stream_1) {
|
|
3542
3586
|
error('failed to open camera');
|
|
3543
|
-
throw new Error('failed to open camera');
|
|
3587
|
+
throw new Error('failed to open camera: ');
|
|
3544
3588
|
}
|
|
3545
3589
|
debug('camera access granted with constraints', constraints);
|
|
3546
3590
|
handleStreamEnded_1 = function handleStreamEnded_1() {
|
|
@@ -3621,7 +3665,7 @@ var createCameraStore = function createCameraStore(config) {
|
|
|
3621
3665
|
},
|
|
3622
3666
|
requestMicrophoneAccess: function requestMicrophoneAccess() {
|
|
3623
3667
|
return __awaiter(this, void 0, void 0, function () {
|
|
3624
|
-
var stream_2;
|
|
3668
|
+
var stream_2, e_4;
|
|
3625
3669
|
return __generator(this, function (_a) {
|
|
3626
3670
|
switch (_a.label) {
|
|
3627
3671
|
case 0:
|
|
@@ -3660,7 +3704,8 @@ var createCameraStore = function createCameraStore(config) {
|
|
|
3660
3704
|
}, 500);
|
|
3661
3705
|
return [3 /*break*/, 4];
|
|
3662
3706
|
case 3:
|
|
3663
|
-
_a.sent();
|
|
3707
|
+
e_4 = _a.sent();
|
|
3708
|
+
debug('failed to open microphone', e_4);
|
|
3664
3709
|
set({
|
|
3665
3710
|
microphoneAccessDenied: true
|
|
3666
3711
|
});
|
|
@@ -4025,9 +4070,7 @@ function evaluateIsMobile(nav) {
|
|
|
4025
4070
|
// @ts-ignore
|
|
4026
4071
|
return navAny.userAgentData && navAny.userAgentData.mobile;
|
|
4027
4072
|
}
|
|
4028
|
-
return /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a) ||
|
|
4029
|
-
// tslint:disable-next-line:max-line-length
|
|
4030
|
-
/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4));
|
|
4073
|
+
return /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4));
|
|
4031
4074
|
}
|
|
4032
4075
|
return false;
|
|
4033
4076
|
}
|
|
@@ -4076,37 +4119,39 @@ var IdCaptureModelsContext = /*#__PURE__*/createContext({
|
|
|
4076
4119
|
});
|
|
4077
4120
|
function IdCaptureModelsProviderInner(_a) {
|
|
4078
4121
|
var children = _a.children,
|
|
4079
|
-
onModelError = _a.onModelError
|
|
4080
|
-
|
|
4081
|
-
|
|
4082
|
-
|
|
4083
|
-
|
|
4084
|
-
|
|
4085
|
-
|
|
4086
|
-
|
|
4087
|
-
|
|
4088
|
-
|
|
4089
|
-
|
|
4090
|
-
|
|
4091
|
-
|
|
4092
|
-
|
|
4093
|
-
|
|
4094
|
-
|
|
4095
|
-
|
|
4096
|
-
|
|
4097
|
-
|
|
4098
|
-
|
|
4099
|
-
|
|
4100
|
-
|
|
4101
|
-
|
|
4122
|
+
onModelError = _a.onModelError,
|
|
4123
|
+
_b = _a.allowSinglePageIdCapture,
|
|
4124
|
+
allowSinglePageIdCapture = _b === void 0 ? false : _b;
|
|
4125
|
+
var _c = useContext(DocumentDetectionModelContext),
|
|
4126
|
+
documentDetectionModelReady = _c.documentDetectionModelReady,
|
|
4127
|
+
documentDetectionModelDownloadProgress = _c.documentDetectionModelDownloadProgress,
|
|
4128
|
+
startDocumentDetection = _c.startDocumentDetection,
|
|
4129
|
+
stopDocumentDetection = _c.stopDocumentDetection,
|
|
4130
|
+
lastPredictionCanvas = _c.documentDetectionLastPredictionCanvas,
|
|
4131
|
+
clearDocumentDetectionLastPredictionCanvas = _c.clearDocumentDetectionLastPredictionCanvas,
|
|
4132
|
+
onDocumentDetected = _c.onDocumentDetected,
|
|
4133
|
+
detectionTime = _c.detectionTime,
|
|
4134
|
+
documentDetectionThresholds = _c.documentDetectionThresholds,
|
|
4135
|
+
setDocumentDetectionThresholds = _c.setDocumentDetectionThresholds,
|
|
4136
|
+
documentDetectionBoundaries = _c.documentDetectionBoundaries,
|
|
4137
|
+
setDocumentDetectionBoundaries = _c.setDocumentDetectionBoundaries,
|
|
4138
|
+
documentDetectionModelError = _c.documentDetectionModelError;
|
|
4139
|
+
var _d = useContext(FocusModelContext),
|
|
4140
|
+
focusModelReady = _d.focusModelReady,
|
|
4141
|
+
focusModelDownloadProgress = _d.focusModelDownloadProgress,
|
|
4142
|
+
makeFocusPrediction = _d.makeFocusPrediction,
|
|
4143
|
+
focusThresholds = _d.focusThresholds,
|
|
4144
|
+
setFocusThresholds = _d.setFocusThresholds,
|
|
4145
|
+
focusPredictionTime = _d.focusPredictionTime,
|
|
4146
|
+
focusModelError = _d.focusModelError;
|
|
4102
4147
|
var onPredictionHandler = useRef();
|
|
4103
4148
|
var bestFrameDetails = useRef(null);
|
|
4104
4149
|
var bestPredictionCanvas = useRef(null);
|
|
4105
4150
|
var bestFocusScore = useRef(0);
|
|
4106
4151
|
var stopDetection = useRef(0);
|
|
4107
|
-
var
|
|
4108
|
-
requiredDocumentType =
|
|
4109
|
-
setRequiredDocumentType =
|
|
4152
|
+
var _e = useState('none'),
|
|
4153
|
+
requiredDocumentType = _e[0],
|
|
4154
|
+
setRequiredDocumentType = _e[1];
|
|
4110
4155
|
var thresholds = useMemo(function () {
|
|
4111
4156
|
return _assign(_assign({}, documentDetectionThresholds), {
|
|
4112
4157
|
focus: focusThresholds
|
|
@@ -4124,34 +4169,42 @@ function IdCaptureModelsProviderInner(_a) {
|
|
|
4124
4169
|
var _this = this;
|
|
4125
4170
|
onDocumentDetected(function (prediction) {
|
|
4126
4171
|
return __awaiter(_this, void 0, void 0, function () {
|
|
4127
|
-
var stopDetectionAtStart, focusPredictionTime, focusScore, focusThresholdMet, isRequiredDocumentType, focusPrediction, focusThresholdSet, focusThreshold;
|
|
4128
|
-
var _a, _b, _c, _d, _e, _f;
|
|
4129
|
-
return __generator(this, function (
|
|
4172
|
+
var stopDetectionAtStart, focusPredictionTime, focusScore, focusThresholdMet, isSinglePage, isRequiredDocumentType, focusPrediction, focusThresholdSet, focusThreshold;
|
|
4173
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
4174
|
+
return __generator(this, function (_h) {
|
|
4130
4175
|
if (!lastPredictionCanvas.current) return [2 /*return*/];
|
|
4131
4176
|
stopDetectionAtStart = stopDetection.current;
|
|
4132
4177
|
focusPredictionTime = 0, focusScore = 0, focusThresholdMet = false;
|
|
4133
|
-
|
|
4178
|
+
isSinglePage = prediction.detectedDocumentType === 'singlePage';
|
|
4179
|
+
if (!allowSinglePageIdCapture && isSinglePage) {
|
|
4180
|
+
prediction.detectedDocumentType = 'passport';
|
|
4181
|
+
prediction.passportDetectionScore = prediction.singlePageDetectionScore;
|
|
4182
|
+
prediction.passportDetectionThresholdMet = prediction.singlePageDetectionThresholdMet;
|
|
4183
|
+
prediction.singlePageDetectionScore = 0;
|
|
4184
|
+
prediction.singlePageDetectionThresholdMet = false;
|
|
4185
|
+
}
|
|
4186
|
+
isRequiredDocumentType = requiredDocumentType === 'none' || prediction.detectedDocumentType === requiredDocumentType || ((_a = requiredDocumentType.includes) === null || _a === void 0 ? void 0 : _a.call(requiredDocumentType, prediction.detectedDocumentType)) || allowSinglePageIdCapture && isSinglePage && ((_b = requiredDocumentType.includes) === null || _b === void 0 ? void 0 : _b.call(requiredDocumentType, 'idCardFront'));
|
|
4134
4187
|
if (isRequiredDocumentType && prediction.detectedDocumentType !== 'none' && prediction.detectionThresholdMet && prediction.documentInBounds && !prediction.documentTooClose && prediction.documentIsStable) {
|
|
4135
|
-
focusPrediction = makeFocusPrediction(lastPredictionCanvas.current, (
|
|
4188
|
+
focusPrediction = makeFocusPrediction(lastPredictionCanvas.current, (_c = prediction.bestDocument) === null || _c === void 0 ? void 0 : _c.box);
|
|
4136
4189
|
if (focusPrediction) {
|
|
4137
4190
|
focusScore = focusPrediction.score;
|
|
4138
4191
|
focusPredictionTime = focusPrediction.predictionTime;
|
|
4139
4192
|
}
|
|
4140
|
-
focusThresholdSet = (
|
|
4141
|
-
focusThreshold = (
|
|
4193
|
+
focusThresholdSet = (_d = thresholds.focus) === null || _d === void 0 ? void 0 : _d[prediction.detectedDocumentType];
|
|
4194
|
+
focusThreshold = (_e = onMobile ? focusThresholdSet === null || focusThresholdSet === void 0 ? void 0 : focusThresholdSet.mobile : focusThresholdSet === null || focusThresholdSet === void 0 ? void 0 : focusThresholdSet.desktop) !== null && _e !== void 0 ? _e : 0;
|
|
4142
4195
|
focusThresholdMet = focusScore >= focusThreshold;
|
|
4143
4196
|
if (bestFocusScore.current <= focusScore && stopDetectionAtStart === stopDetection.current) {
|
|
4144
4197
|
bestFocusScore.current = focusScore;
|
|
4145
4198
|
drawToCanvas(bestPredictionCanvas.current, lastPredictionCanvas.current);
|
|
4146
4199
|
bestFrameDetails.current = {
|
|
4147
|
-
boundingBox: (
|
|
4200
|
+
boundingBox: (_f = prediction.bestDocument) === null || _f === void 0 ? void 0 : _f.box,
|
|
4148
4201
|
documentType: prediction.detectedDocumentType,
|
|
4149
4202
|
detectionScore: prediction.detectionScore,
|
|
4150
4203
|
focusScore: focusScore
|
|
4151
4204
|
};
|
|
4152
4205
|
}
|
|
4153
4206
|
}
|
|
4154
|
-
(
|
|
4207
|
+
(_g = onPredictionHandler.current) === null || _g === void 0 ? void 0 : _g.call(onPredictionHandler, _assign(_assign({}, prediction), {
|
|
4155
4208
|
focusScore: focusScore,
|
|
4156
4209
|
focusPredictionTime: focusPredictionTime,
|
|
4157
4210
|
focusThresholdMet: focusThresholdMet
|
|
@@ -4160,10 +4213,10 @@ function IdCaptureModelsProviderInner(_a) {
|
|
|
4160
4213
|
});
|
|
4161
4214
|
});
|
|
4162
4215
|
});
|
|
4163
|
-
}, [lastPredictionCanvas, makeFocusPrediction, onDocumentDetected, requiredDocumentType, thresholds.focus]);
|
|
4216
|
+
}, [allowSinglePageIdCapture, lastPredictionCanvas, makeFocusPrediction, onDocumentDetected, requiredDocumentType, thresholds.focus]);
|
|
4164
4217
|
var modelError = documentDetectionModelError !== null && documentDetectionModelError !== void 0 ? documentDetectionModelError : focusModelError;
|
|
4165
4218
|
useEffect(function handleModelErrors() {
|
|
4166
|
-
modelError
|
|
4219
|
+
if (modelError) onModelError === null || onModelError === void 0 ? void 0 : onModelError(modelError);
|
|
4167
4220
|
}, [modelError, onModelError]);
|
|
4168
4221
|
var onPredictionMade = useCallback(function (handler) {
|
|
4169
4222
|
onPredictionHandler.current = handler;
|
|
@@ -4174,9 +4227,9 @@ function IdCaptureModelsProviderInner(_a) {
|
|
|
4174
4227
|
canvas: bestPredictionCanvas.current
|
|
4175
4228
|
});
|
|
4176
4229
|
}, []);
|
|
4177
|
-
var
|
|
4178
|
-
canvasKey =
|
|
4179
|
-
setCanvasKey =
|
|
4230
|
+
var _f = useState(0),
|
|
4231
|
+
canvasKey = _f[0],
|
|
4232
|
+
setCanvasKey = _f[1];
|
|
4180
4233
|
var resetBestFrame = useCallback(function () {
|
|
4181
4234
|
stopDetection.current += 1;
|
|
4182
4235
|
setCanvasKey(function (n) {
|
|
@@ -4187,7 +4240,7 @@ function IdCaptureModelsProviderInner(_a) {
|
|
|
4187
4240
|
bestFocusScore.current = 0;
|
|
4188
4241
|
}, [clearDocumentDetectionLastPredictionCanvas]);
|
|
4189
4242
|
useEffect(function () {
|
|
4190
|
-
requiredDocumentType
|
|
4243
|
+
if (requiredDocumentType) resetBestFrame();
|
|
4191
4244
|
}, [requiredDocumentType, resetBestFrame]);
|
|
4192
4245
|
var value = useMemo(function () {
|
|
4193
4246
|
return {
|
|
@@ -4223,9 +4276,9 @@ function IdCaptureModelsProvider(_a) {
|
|
|
4223
4276
|
return /*#__PURE__*/React__default.createElement(DocumentDetectionModelProvider, _assign({}, props), /*#__PURE__*/React__default.createElement(FocusModelProvider, _assign({}, props), /*#__PURE__*/React__default.createElement(IdCaptureModelsProviderInner, _assign({}, props), children)));
|
|
4224
4277
|
}
|
|
4225
4278
|
|
|
4226
|
-
var CapturedDocumentTypeValues = ['idCardFront', 'idCardBack', 'passport', 'selfie'];
|
|
4279
|
+
var CapturedDocumentTypeValues = ['idCardFront', 'idCardBack', 'passport', 'singlePage', 'selfie'];
|
|
4227
4280
|
|
|
4228
|
-
var
|
|
4281
|
+
var acceptedDocumentTypesForIdCaptureRequirementOption = {
|
|
4229
4282
|
idCardFront: ['idCardFront'],
|
|
4230
4283
|
idCardBack: ['idCardBack'],
|
|
4231
4284
|
passport: ['passport'],
|
|
@@ -4233,13 +4286,31 @@ var requiredDocumentsForOption = {
|
|
|
4233
4286
|
idCardAndPassport: ['idCardFront', 'idCardBack', 'passport'],
|
|
4234
4287
|
idCardOrPassport: ['idCardFront', 'idCardBack', 'passport'] // this one is so weird
|
|
4235
4288
|
};
|
|
4236
|
-
function
|
|
4289
|
+
function minImageCountForIdCaptureRequirementOption(idCaptureRequirement) {
|
|
4237
4290
|
if (idCaptureRequirement === 'idCardOrPassport') return 1;
|
|
4238
|
-
return
|
|
4291
|
+
return acceptedDocumentTypesForIdCaptureRequirementOption[idCaptureRequirement].length;
|
|
4239
4292
|
}
|
|
4240
|
-
function
|
|
4293
|
+
function maxImageCountForIdCaptureRequirementOption(idCaptureRequirement) {
|
|
4241
4294
|
if (idCaptureRequirement === 'idCardOrPassport') return 2;
|
|
4242
|
-
return
|
|
4295
|
+
return minImageCountForIdCaptureRequirementOption(idCaptureRequirement);
|
|
4296
|
+
}
|
|
4297
|
+
function remainingIdCaptureRequirements(captureRequirement, capturedDocuments, requestedDocumentType) {
|
|
4298
|
+
var isIdCardOrPassport = captureRequirement === 'idCardOrPassport';
|
|
4299
|
+
if (isIdCardOrPassport && requestedDocumentType === 'passport') return [];
|
|
4300
|
+
var acceptedTypes = acceptedDocumentTypesForIdCaptureRequirementOption[captureRequirement];
|
|
4301
|
+
if (captureRequirement.includes('idCard') && 'singlePage' in capturedDocuments) {
|
|
4302
|
+
acceptedTypes = acceptedTypes.filter(function (v) {
|
|
4303
|
+
return !v.includes('idCard');
|
|
4304
|
+
});
|
|
4305
|
+
}
|
|
4306
|
+
if (isIdCardOrPassport) {
|
|
4307
|
+
acceptedTypes = acceptedTypes.filter(function (v) {
|
|
4308
|
+
return v !== 'passport';
|
|
4309
|
+
});
|
|
4310
|
+
}
|
|
4311
|
+
return acceptedTypes.filter(function (v) {
|
|
4312
|
+
return !(v in capturedDocuments);
|
|
4313
|
+
});
|
|
4243
4314
|
}
|
|
4244
4315
|
|
|
4245
4316
|
var initialState$4 = {
|
|
@@ -4278,6 +4349,8 @@ var initialState$4 = {
|
|
|
4278
4349
|
idCardBackDetectionThresholdMet: false,
|
|
4279
4350
|
passportDetectionScore: 0,
|
|
4280
4351
|
passportDetectionThresholdMet: false,
|
|
4352
|
+
singlePageDetectionScore: 0,
|
|
4353
|
+
singlePageDetectionThresholdMet: false,
|
|
4281
4354
|
focusScore: 0,
|
|
4282
4355
|
focusThresholdMet: false,
|
|
4283
4356
|
isGoodFrame: false,
|
|
@@ -4293,6 +4366,7 @@ var initialState$4 = {
|
|
|
4293
4366
|
capturedDocuments: {},
|
|
4294
4367
|
captureRequirement: 'idCardOrPassport',
|
|
4295
4368
|
requestedDocumentType: 'idCardFront',
|
|
4369
|
+
allowSinglePageIdCapture: false,
|
|
4296
4370
|
allowIdCardBackToFrontCapture: false,
|
|
4297
4371
|
operationStartedAt: null,
|
|
4298
4372
|
captureStartedAt: null
|
|
@@ -4307,11 +4381,13 @@ var _reducer = function reducer(state, action) {
|
|
|
4307
4381
|
var _c = action.payload,
|
|
4308
4382
|
captureRequirement = _c.captureRequirement,
|
|
4309
4383
|
precapturedDocuments = _c.precapturedDocuments,
|
|
4384
|
+
allowSinglePageIdCapture = _c.allowSinglePageIdCapture,
|
|
4310
4385
|
allowIdCardBackToFrontCapture = _c.allowIdCardBackToFrontCapture,
|
|
4311
4386
|
enableOverrideWrongDocumentTypeDialog = _c.enableOverrideWrongDocumentTypeDialog,
|
|
4312
4387
|
allowOverrideWrongDocumentTypeAfterMs = _c.allowOverrideWrongDocumentTypeAfterMs;
|
|
4313
4388
|
var newState = _assign(_assign({}, state), {
|
|
4314
4389
|
captureRequirement: captureRequirement,
|
|
4390
|
+
allowSinglePageIdCapture: allowSinglePageIdCapture !== null && allowSinglePageIdCapture !== void 0 ? allowSinglePageIdCapture : false,
|
|
4315
4391
|
allowIdCardBackToFrontCapture: allowIdCardBackToFrontCapture !== null && allowIdCardBackToFrontCapture !== void 0 ? allowIdCardBackToFrontCapture : false,
|
|
4316
4392
|
enableOverrideWrongDocumentTypeDialog: enableOverrideWrongDocumentTypeDialog,
|
|
4317
4393
|
allowOverrideWrongDocumentTypeAfterMs: allowOverrideWrongDocumentTypeAfterMs
|
|
@@ -4379,6 +4455,8 @@ var _reducer = function reducer(state, action) {
|
|
|
4379
4455
|
idCardBackDetectionThresholdMet = _d.idCardBackDetectionThresholdMet,
|
|
4380
4456
|
passportDetectionScore = _d.passportDetectionScore,
|
|
4381
4457
|
passportDetectionThresholdMet = _d.passportDetectionThresholdMet,
|
|
4458
|
+
singlePageDetectionScore = _d.singlePageDetectionScore,
|
|
4459
|
+
singlePageDetectionThresholdMet = _d.singlePageDetectionThresholdMet,
|
|
4382
4460
|
bestDocument = _d.bestDocument,
|
|
4383
4461
|
documentInBounds = _d.documentInBounds,
|
|
4384
4462
|
documentTooClose = _d.documentTooClose,
|
|
@@ -4399,7 +4477,8 @@ var _reducer = function reducer(state, action) {
|
|
|
4399
4477
|
}
|
|
4400
4478
|
}
|
|
4401
4479
|
}
|
|
4402
|
-
var
|
|
4480
|
+
var idCardDetected = detectedDocumentType.includes('idCard') || detectedDocumentType === 'singlePage';
|
|
4481
|
+
var idCardDetectedButNotAllowed = idCardDetected && !state.captureRequirement.includes('idCard');
|
|
4403
4482
|
var passportNotAllowed = !state.captureRequirement.toLowerCase().includes('passport');
|
|
4404
4483
|
var idCardFrontWasCaptured = 'idCardFront' in state.capturedDocuments;
|
|
4405
4484
|
var idCardBackWasCaptured = 'idCardBack' in state.capturedDocuments;
|
|
@@ -4459,6 +4538,8 @@ var _reducer = function reducer(state, action) {
|
|
|
4459
4538
|
idCardBackDetectionThresholdMet: idCardBackDetectionThresholdMet,
|
|
4460
4539
|
passportDetectionScore: passportDetectionScore,
|
|
4461
4540
|
passportDetectionThresholdMet: passportDetectionThresholdMet,
|
|
4541
|
+
singlePageDetectionScore: singlePageDetectionScore,
|
|
4542
|
+
singlePageDetectionThresholdMet: singlePageDetectionThresholdMet,
|
|
4462
4543
|
focusScore: focusScore,
|
|
4463
4544
|
focusThresholdMet: focusThresholdMet,
|
|
4464
4545
|
isGoodFrame: isGoodFrame,
|
|
@@ -4496,7 +4577,7 @@ var _reducer = function reducer(state, action) {
|
|
|
4496
4577
|
});
|
|
4497
4578
|
case 'documentCaptured':
|
|
4498
4579
|
{
|
|
4499
|
-
var
|
|
4580
|
+
var newState = _assign(_assign({}, state), {
|
|
4500
4581
|
capturing: false,
|
|
4501
4582
|
captureFailed: false,
|
|
4502
4583
|
allowOverrideFlipRequirement: false,
|
|
@@ -4505,64 +4586,42 @@ var _reducer = function reducer(state, action) {
|
|
|
4505
4586
|
wrongDocumentTypePredictions: 0,
|
|
4506
4587
|
capturedDocuments: _assign(_assign({}, state.capturedDocuments), (_a = {}, _a[action.payload.documentType] = action.payload, _a))
|
|
4507
4588
|
});
|
|
4508
|
-
var remainingRequirements =
|
|
4509
|
-
return !(v in newState_1.capturedDocuments);
|
|
4510
|
-
});
|
|
4511
|
-
if (state.captureRequirement === 'idCardOrPassport') {
|
|
4512
|
-
if (state.requestedDocumentType === 'passport') {
|
|
4513
|
-
remainingRequirements = [];
|
|
4514
|
-
} else {
|
|
4515
|
-
remainingRequirements = remainingRequirements.filter(function (v) {
|
|
4516
|
-
return v !== 'passport';
|
|
4517
|
-
});
|
|
4518
|
-
}
|
|
4519
|
-
}
|
|
4589
|
+
var remainingRequirements = remainingIdCaptureRequirements(state.captureRequirement, newState.capturedDocuments, state.requestedDocumentType);
|
|
4520
4590
|
if (remainingRequirements.length === 0) {
|
|
4521
|
-
|
|
4591
|
+
newState.captureState = 'complete';
|
|
4522
4592
|
} else {
|
|
4523
|
-
|
|
4524
|
-
if (state.requestedDocumentType === 'idCardFront' &&
|
|
4525
|
-
|
|
4526
|
-
|
|
4527
|
-
|
|
4528
|
-
|
|
4529
|
-
|
|
4593
|
+
newState.requestedDocumentType = remainingRequirements[0];
|
|
4594
|
+
if (state.requestedDocumentType === 'idCardFront' && newState.requestedDocumentType === 'idCardBack' || state.requestedDocumentType === 'idCardBack' && newState.requestedDocumentType === 'idCardFront') {
|
|
4595
|
+
newState.captureState = 'requestingFlip';
|
|
4596
|
+
newState.idCardFrontDetectionThresholdMet = false;
|
|
4597
|
+
newState.idCardBackDetectionThresholdMet = false;
|
|
4598
|
+
newState.passportDetectionThresholdMet = false;
|
|
4599
|
+
newState.wrongDocumentTypePredictions = 0;
|
|
4530
4600
|
}
|
|
4531
4601
|
}
|
|
4532
|
-
return
|
|
4602
|
+
return newState;
|
|
4533
4603
|
}
|
|
4534
4604
|
case 'documentCapturedManually':
|
|
4535
4605
|
{
|
|
4536
|
-
var
|
|
4606
|
+
var newState = _assign(_assign({}, state), {
|
|
4537
4607
|
capturedDocuments: _assign(_assign({}, state.capturedDocuments), (_b = {}, _b[state.requestedDocumentType] = _assign(_assign({}, action.payload), {
|
|
4538
4608
|
width: 0,
|
|
4539
4609
|
height: 0
|
|
4540
4610
|
}), _b))
|
|
4541
4611
|
});
|
|
4542
|
-
var remainingRequirements =
|
|
4543
|
-
return !(v in newState_2.capturedDocuments);
|
|
4544
|
-
});
|
|
4545
|
-
if (state.captureRequirement === 'idCardOrPassport') {
|
|
4546
|
-
if (state.requestedDocumentType === 'passport') {
|
|
4547
|
-
remainingRequirements = [];
|
|
4548
|
-
} else {
|
|
4549
|
-
remainingRequirements = remainingRequirements.filter(function (v) {
|
|
4550
|
-
return v !== 'passport';
|
|
4551
|
-
});
|
|
4552
|
-
}
|
|
4553
|
-
}
|
|
4612
|
+
var remainingRequirements = remainingIdCaptureRequirements(state.captureRequirement, newState.capturedDocuments, state.requestedDocumentType);
|
|
4554
4613
|
if (remainingRequirements.length === 0) {
|
|
4555
|
-
|
|
4614
|
+
newState.captureState = 'complete';
|
|
4556
4615
|
} else {
|
|
4557
|
-
|
|
4558
|
-
if (state.requestedDocumentType === 'idCardFront' &&
|
|
4559
|
-
|
|
4560
|
-
|
|
4561
|
-
|
|
4562
|
-
|
|
4616
|
+
newState.requestedDocumentType = remainingRequirements[0];
|
|
4617
|
+
if (state.requestedDocumentType === 'idCardFront' && newState.requestedDocumentType === 'idCardBack' || state.requestedDocumentType === 'idCardBack' && newState.requestedDocumentType === 'idCardFront') {
|
|
4618
|
+
newState.captureState = 'requestingFlip';
|
|
4619
|
+
newState.idCardFrontDetectionThresholdMet = false;
|
|
4620
|
+
newState.idCardBackDetectionThresholdMet = false;
|
|
4621
|
+
newState.passportDetectionThresholdMet = false;
|
|
4563
4622
|
}
|
|
4564
4623
|
}
|
|
4565
|
-
return
|
|
4624
|
+
return newState;
|
|
4566
4625
|
}
|
|
4567
4626
|
case 'flipRequestCompleted':
|
|
4568
4627
|
return _assign(_assign({}, state), {
|
|
@@ -5163,7 +5222,7 @@ var IdCapture = function IdCapture(_a) {
|
|
|
5163
5222
|
imageUrl: imageUrl
|
|
5164
5223
|
}
|
|
5165
5224
|
});
|
|
5166
|
-
var capturedDocumentType = documentType
|
|
5225
|
+
var capturedDocumentType = documentType;
|
|
5167
5226
|
setTimeout(function () {
|
|
5168
5227
|
var _a;
|
|
5169
5228
|
var captureTime = new Date().getTime() - ((_a = state.captureStartedAt) !== null && _a !== void 0 ? _a : new Date()).getTime();
|
|
@@ -5230,7 +5289,7 @@ var IdCapture = function IdCapture(_a) {
|
|
|
5230
5289
|
scaling: debugScalingDetails,
|
|
5231
5290
|
flipX: !isRearFacing
|
|
5232
5291
|
});
|
|
5233
|
-
}))), debugMode && ( /*#__PURE__*/React__default.createElement(DebugStatsPane, null, camera ? ( /*#__PURE__*/React__default.createElement(React__default.Fragment, null, "\u2705 Camera: ", camera.label, " (", camera.width, "x", camera.height, ")")) : '❌ Camera not ready', /*#__PURE__*/React__default.createElement("br", null), state.frameCaptureRate > 0.75 ? '✅' : '👎', " Frame Rate:", ' ', Math.round((state.frameCaptureRate + Number.EPSILON) * 1000) / 1000, ' ', "fps (", detectionTime, "ms doc detect, ", focusPredictionTime, "ms focus)", /*#__PURE__*/React__default.createElement("br", null), modelsReady ? ( /*#__PURE__*/React__default.createElement(React__default.Fragment, null, state.detectionThresholdMet ? '✅' : '❌', " Detected Document Type: ", state.detectedDocumentType, /*#__PURE__*/React__default.createElement("br", null), state.idCardFrontDetectionThresholdMet ? '✅' : '❌', " ID Card Front Score: ", state.idCardFrontDetectionScore.toFixed(3), /*#__PURE__*/React__default.createElement("br", null), state.idCardBackDetectionThresholdMet ? '✅' : '❌', " ID Card Back Score: ", state.idCardBackDetectionScore.toFixed(3), /*#__PURE__*/React__default.createElement("br", null), state.passportDetectionThresholdMet ? '✅' : '❌', " Passport Score: ", state.passportDetectionScore.toFixed(3), /*#__PURE__*/React__default.createElement("br", null), state.focusThresholdMet ? '✅' : '❌', " Focus Score:", ' ', state.focusScore.toFixed(3), /*#__PURE__*/React__default.createElement("br", null), state.documentInBounds ? '✅' : '❌', " Document In Bounds", /*#__PURE__*/React__default.createElement("br", null), state.documentIsStable ? '✅' : '❌', " Document Is Stable", /*#__PURE__*/React__default.createElement("br", null), state.goodFramesThresholdMet ? '✅' : '❌', " Good Frame Count:", ' ', state.goodFramesCount, "/", state.goodFramesThreshold)) : ( /*#__PURE__*/React__default.createElement(React__default.Fragment, null, "\u274C Models not ready")))));
|
|
5292
|
+
}))), debugMode && ( /*#__PURE__*/React__default.createElement(DebugStatsPane, null, camera ? ( /*#__PURE__*/React__default.createElement(React__default.Fragment, null, "\u2705 Camera: ", camera.label, " (", camera.width, "x", camera.height, ")")) : '❌ Camera not ready', /*#__PURE__*/React__default.createElement("br", null), state.frameCaptureRate > 0.75 ? '✅' : '👎', " Frame Rate:", ' ', Math.round((state.frameCaptureRate + Number.EPSILON) * 1000) / 1000, ' ', "fps (", detectionTime, "ms doc detect, ", focusPredictionTime, "ms focus)", /*#__PURE__*/React__default.createElement("br", null), modelsReady ? ( /*#__PURE__*/React__default.createElement(React__default.Fragment, null, state.detectionThresholdMet ? '✅' : '❌', " Detected Document Type: ", state.detectedDocumentType, /*#__PURE__*/React__default.createElement("br", null), state.idCardFrontDetectionThresholdMet ? '✅' : '❌', " ID Card Front Score: ", state.idCardFrontDetectionScore.toFixed(3), /*#__PURE__*/React__default.createElement("br", null), state.idCardBackDetectionThresholdMet ? '✅' : '❌', " ID Card Back Score: ", state.idCardBackDetectionScore.toFixed(3), /*#__PURE__*/React__default.createElement("br", null), state.passportDetectionThresholdMet ? '✅' : '❌', " Passport Score: ", state.passportDetectionScore.toFixed(3), /*#__PURE__*/React__default.createElement("br", null), state.singlePageDetectionThresholdMet ? '✅' : '❌', " Single Page Score: ", state.singlePageDetectionScore.toFixed(3), /*#__PURE__*/React__default.createElement("br", null), state.focusThresholdMet ? '✅' : '❌', " Focus Score:", ' ', state.focusScore.toFixed(3), /*#__PURE__*/React__default.createElement("br", null), state.documentInBounds ? '✅' : '❌', " Document In Bounds", /*#__PURE__*/React__default.createElement("br", null), state.documentIsStable ? '✅' : '❌', " Document Is Stable", /*#__PURE__*/React__default.createElement("br", null), state.goodFramesThresholdMet ? '✅' : '❌', " Good Frame Count:", ' ', state.goodFramesCount, "/", state.goodFramesThreshold)) : ( /*#__PURE__*/React__default.createElement(React__default.Fragment, null, "\u274C Models not ready")))));
|
|
5234
5293
|
};
|
|
5235
5294
|
var timeSince = function timeSince(t) {
|
|
5236
5295
|
if (!t) return 0;
|
|
@@ -6269,15 +6328,8 @@ var IdCaptureSuccess = function IdCaptureSuccess(_a) {
|
|
|
6269
6328
|
_e = _a.debugMode,
|
|
6270
6329
|
debugMode = _e === void 0 ? false : _e;
|
|
6271
6330
|
var submissionStatus = useContext(SubmissionContext).submissionStatus;
|
|
6272
|
-
var idCardFront = capturedDocuments.idCardFront,
|
|
6273
|
-
idCardBack = capturedDocuments.idCardBack,
|
|
6274
|
-
passport = capturedDocuments.passport;
|
|
6275
6331
|
var verbiage = useTranslations(rawVerbiage, {
|
|
6276
6332
|
headingText: 'ID Capture Successful',
|
|
6277
|
-
idCardFrontText: 'ID Card Front',
|
|
6278
|
-
idCardBackText: 'ID Card Back',
|
|
6279
|
-
passportText: 'Passport',
|
|
6280
|
-
instructionText: 'Verify the entire ID was captured clearly with no glare.',
|
|
6281
6333
|
retryText: 'Retry',
|
|
6282
6334
|
submittingText: 'Submitting...',
|
|
6283
6335
|
submitText: 'Done'
|
|
@@ -6294,25 +6346,16 @@ var IdCaptureSuccess = function IdCaptureSuccess(_a) {
|
|
|
6294
6346
|
className: classNames.imageContainer
|
|
6295
6347
|
}, /*#__PURE__*/React__default.createElement(ImageRow, {
|
|
6296
6348
|
className: classNames.imageRow
|
|
6297
|
-
},
|
|
6298
|
-
|
|
6299
|
-
|
|
6300
|
-
|
|
6301
|
-
|
|
6302
|
-
|
|
6303
|
-
|
|
6304
|
-
|
|
6305
|
-
|
|
6306
|
-
|
|
6307
|
-
className: classNames.image,
|
|
6308
|
-
alt: verbiage.idCardBackText
|
|
6309
|
-
}), debugMode && ( /*#__PURE__*/React__default.createElement(DebugPre, null, "Detection Score: ".concat(idCardBack.detectionScore, "\nFocus Score: ").concat(idCardBack.focusScore, "\nBounding Box: ").concat(JSON.stringify(idCardBack.boundingBox)))))), passport && ( /*#__PURE__*/React__default.createElement(ImageCol$1, {
|
|
6310
|
-
className: classNames.imageCol
|
|
6311
|
-
}, /*#__PURE__*/React__default.createElement(StyledImage, {
|
|
6312
|
-
image: passport,
|
|
6313
|
-
className: classNames.image,
|
|
6314
|
-
alt: verbiage.passportText
|
|
6315
|
-
}), debugMode && ( /*#__PURE__*/React__default.createElement(DebugPre, null, "Detection Score: ".concat(passport.detectionScore, "\nFocus Score: ").concat(passport.focusScore, "\nBounding Box: ").concat(JSON.stringify(passport.boundingBox)))))))), /*#__PURE__*/React__default.createElement(ButtonsColumn, {
|
|
6349
|
+
}, Object.values(capturedDocuments).map(function (doc) {
|
|
6350
|
+
return /*#__PURE__*/React__default.createElement(ImageCol$1, {
|
|
6351
|
+
className: classNames.imageCol,
|
|
6352
|
+
key: doc.imageData
|
|
6353
|
+
}, /*#__PURE__*/React__default.createElement(StyledImage, {
|
|
6354
|
+
image: doc,
|
|
6355
|
+
className: classNames.image,
|
|
6356
|
+
alt: doc.documentType
|
|
6357
|
+
}), debugMode && ( /*#__PURE__*/React__default.createElement(DebugPre, null, "Document Type: ".concat(doc.documentType, "\nDetection Score: ").concat(doc.detectionScore, "\nFocus Score: ").concat(doc.focusScore, "\nBounding Box: ").concat(JSON.stringify(doc.boundingBox)))));
|
|
6358
|
+
}))), /*#__PURE__*/React__default.createElement(ButtonsColumn, {
|
|
6316
6359
|
className: classNames.buttonsRow
|
|
6317
6360
|
}, /*#__PURE__*/React__default.createElement(WideButton, {
|
|
6318
6361
|
className: classNames.submitBtn,
|
|
@@ -6331,7 +6374,7 @@ var IdCaptureSuccess = function IdCaptureSuccess(_a) {
|
|
|
6331
6374
|
};
|
|
6332
6375
|
var Heading$a = styled.h1(templateObject_1$v || (templateObject_1$v = __makeTemplateObject(["\n font-size: 1.5rem;\n margin-top: 0;\n margin-bottom: 1.5rem;\n"], ["\n font-size: 1.5rem;\n margin-top: 0;\n margin-bottom: 1.5rem;\n"])));
|
|
6333
6376
|
var ImagesContainer = styled(OverlayImageContainer)(templateObject_2$q || (templateObject_2$q = __makeTemplateObject(["\n flex-grow: 1;\n overflow-y: auto;\n padding-bottom: 0;\n max-width: 100%;\n"], ["\n flex-grow: 1;\n overflow-y: auto;\n padding-bottom: 0;\n max-width: 100%;\n"])));
|
|
6334
|
-
var ImageRow = styled(OverlayImageRow)(templateObject_3$k || (templateObject_3$k = __makeTemplateObject(["\n max-width: 100%;\n flex-direction: column;\n display: grid;\n grid-gap: 12px;\n
|
|
6377
|
+
var ImageRow = styled(OverlayImageRow)(templateObject_3$k || (templateObject_3$k = __makeTemplateObject(["\n max-width: 100%;\n flex-direction: column;\n display: grid;\n grid-gap: 12px;\n"], ["\n max-width: 100%;\n flex-direction: column;\n display: grid;\n grid-gap: 12px;\n"])));
|
|
6335
6378
|
var ImageCol$1 = styled.div(templateObject_4$e || (templateObject_4$e = __makeTemplateObject(["\n width: 100%;\n max-height: none !important;\n"], ["\n width: 100%;\n max-height: none !important;\n"])));
|
|
6336
6379
|
var StyledImage = styled(CapturedDocumentImg)(templateObject_5$9 || (templateObject_5$9 = __makeTemplateObject(["\n width: 100%;\n border-radius: 12px;\n"], ["\n width: 100%;\n border-radius: 12px;\n"])));
|
|
6337
6380
|
var DebugPre = styled.pre(templateObject_6$7 || (templateObject_6$7 = __makeTemplateObject(["\n text-align: left;\n max-width: min(450px, 100dvw - 100px);\n overflow-x: auto;\n"], ["\n text-align: left;\n max-width: min(450px, 100dvw - 100px);\n overflow-x: auto;\n"])));
|
|
@@ -6915,7 +6958,7 @@ var IdCaptureGuideOverlay = function IdCaptureGuideOverlay(_a) {
|
|
|
6915
6958
|
});
|
|
6916
6959
|
}, [setDimensions, wrapperHeight, wrapperWidth]);
|
|
6917
6960
|
var padding = userSuppliedPadding !== null && userSuppliedPadding !== void 0 ? userSuppliedPadding : isMobile() ? (_g = (_f = (_e = theme.idCapture) === null || _e === void 0 ? void 0 : _e.guideBox) === null || _f === void 0 ? void 0 : _f.mobilePadding) !== null && _g !== void 0 ? _g : 0 : (_k = (_j = (_h = theme.idCapture) === null || _h === void 0 ? void 0 : _h.guideBox) === null || _j === void 0 ? void 0 : _j.desktopPadding) !== null && _k !== void 0 ? _k : 50;
|
|
6918
|
-
var paddingAndBorderPx = padding * 2 + borderWidth * 2;
|
|
6961
|
+
var paddingAndBorderPx = padding * 2 + (borderWidth !== null && borderWidth !== void 0 ? borderWidth : 0) * 2;
|
|
6919
6962
|
var images = useImagesWithBackToFront(userSuppliedImages, isBackToFront);
|
|
6920
6963
|
var imagesByUrl = useGuideImagesByUrl(images);
|
|
6921
6964
|
var orientation = getOrientation(portraitGuidesOnMobile);
|
|
@@ -6962,7 +7005,7 @@ var IdCaptureGuideOverlay = function IdCaptureGuideOverlay(_a) {
|
|
|
6962
7005
|
"$isMirrored": isMirrored,
|
|
6963
7006
|
className: classNames.centerRegion
|
|
6964
7007
|
}, /*#__PURE__*/React__default.createElement(GuideCenterBorder, {
|
|
6965
|
-
"$borderWidth": borderWidth,
|
|
7008
|
+
"$borderWidth": borderWidth !== null && borderWidth !== void 0 ? borderWidth : 0,
|
|
6966
7009
|
"$borderColor": borderColor,
|
|
6967
7010
|
"$padding": imagePadding,
|
|
6968
7011
|
className: classNames.centerRegionBorder
|
|
@@ -7162,7 +7205,7 @@ var IdCaptureFitGuide = function IdCaptureFitGuide(_a) {
|
|
|
7162
7205
|
}, [aspectRatio, borderColor, borderRadius, borderWidth, dispatch, maskColor, padding, redrawing, wrapperHeight, wrapperWidth]);
|
|
7163
7206
|
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(CanvasWrapper$1, {
|
|
7164
7207
|
ref: wrapperRef,
|
|
7165
|
-
"$maskColor": maskColor,
|
|
7208
|
+
"$maskColor": maskColor !== null && maskColor !== void 0 ? maskColor : '',
|
|
7166
7209
|
className: classNames.canvasWrapper
|
|
7167
7210
|
}, /*#__PURE__*/React__default.createElement(Canvas$1, {
|
|
7168
7211
|
ref: canvasRef,
|
|
@@ -7457,7 +7500,7 @@ var DocumentCaptureStateProvider = function DocumentCaptureStateProvider(_a) {
|
|
|
7457
7500
|
var uploadDocument = useContext(SubmissionContext).uploadDocument;
|
|
7458
7501
|
var uploadCapturedDocument = useCallback(function (content, filetype) {
|
|
7459
7502
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
7460
|
-
var documentId_1;
|
|
7503
|
+
var documentId_1, e_1;
|
|
7461
7504
|
return __generator(this, function (_a) {
|
|
7462
7505
|
switch (_a.label) {
|
|
7463
7506
|
case 0:
|
|
@@ -7480,7 +7523,8 @@ var DocumentCaptureStateProvider = function DocumentCaptureStateProvider(_a) {
|
|
|
7480
7523
|
}, 0);
|
|
7481
7524
|
return [3 /*break*/, 3];
|
|
7482
7525
|
case 2:
|
|
7483
|
-
_a.sent();
|
|
7526
|
+
e_1 = _a.sent();
|
|
7527
|
+
debug('upload failed', e_1);
|
|
7484
7528
|
dispatch({
|
|
7485
7529
|
type: 'uploadFailed'
|
|
7486
7530
|
});
|
|
@@ -7515,7 +7559,7 @@ var DocumentCaptureStateProvider = function DocumentCaptureStateProvider(_a) {
|
|
|
7515
7559
|
resolvedDocuments.forEach(function (d) {
|
|
7516
7560
|
if (d.content) {
|
|
7517
7561
|
d.contentUrl || (d.contentUrl = URL.createObjectURL(d.content));
|
|
7518
|
-
uploadCapturedDocument(d.content, d.content.type);
|
|
7562
|
+
void uploadCapturedDocument(d.content, d.content.type);
|
|
7519
7563
|
}
|
|
7520
7564
|
});
|
|
7521
7565
|
}, [aspectRatio, cameraFeedMode, documents, instructions, uploadCapturedDocument]);
|
|
@@ -7713,6 +7757,7 @@ var CameraVideoTag = function CameraVideoTag(props) {
|
|
|
7713
7757
|
useEffect(function attachCameraStreamToVideoTagWhenReady() {
|
|
7714
7758
|
if (videoRef.current && videoStream) {
|
|
7715
7759
|
debug('attaching camera stream to video tag');
|
|
7760
|
+
// eslint-disable-next-line react-compiler/react-compiler
|
|
7716
7761
|
videoRef.current.srcObject = videoStream;
|
|
7717
7762
|
}
|
|
7718
7763
|
}, [videoStream, videoRef]);
|
|
@@ -8039,8 +8084,8 @@ var IdCaptureFallback = function IdCaptureFallback(_a) {
|
|
|
8039
8084
|
var _j = useState(silentFallback),
|
|
8040
8085
|
useFallback = _j[0],
|
|
8041
8086
|
setUseFallback = _j[1];
|
|
8042
|
-
var
|
|
8043
|
-
var
|
|
8087
|
+
var minImageCount = minImageCountForIdCaptureRequirementOption(idCaptureRequirement);
|
|
8088
|
+
var maxImageCount = maxImageCountForIdCaptureRequirementOption(idCaptureRequirement);
|
|
8044
8089
|
var _k = useFileState(),
|
|
8045
8090
|
rawFile = _k.rawFile,
|
|
8046
8091
|
fileInputOnChange = _k.fileInputOnChange;
|
|
@@ -8053,7 +8098,7 @@ var IdCaptureFallback = function IdCaptureFallback(_a) {
|
|
|
8053
8098
|
var whatToCapture = idCaptureRequirement === 'idCard' ? 'ID card' : idCaptureRequirement === 'passport' ? 'passport' : idCaptureRequirement === 'idCardOrPassport' ? 'ID card or passport' : 'ID card and passport';
|
|
8054
8099
|
var firstInstructionText = idCaptureRequirement === 'idCard' || idCaptureRequirement === 'idCardAndPassport' ? 'Please capture the front of your ID card.' : idCaptureRequirement === 'passport' ? 'Please capture the ID page of your passport.' : 'Please capture the front of your ID card, or the ID page of your passport.';
|
|
8055
8100
|
var secondInstructionText = idCaptureRequirement === 'idCardOrPassport' ? 'Please capture the back of your ID card, or click Done if submitting a passport.' : 'Please capture the back of your ID card.';
|
|
8056
|
-
var descriptionText = "On-device capture guidance failed, please capture ".concat(
|
|
8101
|
+
var descriptionText = "On-device capture guidance failed, please capture ".concat(minImageCount > 1 ? 'photos' : ' a photo', " of your ").concat(whatToCapture, " manually.");
|
|
8057
8102
|
var verbiage = useTranslations(rawVerbiage, {
|
|
8058
8103
|
headingText: "We're having some trouble.",
|
|
8059
8104
|
descriptionText: descriptionText,
|
|
@@ -8127,7 +8172,7 @@ var IdCaptureFallback = function IdCaptureFallback(_a) {
|
|
|
8127
8172
|
alt: "",
|
|
8128
8173
|
className: classNames.image
|
|
8129
8174
|
}));
|
|
8130
|
-
}))), images.length <
|
|
8175
|
+
}))), images.length < minImageCount && ( /*#__PURE__*/React__default.createElement(Instruction, {
|
|
8131
8176
|
className: classNames.instruction
|
|
8132
8177
|
}, instructionText)), /*#__PURE__*/React__default.createElement("input", {
|
|
8133
8178
|
ref: fileInput,
|
|
@@ -8138,7 +8183,7 @@ var IdCaptureFallback = function IdCaptureFallback(_a) {
|
|
|
8138
8183
|
hidden: true
|
|
8139
8184
|
}), /*#__PURE__*/React__default.createElement(StyledButtonsRow$8, {
|
|
8140
8185
|
className: classNames.buttonsRow
|
|
8141
|
-
}, images.length <
|
|
8186
|
+
}, images.length < maxImageCount && ( /*#__PURE__*/React__default.createElement(LoaderButton, {
|
|
8142
8187
|
variant: images.length > 0 ? 'secondary' : 'positive',
|
|
8143
8188
|
className: images.length > 0 ? classNames.captureMoreBtn : classNames.captureBtn,
|
|
8144
8189
|
colors: images.length > 0 ? colors.captureMoreBtn : colors.captureBtn,
|
|
@@ -8151,7 +8196,7 @@ var IdCaptureFallback = function IdCaptureFallback(_a) {
|
|
|
8151
8196
|
setDocumentToCapture(instructionText);
|
|
8152
8197
|
}
|
|
8153
8198
|
}
|
|
8154
|
-
}, images.length > 0 ? verbiage.captureMoreBtnText : verbiage.captureBtnText)), images.length >=
|
|
8199
|
+
}, images.length > 0 ? verbiage.captureMoreBtnText : verbiage.captureBtnText)), images.length >= minImageCount && ( /*#__PURE__*/React__default.createElement(LoaderButton, {
|
|
8155
8200
|
variant: "positive",
|
|
8156
8201
|
className: classNames.doneBtn,
|
|
8157
8202
|
colors: colors.doneBtn,
|
|
@@ -8198,87 +8243,94 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
|
|
|
8198
8243
|
precapturedDocuments = _a.precapturedDocuments,
|
|
8199
8244
|
_j = _a.captureRequirement,
|
|
8200
8245
|
captureRequirement = _j === void 0 ? 'idCardOrPassport' : _j,
|
|
8201
|
-
_k = _a.
|
|
8202
|
-
|
|
8203
|
-
_l = _a.
|
|
8204
|
-
|
|
8205
|
-
_m = _a.
|
|
8206
|
-
|
|
8246
|
+
_k = _a.allowSinglePageIdCapture,
|
|
8247
|
+
allowSinglePageIdCapture = _k === void 0 ? false : _k,
|
|
8248
|
+
_l = _a.separateIdCardCaptureSequence,
|
|
8249
|
+
separateIdCardCaptureSequence = _l === void 0 ? false : _l,
|
|
8250
|
+
_m = _a.thresholds,
|
|
8251
|
+
thresholds = _m === void 0 ? defaultIdCaptureThresholds : _m,
|
|
8252
|
+
_o = _a.skipSuccessScreen,
|
|
8253
|
+
skipSuccessScreen = _o === void 0 ? false : _o,
|
|
8207
8254
|
instructions = _a.instructions,
|
|
8208
|
-
|
|
8209
|
-
releaseCameraAccessOnExit =
|
|
8210
|
-
|
|
8211
|
-
guideType =
|
|
8212
|
-
|
|
8213
|
-
portraitGuidesOnMobile =
|
|
8214
|
-
|
|
8215
|
-
rotateLoadingOverlayImageWhenPortrait =
|
|
8216
|
-
|
|
8217
|
-
silentFallback =
|
|
8218
|
-
|
|
8219
|
-
forceFallbackMode =
|
|
8220
|
-
|
|
8221
|
-
allowIdCardBackToFrontCapture =
|
|
8222
|
-
|
|
8223
|
-
enableOverrideWrongDocumentTypeDialog =
|
|
8224
|
-
|
|
8225
|
-
allowOverrideWrongDocumentTypeAfterMs =
|
|
8226
|
-
|
|
8227
|
-
guideImages =
|
|
8228
|
-
|
|
8229
|
-
assets =
|
|
8230
|
-
|
|
8231
|
-
classNames =
|
|
8232
|
-
|
|
8233
|
-
colors =
|
|
8234
|
-
|
|
8235
|
-
verbiage =
|
|
8236
|
-
|
|
8237
|
-
debugMode =
|
|
8238
|
-
var
|
|
8239
|
-
state =
|
|
8240
|
-
dispatch =
|
|
8241
|
-
var
|
|
8242
|
-
cameraAccessDenied =
|
|
8243
|
-
requestCameraAccess =
|
|
8244
|
-
releaseCameraAccess =
|
|
8245
|
-
var
|
|
8246
|
-
overlayDismissed =
|
|
8247
|
-
setOverlayDismissed =
|
|
8248
|
-
var
|
|
8249
|
-
submissionStatus =
|
|
8250
|
-
setIdFrontImage =
|
|
8251
|
-
setIdBackImage =
|
|
8252
|
-
setPassportImage =
|
|
8253
|
-
logIdFrontCaptureAttempt =
|
|
8254
|
-
logIdBackCaptureAttempt =
|
|
8255
|
-
var
|
|
8256
|
-
start =
|
|
8257
|
-
stop =
|
|
8258
|
-
onPredictionMade =
|
|
8259
|
-
setRequiredDocumentType =
|
|
8260
|
-
modelError =
|
|
8261
|
-
resetBestFrame =
|
|
8255
|
+
_p = _a.releaseCameraAccessOnExit,
|
|
8256
|
+
releaseCameraAccessOnExit = _p === void 0 ? true : _p,
|
|
8257
|
+
_q = _a.guideType,
|
|
8258
|
+
guideType = _q === void 0 ? 'fit' : _q,
|
|
8259
|
+
_r = _a.portraitGuidesOnMobile,
|
|
8260
|
+
portraitGuidesOnMobile = _r === void 0 ? true : _r,
|
|
8261
|
+
_s = _a.rotateLoadingOverlayImageWhenPortrait,
|
|
8262
|
+
rotateLoadingOverlayImageWhenPortrait = _s === void 0 ? true : _s,
|
|
8263
|
+
_t = _a.silentFallback,
|
|
8264
|
+
silentFallback = _t === void 0 ? false : _t,
|
|
8265
|
+
_u = _a.forceFallbackMode,
|
|
8266
|
+
forceFallbackMode = _u === void 0 ? false : _u,
|
|
8267
|
+
_v = _a.allowIdCardBackToFrontCapture,
|
|
8268
|
+
allowIdCardBackToFrontCapture = _v === void 0 ? false : _v,
|
|
8269
|
+
_w = _a.enableOverrideWrongDocumentTypeDialog,
|
|
8270
|
+
enableOverrideWrongDocumentTypeDialog = _w === void 0 ? false : _w,
|
|
8271
|
+
_x = _a.allowOverrideWrongDocumentTypeAfterMs,
|
|
8272
|
+
allowOverrideWrongDocumentTypeAfterMs = _x === void 0 ? 8000 : _x,
|
|
8273
|
+
_y = _a.guideImages,
|
|
8274
|
+
guideImages = _y === void 0 ? defaultIdCaptureGuideImages : _y,
|
|
8275
|
+
_z = _a.assets,
|
|
8276
|
+
assets = _z === void 0 ? {} : _z,
|
|
8277
|
+
_0 = _a.classNames,
|
|
8278
|
+
classNames = _0 === void 0 ? {} : _0,
|
|
8279
|
+
_1 = _a.colors,
|
|
8280
|
+
colors = _1 === void 0 ? {} : _1,
|
|
8281
|
+
_2 = _a.verbiage,
|
|
8282
|
+
verbiage = _2 === void 0 ? {} : _2,
|
|
8283
|
+
_3 = _a.debugMode,
|
|
8284
|
+
debugMode = _3 === void 0 ? false : _3;
|
|
8285
|
+
var _4 = useIdCaptureState(),
|
|
8286
|
+
state = _4[0],
|
|
8287
|
+
dispatch = _4[1];
|
|
8288
|
+
var _5 = useCameraStore(),
|
|
8289
|
+
cameraAccessDenied = _5.cameraAccessDenied,
|
|
8290
|
+
requestCameraAccess = _5.requestCameraAccess,
|
|
8291
|
+
releaseCameraAccess = _5.releaseCameraAccess;
|
|
8292
|
+
var _6 = useState(false),
|
|
8293
|
+
overlayDismissed = _6[0],
|
|
8294
|
+
setOverlayDismissed = _6[1];
|
|
8295
|
+
var _7 = useContext(SubmissionContext),
|
|
8296
|
+
submissionStatus = _7.submissionStatus,
|
|
8297
|
+
setIdFrontImage = _7.setIdFrontImage,
|
|
8298
|
+
setIdBackImage = _7.setIdBackImage,
|
|
8299
|
+
setPassportImage = _7.setPassportImage,
|
|
8300
|
+
logIdFrontCaptureAttempt = _7.logIdFrontCaptureAttempt,
|
|
8301
|
+
logIdBackCaptureAttempt = _7.logIdBackCaptureAttempt;
|
|
8302
|
+
var _8 = useContext(IdCaptureModelsContext),
|
|
8303
|
+
start = _8.start,
|
|
8304
|
+
stop = _8.stop,
|
|
8305
|
+
onPredictionMade = _8.onPredictionMade,
|
|
8306
|
+
setRequiredDocumentType = _8.setRequiredDocumentType,
|
|
8307
|
+
modelError = _8.modelError,
|
|
8308
|
+
resetBestFrame = _8.resetBestFrame;
|
|
8262
8309
|
useEffect(function () {
|
|
8263
8310
|
dispatch({
|
|
8264
8311
|
type: 'configureWizard',
|
|
8265
8312
|
payload: {
|
|
8266
8313
|
captureRequirement: captureRequirement,
|
|
8267
8314
|
precapturedDocuments: precapturedDocuments,
|
|
8315
|
+
allowSinglePageIdCapture: allowSinglePageIdCapture,
|
|
8268
8316
|
allowIdCardBackToFrontCapture: allowIdCardBackToFrontCapture,
|
|
8269
8317
|
enableOverrideWrongDocumentTypeDialog: enableOverrideWrongDocumentTypeDialog,
|
|
8270
8318
|
allowOverrideWrongDocumentTypeAfterMs: allowOverrideWrongDocumentTypeAfterMs
|
|
8271
8319
|
}
|
|
8272
8320
|
});
|
|
8273
|
-
}, [allowIdCardBackToFrontCapture, allowOverrideWrongDocumentTypeAfterMs, captureRequirement, dispatch, enableOverrideWrongDocumentTypeDialog, precapturedDocuments]);
|
|
8321
|
+
}, [allowIdCardBackToFrontCapture, allowOverrideWrongDocumentTypeAfterMs, allowSinglePageIdCapture, captureRequirement, dispatch, enableOverrideWrongDocumentTypeDialog, precapturedDocuments]);
|
|
8274
8322
|
var documentCount = Object.keys(state.capturedDocuments).length;
|
|
8275
8323
|
useEffect(function () {
|
|
8276
|
-
documentCount
|
|
8324
|
+
if (documentCount) resetBestFrame();
|
|
8277
8325
|
}, [documentCount, resetBestFrame]);
|
|
8278
8326
|
var logCaptureMetadata = useCallback(function (metadata) {
|
|
8279
8327
|
var _a;
|
|
8280
8328
|
metadata.operationTime = new Date().getTime() - ((_a = state.operationStartedAt) !== null && _a !== void 0 ? _a : new Date()).getTime();
|
|
8281
|
-
state.requestedDocumentType === 'idCardBack'
|
|
8329
|
+
if (state.requestedDocumentType === 'idCardBack') {
|
|
8330
|
+
logIdBackCaptureAttempt(metadata);
|
|
8331
|
+
} else {
|
|
8332
|
+
logIdFrontCaptureAttempt(metadata);
|
|
8333
|
+
}
|
|
8282
8334
|
}, [logIdBackCaptureAttempt, logIdFrontCaptureAttempt, state.operationStartedAt, state.requestedDocumentType]);
|
|
8283
8335
|
useEffect(function startModelsWhenCapturing() {
|
|
8284
8336
|
if (!overlayDismissed || state.captureState !== 'capturing') return;
|
|
@@ -8328,14 +8380,17 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
|
|
|
8328
8380
|
var _a = state.capturedDocuments,
|
|
8329
8381
|
idCardFront = _a.idCardFront,
|
|
8330
8382
|
idCardBack = _a.idCardBack,
|
|
8331
|
-
passport = _a.passport
|
|
8383
|
+
passport = _a.passport,
|
|
8384
|
+
singlePage = _a.singlePage;
|
|
8332
8385
|
var idFrontImage = idCardFront && dataUrlToBase64Sync(idCardFront.imageData);
|
|
8333
8386
|
var idBackImage = idCardBack && dataUrlToBase64Sync(idCardBack.imageData);
|
|
8334
8387
|
var passportImage = passport && dataUrlToBase64Sync(passport.imageData);
|
|
8335
|
-
|
|
8336
|
-
|
|
8337
|
-
|
|
8338
|
-
|
|
8388
|
+
var singlePageImage = singlePage && dataUrlToBase64Sync(singlePage.imageData);
|
|
8389
|
+
if (idFrontImage) setIdFrontImage(idFrontImage);
|
|
8390
|
+
if (idBackImage) setIdBackImage(idBackImage);
|
|
8391
|
+
if (passportImage) setPassportImage(passportImage);
|
|
8392
|
+
if (singlePageImage) setIdFrontImage(singlePageImage);
|
|
8393
|
+
if (releaseCameraAccessOnExit) releaseCameraAccess();
|
|
8339
8394
|
setTimeout(function () {
|
|
8340
8395
|
onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess({
|
|
8341
8396
|
idFrontImage: idFrontImage,
|
|
@@ -8350,9 +8405,9 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
|
|
|
8350
8405
|
type: 'resetWizard'
|
|
8351
8406
|
});
|
|
8352
8407
|
}, [dispatch]);
|
|
8353
|
-
var
|
|
8354
|
-
attempt =
|
|
8355
|
-
setAttempt =
|
|
8408
|
+
var _9 = useState(0),
|
|
8409
|
+
attempt = _9[0],
|
|
8410
|
+
setAttempt = _9[1];
|
|
8356
8411
|
var onExit = useCallback(function () {
|
|
8357
8412
|
releaseCameraAccess();
|
|
8358
8413
|
setOverlayDismissed(false);
|
|
@@ -8367,7 +8422,7 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
|
|
|
8367
8422
|
}, [dispatch, onExitCapture, releaseCameraAccess, requestCameraAccess]);
|
|
8368
8423
|
useEffect(function () {
|
|
8369
8424
|
if (submissionStatus !== SubmissionStatus.READY) {
|
|
8370
|
-
releaseCameraAccessOnExit
|
|
8425
|
+
if (releaseCameraAccessOnExit) releaseCameraAccess();
|
|
8371
8426
|
}
|
|
8372
8427
|
}, [releaseCameraAccess, releaseCameraAccessOnExit, submissionStatus]);
|
|
8373
8428
|
useEffect(function () {
|
|
@@ -8443,9 +8498,9 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
|
|
|
8443
8498
|
});
|
|
8444
8499
|
});
|
|
8445
8500
|
}, [dispatch]);
|
|
8446
|
-
var
|
|
8447
|
-
progressStarted =
|
|
8448
|
-
setProgressStarted =
|
|
8501
|
+
var _10 = useState(false),
|
|
8502
|
+
progressStarted = _10[0],
|
|
8503
|
+
setProgressStarted = _10[1];
|
|
8449
8504
|
useEffect(function () {
|
|
8450
8505
|
if (state.captureState === 'capturing') {
|
|
8451
8506
|
setProgressStarted(false);
|
|
@@ -9548,19 +9603,25 @@ var SelfieCapture = function SelfieCapture(_a) {
|
|
|
9548
9603
|
canvasRef = _v.canvasRef,
|
|
9549
9604
|
guidanceError = _v.error;
|
|
9550
9605
|
onPredictionMade(useThrottledCallback(useCallback(function (prediction) {
|
|
9551
|
-
return
|
|
9552
|
-
|
|
9553
|
-
|
|
9554
|
-
|
|
9555
|
-
|
|
9556
|
-
|
|
9557
|
-
|
|
9558
|
-
|
|
9559
|
-
|
|
9606
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
9607
|
+
return __generator(this, function (_a) {
|
|
9608
|
+
if (shouldCapture && !busy) {
|
|
9609
|
+
drawToCanvas(lastPredictionCanvas.current, canvasRef.current);
|
|
9610
|
+
dispatch({
|
|
9611
|
+
type: 'facesDetected',
|
|
9612
|
+
payload: prediction
|
|
9613
|
+
});
|
|
9614
|
+
}
|
|
9615
|
+
return [2 /*return*/];
|
|
9616
|
+
});
|
|
9560
9617
|
});
|
|
9561
9618
|
}, [canvasRef, shouldCapture, busy]), 16));
|
|
9562
9619
|
useEffect(function () {
|
|
9563
|
-
(prediction === null || prediction === void 0 ? void 0 : prediction.faceReady)
|
|
9620
|
+
if (prediction === null || prediction === void 0 ? void 0 : prediction.faceReady) {
|
|
9621
|
+
onGuidanceSatisfied === null || onGuidanceSatisfied === void 0 ? void 0 : onGuidanceSatisfied();
|
|
9622
|
+
} else {
|
|
9623
|
+
onGuidanceNotSatisfied === null || onGuidanceNotSatisfied === void 0 ? void 0 : onGuidanceNotSatisfied();
|
|
9624
|
+
}
|
|
9564
9625
|
}, [onGuidanceNotSatisfied, onGuidanceSatisfied, prediction === null || prediction === void 0 ? void 0 : prediction.faceReady]);
|
|
9565
9626
|
useEffect(function () {
|
|
9566
9627
|
if (!(prediction === null || prediction === void 0 ? void 0 : prediction.faceReady)) return;
|
|
@@ -10558,7 +10619,7 @@ var FaceLivenessWizard = function FaceLivenessWizard(_a) {
|
|
|
10558
10619
|
}, [logCaptureMetadata, releaseCameraAccess, requestCameraAccess]);
|
|
10559
10620
|
var onDoneCallback = useCallback(function () {
|
|
10560
10621
|
logCaptureMetadata();
|
|
10561
|
-
releaseCameraAccessOnExit
|
|
10622
|
+
if (releaseCameraAccessOnExit) releaseCameraAccess();
|
|
10562
10623
|
setTimeout(function () {
|
|
10563
10624
|
onComplete === null || onComplete === void 0 ? void 0 : onComplete(submissionResponse, livenessCheckRequest);
|
|
10564
10625
|
}, 0);
|
|
@@ -10577,7 +10638,7 @@ var FaceLivenessWizard = function FaceLivenessWizard(_a) {
|
|
|
10577
10638
|
onLoadingOverlayDismissed === null || onLoadingOverlayDismissed === void 0 ? void 0 : onLoadingOverlayDismissed();
|
|
10578
10639
|
}, [onLoadingOverlayDismissed]);
|
|
10579
10640
|
var onFailureExitClick = useCallback(function () {
|
|
10580
|
-
releaseCameraAccessOnExit
|
|
10641
|
+
if (releaseCameraAccessOnExit) releaseCameraAccess();
|
|
10581
10642
|
setTimeout(function () {
|
|
10582
10643
|
onExitAfterFailure === null || onExitAfterFailure === void 0 ? void 0 : onExitAfterFailure(submissionResponse, livenessCheckRequest);
|
|
10583
10644
|
}, 0);
|
|
@@ -10931,16 +10992,15 @@ var SignatureButtonsContainer = styled(ButtonsRow)(templateObject_4$4 || (templa
|
|
|
10931
10992
|
var templateObject_1$b, templateObject_2$9, templateObject_3$9, templateObject_4$4;
|
|
10932
10993
|
|
|
10933
10994
|
var SignatureCapture = function SignatureCapture(_a) {
|
|
10934
|
-
var _b;
|
|
10935
10995
|
var onAccept = _a.onAccept,
|
|
10936
|
-
|
|
10937
|
-
classNames =
|
|
10938
|
-
|
|
10939
|
-
rawVerbiage =
|
|
10940
|
-
var
|
|
10941
|
-
ref =
|
|
10942
|
-
width =
|
|
10943
|
-
height =
|
|
10996
|
+
_b = _a.classNames,
|
|
10997
|
+
classNames = _b === void 0 ? {} : _b,
|
|
10998
|
+
_c = _a.verbiage,
|
|
10999
|
+
rawVerbiage = _c === void 0 ? {} : _c;
|
|
11000
|
+
var _d = useResizeObserver(),
|
|
11001
|
+
ref = _d.ref,
|
|
11002
|
+
width = _d.width,
|
|
11003
|
+
height = _d.height;
|
|
10944
11004
|
var signaturePad = useRef(null);
|
|
10945
11005
|
var verbiage = useTranslations(rawVerbiage, {
|
|
10946
11006
|
headingText: 'Please sign the box below',
|
|
@@ -10990,8 +11050,11 @@ var SignatureCapture = function SignatureCapture(_a) {
|
|
|
10990
11050
|
}, /*#__PURE__*/React__default.createElement(LoaderButton, {
|
|
10991
11051
|
variant: "secondary",
|
|
10992
11052
|
className: classNames.clearBtn,
|
|
10993
|
-
|
|
10994
|
-
|
|
11053
|
+
finished: true,
|
|
11054
|
+
onClick: function onClick() {
|
|
11055
|
+
var _a;
|
|
11056
|
+
(_a = signaturePad.current) === null || _a === void 0 ? void 0 : _a.clear();
|
|
11057
|
+
}
|
|
10995
11058
|
}, verbiage.clearBtnText), /*#__PURE__*/React__default.createElement(AcceptBtn$1, {
|
|
10996
11059
|
variant: "positive",
|
|
10997
11060
|
className: classNames.acceptBtn,
|
|
@@ -11969,7 +12032,8 @@ var defaultVideoIdCaptureThresholds = {
|
|
|
11969
12032
|
detection: {
|
|
11970
12033
|
idCardFront: 0.4,
|
|
11971
12034
|
idCardBack: 0.5,
|
|
11972
|
-
passport: 0.3
|
|
12035
|
+
passport: 0.3,
|
|
12036
|
+
singlePage: 0.3
|
|
11973
12037
|
},
|
|
11974
12038
|
focus: {
|
|
11975
12039
|
idCardFront: {
|
|
@@ -11983,12 +12047,17 @@ var defaultVideoIdCaptureThresholds = {
|
|
|
11983
12047
|
passport: {
|
|
11984
12048
|
desktop: 0,
|
|
11985
12049
|
mobile: 0
|
|
12050
|
+
},
|
|
12051
|
+
singlePage: {
|
|
12052
|
+
desktop: 0,
|
|
12053
|
+
mobile: 0
|
|
11986
12054
|
}
|
|
11987
12055
|
},
|
|
11988
12056
|
goodFrames: {
|
|
11989
12057
|
idCardFront: 1,
|
|
11990
12058
|
idCardBack: 1,
|
|
11991
|
-
passport: 1
|
|
12059
|
+
passport: 1,
|
|
12060
|
+
singlePage: 1
|
|
11992
12061
|
},
|
|
11993
12062
|
flipShortcutThreshold: 0.7
|
|
11994
12063
|
};
|
|
@@ -12060,6 +12129,7 @@ var IdVideoCapture = function IdVideoCapture(_a) {
|
|
|
12060
12129
|
stopIdModels = _18.stop,
|
|
12061
12130
|
onIdPredictionMade = _18.onPredictionMade,
|
|
12062
12131
|
setThresholds = _18.setThresholds,
|
|
12132
|
+
setRequiredDocumentType = _18.setRequiredDocumentType,
|
|
12063
12133
|
setDocumentDetectionBoundaries = _18.setDocumentDetectionBoundaries,
|
|
12064
12134
|
bestFrameDetails = _18.bestFrameDetails,
|
|
12065
12135
|
resetBestFrame = _18.resetBestFrame,
|
|
@@ -12138,6 +12208,9 @@ var IdVideoCapture = function IdVideoCapture(_a) {
|
|
|
12138
12208
|
useEffect(function () {
|
|
12139
12209
|
setThresholds(adjustedThresholds);
|
|
12140
12210
|
}, [requestedAction, setThresholds, adjustedThresholds]);
|
|
12211
|
+
useEffect(function () {
|
|
12212
|
+
setRequiredDocumentType(requestedAction === 'SHOW_PASSPORT' ? 'passport' : requestedAction === 'SHOW_ID_BACK' ? 'idCardBack' : 'idCardFront');
|
|
12213
|
+
}, [requestedAction, setRequiredDocumentType]);
|
|
12141
12214
|
useEffect(function () {
|
|
12142
12215
|
setDocumentDetectionBoundaries({
|
|
12143
12216
|
top: 20,
|
|
@@ -12160,6 +12233,9 @@ var IdVideoCapture = function IdVideoCapture(_a) {
|
|
|
12160
12233
|
setGoodFramesCount = _28[1];
|
|
12161
12234
|
var goodFramesThreshold = requestedAction === 'SHOW_PASSPORT' ? adjustedThresholds.goodFrames.passport : requestedAction === 'SHOW_ID_FRONT' ? adjustedThresholds.goodFrames.idCardFront : adjustedThresholds.goodFrames.idCardBack;
|
|
12162
12235
|
var goodFramesThresholdMet = goodFramesCount >= goodFramesThreshold;
|
|
12236
|
+
var _29 = useState(false),
|
|
12237
|
+
isSinglePage = _29[0],
|
|
12238
|
+
setIsSinglePage = _29[1];
|
|
12163
12239
|
useEffect(function () {
|
|
12164
12240
|
if (!idCaptureModelsEnabled || idModelError) return;
|
|
12165
12241
|
onIdPredictionMade(function (prediction) {
|
|
@@ -12167,7 +12243,8 @@ var IdVideoCapture = function IdVideoCapture(_a) {
|
|
|
12167
12243
|
setCurrentDetectionScore(prediction.detectionScore);
|
|
12168
12244
|
setCurrentDetectedDocumentType(prediction.detectedDocumentType);
|
|
12169
12245
|
setCurrentFocusScore(prediction.focusScore);
|
|
12170
|
-
|
|
12246
|
+
setIsSinglePage(prediction.singlePageDetectionThresholdMet);
|
|
12247
|
+
var detectionThresholdMet = requestedAction === 'SHOW_PASSPORT' ? prediction.passportDetectionThresholdMet : requestedAction === 'SHOW_ID_BACK' ? prediction.idCardBackDetectionThresholdMet : prediction.idCardFrontDetectionThresholdMet || prediction.singlePageDetectionThresholdMet;
|
|
12171
12248
|
var isGoodFrame = detectionThresholdMet && prediction.focusThresholdMet;
|
|
12172
12249
|
var shouldShortcutFlipAnimation = requestedAction === 'FLIP_ID' && isGoodFrame && prediction.idCardBackDetectionScore >= adjustedThresholds.flipShortcutThreshold;
|
|
12173
12250
|
if (shouldShortcutFlipAnimation) {
|
|
@@ -12178,9 +12255,9 @@ var IdVideoCapture = function IdVideoCapture(_a) {
|
|
|
12178
12255
|
} : 0);
|
|
12179
12256
|
});
|
|
12180
12257
|
}, [idCaptureModelsEnabled, onIdPredictionMade, idModelError, requestedAction, adjustedThresholds.flipShortcutThreshold]);
|
|
12181
|
-
var
|
|
12182
|
-
idFrontCaptureStartedAt =
|
|
12183
|
-
setFirstGoodFrameTime =
|
|
12258
|
+
var _30 = useState(null),
|
|
12259
|
+
idFrontCaptureStartedAt = _30[0],
|
|
12260
|
+
setFirstGoodFrameTime = _30[1];
|
|
12184
12261
|
useEffect(function () {
|
|
12185
12262
|
if (goodFramesCount === 1) setFirstGoodFrameTime(new Date().getTime());
|
|
12186
12263
|
}, [goodFramesCount]);
|
|
@@ -12201,80 +12278,60 @@ var IdVideoCapture = function IdVideoCapture(_a) {
|
|
|
12201
12278
|
var frameHeight = (_e = (_d = videoRef.current) === null || _d === void 0 ? void 0 : _d.videoHeight) !== null && _e !== void 0 ? _e : 0;
|
|
12202
12279
|
var faceBox = face === null || face === void 0 ? void 0 : face.box;
|
|
12203
12280
|
var faceCentered = !faceBox || !frameWidth || faceBox.xMin > frameWidth * edgeBoundary && faceBox.yMin > frameHeight * edgeBoundary && faceBox.xMax < frameWidth * (1 - edgeBoundary) && faceBox.yMax < frameHeight * (1 - edgeBoundary);
|
|
12204
|
-
var
|
|
12205
|
-
countdownStartedAt =
|
|
12206
|
-
setCountdownStartedAt =
|
|
12281
|
+
var _31 = useState(),
|
|
12282
|
+
countdownStartedAt = _31[0],
|
|
12283
|
+
setCountdownStartedAt = _31[1];
|
|
12207
12284
|
var photoCanvas = useRef(null);
|
|
12208
12285
|
var frameLock = useRef(false);
|
|
12209
12286
|
var captureFrame = useCallback(function () {
|
|
12210
12287
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
12211
|
-
var frameBase64
|
|
12212
|
-
return __generator(this, function (
|
|
12213
|
-
|
|
12214
|
-
|
|
12215
|
-
|
|
12216
|
-
|
|
12217
|
-
|
|
12218
|
-
|
|
12219
|
-
|
|
12220
|
-
|
|
12221
|
-
|
|
12222
|
-
|
|
12223
|
-
_b.label = 1;
|
|
12224
|
-
case 1:
|
|
12225
|
-
_b.trys.push([1,, 7, 8]);
|
|
12226
|
-
if (!(requestedAction == 'SHOW_ID_FRONT')) return [3 /*break*/, 5];
|
|
12288
|
+
var frameBase64;
|
|
12289
|
+
return __generator(this, function (_a) {
|
|
12290
|
+
if (frameLock.current) return [2 /*return*/];
|
|
12291
|
+
frameLock.current = true;
|
|
12292
|
+
drawToCanvas(photoCanvas.current, videoRef.current);
|
|
12293
|
+
frameBase64 = photoCanvas.current.toDataURL('image/jpeg');
|
|
12294
|
+
if (!frameBase64) {
|
|
12295
|
+
frameLock.current = false;
|
|
12296
|
+
return [2 /*return*/];
|
|
12297
|
+
}
|
|
12298
|
+
try {
|
|
12299
|
+
if (requestedAction == 'SHOW_ID_FRONT') {
|
|
12227
12300
|
if (onIdFrontImageCaptured) {
|
|
12228
12301
|
onIdFrontImageCaptured(frameBase64);
|
|
12229
12302
|
}
|
|
12230
|
-
if (
|
|
12231
|
-
_a = skipShowIdCardBack === true;
|
|
12232
|
-
if (_a) return [3 /*break*/, 3];
|
|
12233
|
-
return [4 /*yield*/, skipShowIdCardBack()];
|
|
12234
|
-
case 2:
|
|
12235
|
-
_a = _b.sent();
|
|
12236
|
-
_b.label = 3;
|
|
12237
|
-
case 3:
|
|
12238
|
-
if (_a) {
|
|
12303
|
+
if (isSinglePage || evaluateShouldSkip(skipShowIdCardBack)) {
|
|
12239
12304
|
return [2 /*return*/, onIdCaptureComplete()];
|
|
12240
12305
|
}
|
|
12241
|
-
_b.label = 4;
|
|
12242
|
-
case 4:
|
|
12243
12306
|
setRequestedAction('FLIP_ID');
|
|
12244
|
-
|
|
12245
|
-
|
|
12246
|
-
|
|
12247
|
-
if (onIdBackImageCaptured) {
|
|
12248
|
-
onIdBackImageCaptured(frameBase64);
|
|
12249
|
-
}
|
|
12250
|
-
onIdCaptureComplete();
|
|
12251
|
-
} else if (requestedAction == 'SHOW_PASSPORT') {
|
|
12252
|
-
if (onIdFrontImageCaptured) {
|
|
12253
|
-
onIdFrontImageCaptured(frameBase64);
|
|
12254
|
-
}
|
|
12255
|
-
onIdCaptureComplete();
|
|
12307
|
+
} else if (requestedAction == 'SHOW_ID_BACK') {
|
|
12308
|
+
if (onIdBackImageCaptured) {
|
|
12309
|
+
onIdBackImageCaptured(frameBase64);
|
|
12256
12310
|
}
|
|
12257
|
-
|
|
12258
|
-
|
|
12259
|
-
|
|
12260
|
-
|
|
12261
|
-
setDetectedObjects([]);
|
|
12262
|
-
setCurrentDetectionScore(0);
|
|
12263
|
-
setCurrentFocusScore(0);
|
|
12264
|
-
setGoodFramesCount(0);
|
|
12265
|
-
setCountdownStartedAt(undefined);
|
|
12266
|
-
resetBestFrame();
|
|
12267
|
-
frameLock.current = false;
|
|
12268
|
-
if (countdownTimeoutRef.current) {
|
|
12269
|
-
clearTimeout(countdownTimeoutRef.current);
|
|
12311
|
+
onIdCaptureComplete();
|
|
12312
|
+
} else if (requestedAction == 'SHOW_PASSPORT') {
|
|
12313
|
+
if (onIdFrontImageCaptured) {
|
|
12314
|
+
onIdFrontImageCaptured(frameBase64);
|
|
12270
12315
|
}
|
|
12271
|
-
|
|
12272
|
-
|
|
12273
|
-
|
|
12316
|
+
onIdCaptureComplete();
|
|
12317
|
+
}
|
|
12318
|
+
} finally {
|
|
12319
|
+
setDetectedObjects([]);
|
|
12320
|
+
setCurrentDetectionScore(0);
|
|
12321
|
+
setCurrentFocusScore(0);
|
|
12322
|
+
setGoodFramesCount(0);
|
|
12323
|
+
setCountdownStartedAt(undefined);
|
|
12324
|
+
setIsSinglePage(false);
|
|
12325
|
+
resetBestFrame();
|
|
12326
|
+
frameLock.current = false;
|
|
12327
|
+
if (countdownTimeoutRef.current) {
|
|
12328
|
+
clearTimeout(countdownTimeoutRef.current);
|
|
12329
|
+
}
|
|
12274
12330
|
}
|
|
12331
|
+
return [2 /*return*/];
|
|
12275
12332
|
});
|
|
12276
12333
|
});
|
|
12277
|
-
}, [
|
|
12334
|
+
}, [videoRef, requestedAction, onIdFrontImageCaptured, isSinglePage, skipShowIdCardBack, onIdCaptureComplete, onIdBackImageCaptured, resetBestFrame]);
|
|
12278
12335
|
var isFlipping = requestedAction === 'FLIP_ID';
|
|
12279
12336
|
useEffect(function () {
|
|
12280
12337
|
if (!isFlipping) return;
|
|
@@ -12333,9 +12390,9 @@ var IdVideoCapture = function IdVideoCapture(_a) {
|
|
|
12333
12390
|
stopSelfieGuidance();
|
|
12334
12391
|
};
|
|
12335
12392
|
}, [startSelfieGuidance, stopSelfieGuidance]);
|
|
12336
|
-
var
|
|
12337
|
-
numFramesWithoutFaces =
|
|
12338
|
-
setNumFramesWithoutFaces =
|
|
12393
|
+
var _32 = useState(0),
|
|
12394
|
+
numFramesWithoutFaces = _32[0],
|
|
12395
|
+
setNumFramesWithoutFaces = _32[1];
|
|
12339
12396
|
onSelfiePredictionMade(useThrottledCallback(useCallback(function (_a) {
|
|
12340
12397
|
var face = _a.face;
|
|
12341
12398
|
if (selfieModelError) return;
|
|
@@ -12351,12 +12408,12 @@ var IdVideoCapture = function IdVideoCapture(_a) {
|
|
|
12351
12408
|
}
|
|
12352
12409
|
}, [disableFaceDetectionWhileAudioCapture, disableFaceDetectionWhileAudioCaptureMsDelay, numFramesWithoutFaces, onFaceNotDetected, timeoutStartedAt]);
|
|
12353
12410
|
var theme = useTheme();
|
|
12354
|
-
var
|
|
12411
|
+
var _33 = useTranslations(rawVerbiage, {
|
|
12355
12412
|
faceNotCenteredText: 'Please move your face to the center...',
|
|
12356
12413
|
captureBtnText: 'Capture'
|
|
12357
12414
|
}),
|
|
12358
|
-
captureBtnText =
|
|
12359
|
-
faceNotCenteredText =
|
|
12415
|
+
captureBtnText = _33.captureBtnText,
|
|
12416
|
+
faceNotCenteredText = _33.faceNotCenteredText;
|
|
12360
12417
|
var debugScalingDetails = useDebugScalingDetails({
|
|
12361
12418
|
enabled: debugMode,
|
|
12362
12419
|
pageWidth: width,
|
|
@@ -12431,6 +12488,11 @@ var CountdownContainer = styled.div(templateObject_1$5 || (templateObject_1$5 =
|
|
|
12431
12488
|
var Countdown = styled.div(templateObject_2$5 || (templateObject_2$5 = __makeTemplateObject(["\n color: white;\n font-size: 64px;\n font-weight: bold;\n margin: auto;\n"], ["\n color: white;\n font-size: 64px;\n font-weight: bold;\n margin: auto;\n"])));
|
|
12432
12489
|
var CaptureButtonContainer = styled.div(templateObject_3$5 || (templateObject_3$5 = __makeTemplateObject(["\n position: fixed;\n bottom: 0;\n width: 100dvw;\n display: flex;\n z-index: 100000;\n"], ["\n position: fixed;\n bottom: 0;\n width: 100dvw;\n display: flex;\n z-index: 100000;\n"])));
|
|
12433
12490
|
var CaptureButton = styled(LoaderButton)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n margin: 0 auto 25px;\n"], ["\n margin: 0 auto 25px;\n"])));
|
|
12491
|
+
function evaluateShouldSkip(value) {
|
|
12492
|
+
if (value === true) return true;
|
|
12493
|
+
if (typeof value === 'function') return value();
|
|
12494
|
+
return false;
|
|
12495
|
+
}
|
|
12434
12496
|
var templateObject_1$5, templateObject_2$5, templateObject_3$5, templateObject_4;
|
|
12435
12497
|
|
|
12436
12498
|
var IdVideoCaptureSuccess = function IdVideoCaptureSuccess(_a) {
|
|
@@ -12648,7 +12710,7 @@ var VideoIdWizard = function VideoIdWizard(_a) {
|
|
|
12648
12710
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
12649
12711
|
return __generator(this, function (_a) {
|
|
12650
12712
|
setIdCaptureVideoUrl(videoUrl);
|
|
12651
|
-
audioUrl
|
|
12713
|
+
if (audioUrl) setIdCaptureVideoAudioUrl(audioUrl);
|
|
12652
12714
|
setCaptureState('SUCCESS');
|
|
12653
12715
|
if (skipSuccessScreen) onComplete === null || onComplete === void 0 ? void 0 : onComplete();
|
|
12654
12716
|
return [2 /*return*/];
|
|
@@ -12724,7 +12786,8 @@ var VideoIdWizard = function VideoIdWizard(_a) {
|
|
|
12724
12786
|
documentDetectionModelUrl: (_g = (_f = idCaptureProps.assets) === null || _f === void 0 ? void 0 : _f.documentDetectionModelUrl) !== null && _g !== void 0 ? _g : '',
|
|
12725
12787
|
focusModelUrl: (_j = (_h = idCaptureProps.assets) === null || _h === void 0 ? void 0 : _h.focusModelUrl) !== null && _j !== void 0 ? _j : '',
|
|
12726
12788
|
onModelError: onIdCaptureModelError,
|
|
12727
|
-
modelLoadTimeoutMs: idCaptureModelLoadTimeoutMs
|
|
12789
|
+
modelLoadTimeoutMs: idCaptureModelLoadTimeoutMs,
|
|
12790
|
+
allowSinglePageIdCapture: idCaptureProps.allowSinglePageIdCapture
|
|
12728
12791
|
}, /*#__PURE__*/React__default.createElement(SelfieGuidanceModelsProvider, {
|
|
12729
12792
|
autoStart: false,
|
|
12730
12793
|
onModelError: faceLivenessProps === null || faceLivenessProps === void 0 ? void 0 : faceLivenessProps.onModelError,
|
|
@@ -12974,7 +13037,8 @@ function CompositeWizard(_a) {
|
|
|
12974
13037
|
documentDetectionModelUrl: (_d = (_c = idCaptureProps.assets) === null || _c === void 0 ? void 0 : _c.documentDetectionModelUrl) !== null && _d !== void 0 ? _d : '',
|
|
12975
13038
|
focusModelUrl: (_f = (_e = idCaptureProps.assets) === null || _e === void 0 ? void 0 : _e.focusModelUrl) !== null && _f !== void 0 ? _f : '',
|
|
12976
13039
|
onModelError: idCaptureProps.onModelError,
|
|
12977
|
-
modelLoadTimeoutMs: idCaptureProps.modelLoadTimeoutMs
|
|
13040
|
+
modelLoadTimeoutMs: idCaptureProps.modelLoadTimeoutMs,
|
|
13041
|
+
allowSinglePageIdCapture: idCaptureProps.allowSinglePageIdCapture
|
|
12978
13042
|
}, /*#__PURE__*/React__default.createElement(IdCaptureStateProvider, null, /*#__PURE__*/React__default.createElement(GuideOrientationContextProvider, null, /*#__PURE__*/React__default.createElement(IdCaptureWizard, _assign({}, idCaptureProps, {
|
|
12979
13043
|
onSuccess: onIdCaptureSuccess
|
|
12980
13044
|
}))))));
|
|
@@ -13241,10 +13305,10 @@ var resolveTheme = function resolveTheme(input) {
|
|
|
13241
13305
|
var ThemeProvider = function ThemeProvider(_a) {
|
|
13242
13306
|
var children = _a.children,
|
|
13243
13307
|
themeInput = _a.theme;
|
|
13244
|
-
var themeRef =
|
|
13308
|
+
var themeRef = useState(themeInput)[0];
|
|
13245
13309
|
var theme = useMemo(function () {
|
|
13246
|
-
return resolveTheme(themeRef
|
|
13247
|
-
}, []);
|
|
13310
|
+
return resolveTheme(themeRef);
|
|
13311
|
+
}, [themeRef]);
|
|
13248
13312
|
var colors = theme.colors;
|
|
13249
13313
|
useEffect(function () {
|
|
13250
13314
|
for (var name_1 in colors) {
|
|
@@ -13296,31 +13360,33 @@ var IdValidation = function IdValidation(_a) {
|
|
|
13296
13360
|
onLoadingOverlayDismissed = _a.onLoadingOverlayDismissed,
|
|
13297
13361
|
_d = _a.idCaptureRequirement,
|
|
13298
13362
|
idCaptureRequirement = _d === void 0 ? 'idCardOrPassport' : _d,
|
|
13299
|
-
_e = _a.
|
|
13300
|
-
|
|
13301
|
-
_f = _a.
|
|
13302
|
-
|
|
13303
|
-
_g = _a.
|
|
13304
|
-
|
|
13363
|
+
_e = _a.allowSinglePageIdCapture,
|
|
13364
|
+
allowSinglePageIdCapture = _e === void 0 ? false : _e,
|
|
13365
|
+
_f = _a.separateIdCardCaptureSequence,
|
|
13366
|
+
separateIdCardCaptureSequence = _f === void 0 ? false : _f,
|
|
13367
|
+
_g = _a.idCaptureThresholds,
|
|
13368
|
+
idCaptureThresholds = _g === void 0 ? defaultIdCaptureThresholds : _g,
|
|
13369
|
+
_h = _a.skipSuccessScreen,
|
|
13370
|
+
skipSuccessScreen = _h === void 0 ? false : _h,
|
|
13305
13371
|
instructions = _a.instructions,
|
|
13306
|
-
|
|
13307
|
-
guideType =
|
|
13308
|
-
|
|
13309
|
-
guideImages =
|
|
13310
|
-
|
|
13311
|
-
portraitGuidesOnMobile =
|
|
13312
|
-
|
|
13313
|
-
rotateLoadingOverlayImageWhenPortrait =
|
|
13314
|
-
|
|
13315
|
-
modelLoadTimeoutMs =
|
|
13316
|
-
|
|
13317
|
-
forceFallbackMode =
|
|
13318
|
-
|
|
13319
|
-
allowIdCardBackToFrontCapture =
|
|
13320
|
-
|
|
13321
|
-
enableOverrideWrongDocumentTypeDialog =
|
|
13322
|
-
|
|
13323
|
-
allowOverrideWrongDocumentTypeAfterMs =
|
|
13372
|
+
_j = _a.guideType,
|
|
13373
|
+
guideType = _j === void 0 ? 'fit' : _j,
|
|
13374
|
+
_k = _a.guideImages,
|
|
13375
|
+
guideImages = _k === void 0 ? defaultIdCaptureGuideImages : _k,
|
|
13376
|
+
_l = _a.portraitGuidesOnMobile,
|
|
13377
|
+
portraitGuidesOnMobile = _l === void 0 ? true : _l,
|
|
13378
|
+
_m = _a.rotateLoadingOverlayImageWhenPortrait,
|
|
13379
|
+
rotateLoadingOverlayImageWhenPortrait = _m === void 0 ? true : _m,
|
|
13380
|
+
_o = _a.modelLoadTimeoutMs,
|
|
13381
|
+
modelLoadTimeoutMs = _o === void 0 ? defaultDocumentDetectionModelLoadTimeoutMs : _o,
|
|
13382
|
+
_p = _a.forceFallbackMode,
|
|
13383
|
+
forceFallbackMode = _p === void 0 ? false : _p,
|
|
13384
|
+
_q = _a.allowIdCardBackToFrontCapture,
|
|
13385
|
+
allowIdCardBackToFrontCapture = _q === void 0 ? false : _q,
|
|
13386
|
+
_r = _a.enableOverrideWrongDocumentTypeDialog,
|
|
13387
|
+
enableOverrideWrongDocumentTypeDialog = _r === void 0 ? false : _r,
|
|
13388
|
+
_s = _a.allowOverrideWrongDocumentTypeAfterMs,
|
|
13389
|
+
allowOverrideWrongDocumentTypeAfterMs = _s === void 0 ? 8000 : _s,
|
|
13324
13390
|
onBeforeSubmit = _a.onBeforeSubmit,
|
|
13325
13391
|
onBeforeDocumentUpload = _a.onBeforeDocumentUpload,
|
|
13326
13392
|
onDocumentUploadProgress = _a.onDocumentUploadProgress,
|
|
@@ -13334,28 +13400,28 @@ var IdValidation = function IdValidation(_a) {
|
|
|
13334
13400
|
onUserCancel = _a.onUserCancel,
|
|
13335
13401
|
onModelError = _a.onModelError,
|
|
13336
13402
|
onCameraAccessDenied = _a.onCameraAccessDenied,
|
|
13337
|
-
|
|
13338
|
-
theme =
|
|
13339
|
-
|
|
13340
|
-
assets =
|
|
13341
|
-
|
|
13342
|
-
classNames =
|
|
13343
|
-
|
|
13344
|
-
colors =
|
|
13345
|
-
|
|
13346
|
-
verbiage =
|
|
13347
|
-
|
|
13348
|
-
captureSignature =
|
|
13349
|
-
|
|
13350
|
-
captureSignatureVideo =
|
|
13351
|
-
|
|
13352
|
-
captureAdditionalDocuments =
|
|
13353
|
-
|
|
13354
|
-
geolocationEnabled =
|
|
13355
|
-
|
|
13356
|
-
geolocationRequired =
|
|
13357
|
-
|
|
13358
|
-
debugMode =
|
|
13403
|
+
_t = _a.theme,
|
|
13404
|
+
theme = _t === void 0 ? 'default' : _t,
|
|
13405
|
+
_u = _a.assets,
|
|
13406
|
+
assets = _u === void 0 ? {} : _u,
|
|
13407
|
+
_v = _a.classNames,
|
|
13408
|
+
classNames = _v === void 0 ? {} : _v,
|
|
13409
|
+
_w = _a.colors,
|
|
13410
|
+
colors = _w === void 0 ? {} : _w,
|
|
13411
|
+
_x = _a.verbiage,
|
|
13412
|
+
verbiage = _x === void 0 ? {} : _x,
|
|
13413
|
+
_y = _a.captureSignature,
|
|
13414
|
+
captureSignature = _y === void 0 ? false : _y,
|
|
13415
|
+
_z = _a.captureSignatureVideo,
|
|
13416
|
+
captureSignatureVideo = _z === void 0 ? false : _z,
|
|
13417
|
+
_0 = _a.captureAdditionalDocuments,
|
|
13418
|
+
captureAdditionalDocuments = _0 === void 0 ? [] : _0,
|
|
13419
|
+
_1 = _a.geolocationEnabled,
|
|
13420
|
+
geolocationEnabled = _1 === void 0 ? true : _1,
|
|
13421
|
+
_2 = _a.geolocationRequired,
|
|
13422
|
+
geolocationRequired = _2 === void 0 ? false : _2,
|
|
13423
|
+
_3 = _a.debugMode,
|
|
13424
|
+
debugMode = _3 === void 0 ? false : _3;
|
|
13359
13425
|
useLanguage(lang);
|
|
13360
13426
|
useDebugLogging(debugMode);
|
|
13361
13427
|
var idCaptureProps = useMemo(function () {
|
|
@@ -13365,6 +13431,7 @@ var IdValidation = function IdValidation(_a) {
|
|
|
13365
13431
|
onModelError: onModelError,
|
|
13366
13432
|
precapturedDocuments: precapturedDocuments,
|
|
13367
13433
|
captureRequirement: idCaptureRequirement,
|
|
13434
|
+
allowSinglePageIdCapture: allowSinglePageIdCapture,
|
|
13368
13435
|
separateIdCardCaptureSequence: separateIdCardCaptureSequence,
|
|
13369
13436
|
thresholds: idCaptureThresholds,
|
|
13370
13437
|
skipSuccessScreen: skipSuccessScreen,
|
|
@@ -13387,7 +13454,7 @@ var IdValidation = function IdValidation(_a) {
|
|
|
13387
13454
|
verbiage: verbiage,
|
|
13388
13455
|
debugMode: debugMode
|
|
13389
13456
|
};
|
|
13390
|
-
}, [onExitCapture, onUserCancel, onModelError, precapturedDocuments, idCaptureRequirement, separateIdCardCaptureSequence, idCaptureThresholds, skipSuccessScreen, loadingOverlayMode, customOverlayContent, onLoadingOverlayDismissed, forceFallbackMode, allowIdCardBackToFrontCapture, instructions, guideType, guideImages, portraitGuidesOnMobile, rotateLoadingOverlayImageWhenPortrait, modelLoadTimeoutMs, enableOverrideWrongDocumentTypeDialog, allowOverrideWrongDocumentTypeAfterMs, assets, classNames, colors, verbiage, debugMode]);
|
|
13457
|
+
}, [onExitCapture, onUserCancel, onModelError, precapturedDocuments, idCaptureRequirement, allowSinglePageIdCapture, separateIdCardCaptureSequence, idCaptureThresholds, skipSuccessScreen, loadingOverlayMode, customOverlayContent, onLoadingOverlayDismissed, forceFallbackMode, allowIdCardBackToFrontCapture, instructions, guideType, guideImages, portraitGuidesOnMobile, rotateLoadingOverlayImageWhenPortrait, modelLoadTimeoutMs, enableOverrideWrongDocumentTypeDialog, allowOverrideWrongDocumentTypeAfterMs, assets, classNames, colors, verbiage, debugMode]);
|
|
13391
13458
|
var additionalDocumentCaptureProps = useMemo(function () {
|
|
13392
13459
|
return {
|
|
13393
13460
|
documents: captureAdditionalDocuments,
|
|
@@ -15743,7 +15810,9 @@ function renderElement(component, targetElement) {
|
|
|
15743
15810
|
try {
|
|
15744
15811
|
root.unmount();
|
|
15745
15812
|
originalRemove_1();
|
|
15746
|
-
} catch (e) {
|
|
15813
|
+
} catch (e) {
|
|
15814
|
+
debug('failed to unmount', e);
|
|
15815
|
+
}
|
|
15747
15816
|
};
|
|
15748
15817
|
}
|
|
15749
15818
|
return targetElement;
|