idmission-web-sdk 2.2.15 → 2.2.17

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/sdk2.esm.js CHANGED
@@ -5,6 +5,7 @@ import platform from 'platform';
5
5
  import styled, { keyframes, useTheme, ThemeProvider as ThemeProvider$1 } from 'styled-components';
6
6
  import { useTranslation, initReactI18next } from 'react-i18next';
7
7
  import { Upload } from 'tus-js-client';
8
+ import CryptoJS from 'crypto-js';
8
9
  import useResizeObserver from 'use-resize-observer';
9
10
  import { ImageSegmenter, FilesetResolver, ImageClassifier, FaceDetector, ObjectDetector } from '@mediapipe/tasks-vision';
10
11
  import { useDebouncedCallback, useThrottledCallback } from 'use-debounce';
@@ -200,7 +201,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
200
201
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
201
202
  };
202
203
 
203
- var webSdkVersion = '2.2.15';
204
+ var webSdkVersion = '2.2.17';
204
205
 
205
206
  function getPlatform() {
206
207
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -1293,51 +1294,54 @@ var SubmissionProvider = function SubmissionProvider(_a) {
1293
1294
  var uploadDocument = useCallback(function (src, metadata) {
1294
1295
  return new Promise(function (resolve, reject) {
1295
1296
  return __awaiter(void 0, void 0, void 0, function () {
1296
- var blob, _a, upload;
1297
- var _b;
1298
- return __generator(this, function (_c) {
1299
- switch (_c.label) {
1297
+ var blob, _a, upload, _b, _c;
1298
+ var _d, _e;
1299
+ var _f;
1300
+ return __generator(this, function (_g) {
1301
+ switch (_g.label) {
1300
1302
  case 0:
1301
1303
  blob = typeof src === 'string' ? convertBase64ToBlob(src) : src;
1302
1304
  _a = onBeforeDocumentUpload.current;
1303
1305
  if (!_a) return [3 /*break*/, 2];
1304
- return [4 /*yield*/, (_b = onBeforeDocumentUpload.current) === null || _b === void 0 ? void 0 : _b.call(onBeforeDocumentUpload, blob, metadata)];
1306
+ return [4 /*yield*/, (_f = onBeforeDocumentUpload.current) === null || _f === void 0 ? void 0 : _f.call(onBeforeDocumentUpload, blob, metadata)];
1305
1307
  case 1:
1306
- _a = _c.sent() === false;
1307
- _c.label = 2;
1308
+ _a = _g.sent() === false;
1309
+ _g.label = 2;
1308
1310
  case 2:
1309
1311
  if (_a) return [2 /*return*/, resolve(blobToB64(blob))];
1310
- upload = createUpload(blob, {
1312
+ _b = createUpload;
1313
+ _c = [blob];
1314
+ _d = {
1311
1315
  endpoint: documentServiceUrl,
1312
1316
  retryDelays: [0, 1000, 1000, 1000, 3000, 5000, 10000, 20000],
1313
1317
  headers: {
1314
1318
  'X-Session-Id': sessionId
1315
- },
1316
- metadata: metadata || {
1317
- filetype: blob.type
1318
- },
1319
- onProgress: function onProgress(bytesUploaded, bytesTotal) {
1320
- var _a;
1321
- (_a = onDocumentUploadProgress.current) === null || _a === void 0 ? void 0 : _a.call(onDocumentUploadProgress, {
1322
- bytesUploaded: bytesUploaded,
1323
- bytesTotal: bytesTotal,
1324
- percentage: (bytesUploaded / bytesTotal * 100).toFixed(2) + '%',
1325
- metadata: metadata
1326
- });
1327
- },
1328
- onSuccess: function onSuccess() {
1329
- var _a, _b;
1330
- var documentId = 'urn:documentsv1:' + ((_a = upload.url.split('/files/').pop()) === null || _a === void 0 ? void 0 : _a.split('+').shift());
1331
- (_b = onDocumentUploaded.current) === null || _b === void 0 ? void 0 : _b.call(onDocumentUploaded, documentId, metadata);
1332
- resolve(documentId);
1333
- },
1334
- onError: function onError(error) {
1335
- var _a;
1336
- log('Failed because: ' + error);
1337
- (_a = onDocumentUploadFailed.current) === null || _a === void 0 ? void 0 : _a.call(onDocumentUploadFailed, error, metadata);
1338
- reject(error);
1339
1319
  }
1340
- });
1320
+ };
1321
+ _e = {
1322
+ filetype: blob.type
1323
+ };
1324
+ return [4 /*yield*/, calculateMd5(blob)];
1325
+ case 3:
1326
+ upload = _b.apply(void 0, _c.concat([(_d.metadata = _assign.apply(void 0, [(_e.fingerprint = _g.sent(), _e), metadata || {}]), _d.onProgress = function (bytesUploaded, bytesTotal) {
1327
+ var _a;
1328
+ (_a = onDocumentUploadProgress.current) === null || _a === void 0 ? void 0 : _a.call(onDocumentUploadProgress, {
1329
+ bytesUploaded: bytesUploaded,
1330
+ bytesTotal: bytesTotal,
1331
+ percentage: (bytesUploaded / bytesTotal * 100).toFixed(2) + '%',
1332
+ metadata: metadata
1333
+ });
1334
+ }, _d.onSuccess = function () {
1335
+ var _a, _b;
1336
+ var documentId = 'urn:documentsv1:' + ((_a = upload.url.split('/files/').pop()) === null || _a === void 0 ? void 0 : _a.split('+').shift());
1337
+ (_b = onDocumentUploaded.current) === null || _b === void 0 ? void 0 : _b.call(onDocumentUploaded, documentId, metadata);
1338
+ resolve(documentId);
1339
+ }, _d.onError = function (error) {
1340
+ var _a;
1341
+ log('Failed because: ' + error);
1342
+ (_a = onDocumentUploadFailed.current) === null || _a === void 0 ? void 0 : _a.call(onDocumentUploadFailed, error, metadata);
1343
+ reject(error);
1344
+ }, _d)]));
1341
1345
  // Check if there are any previous uploads to continue.
1342
1346
  upload.findPreviousUploads().then(function (previousUploads) {
1343
1347
  // Found previous uploads so we select the first one.
@@ -1871,6 +1875,16 @@ function convertBase64ToBlob(base64Image) {
1871
1875
  type: imageType
1872
1876
  });
1873
1877
  }
1878
+ function calculateMd5(blob) {
1879
+ return new Promise(function (resolve, reject) {
1880
+ var reader = new FileReader();
1881
+ reader.readAsArrayBuffer(blob);
1882
+ reader.onloadend = function () {
1883
+ if (!reader.result) return reject(new Error('Failed to read file'));
1884
+ resolve(CryptoJS.MD5(reader.result.toString()).toString());
1885
+ };
1886
+ });
1887
+ }
1874
1888
 
1875
1889
  function getFrameDimensions(frame) {
1876
1890
  var frameWidth = frame.width,
@@ -11587,6 +11601,11 @@ var VideoSignatureWizard = function VideoSignatureWizard(_a) {
11587
11601
  setCaptureState('CAPTURING_SIGNATURE');
11588
11602
  }
11589
11603
  }, [allowSignatureAfterLivenessCheckFailure, onExitAfterFailureProp]);
11604
+ var faceLivenessOnLoadingOverlayDismissed = faceLivenessProps === null || faceLivenessProps === void 0 ? void 0 : faceLivenessProps.onLoadingOverlayDismissed;
11605
+ var onLoadingOverlayDismissedCallback = useCallback(function () {
11606
+ onLoadingOverlayDismissed === null || onLoadingOverlayDismissed === void 0 ? void 0 : onLoadingOverlayDismissed();
11607
+ faceLivenessOnLoadingOverlayDismissed === null || faceLivenessOnLoadingOverlayDismissed === void 0 ? void 0 : faceLivenessOnLoadingOverlayDismissed();
11608
+ }, [faceLivenessOnLoadingOverlayDismissed, onLoadingOverlayDismissed]);
11590
11609
  return /*#__PURE__*/React__default.createElement(VideoSignatureContextProvider, null, /*#__PURE__*/React__default.createElement(PageContainer, {
11591
11610
  className: "flex ".concat((_b = classNames === null || classNames === void 0 ? void 0 : classNames.container) !== null && _b !== void 0 ? _b : '')
11592
11611
  }, /*#__PURE__*/React__default.createElement(CameraVideoTag, {
@@ -11601,7 +11620,7 @@ var VideoSignatureWizard = function VideoSignatureWizard(_a) {
11601
11620
  onExitCapture: onExit,
11602
11621
  onUserCancel: onUserCancel,
11603
11622
  onExitAfterFailure: onExitAfterFailure,
11604
- onLoadingOverlayDismissed: onLoadingOverlayDismissed,
11623
+ onLoadingOverlayDismissed: onLoadingOverlayDismissedCallback,
11605
11624
  customOverlayContent: customOverlayContent,
11606
11625
  loadingOverlayMode: loadingOverlayMode,
11607
11626
  guidesComponent: guidesComponent,