idmission-web-sdk 1.0.103 → 1.0.105
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/customer_flows/DocumentCapture.d.ts +4 -0
- package/dist/components/document_capture/DocumentCaptureGuideOverlay.d.ts +1 -1
- package/dist/components/document_capture/DocumentCaptureScreen.d.ts +15 -0
- package/dist/components/document_capture/DocumentCaptureStateProvider.d.ts +68 -0
- package/dist/components/document_capture/DocumentCaptureWizard.d.ts +4 -5
- package/dist/components/id_capture/IdCaptureModelsProvider.d.ts +5 -1
- package/dist/components/submission/SubmissionProvider.d.ts +3 -1
- package/dist/sdk2.cjs.development.js +108 -87
- 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 +107 -87
- package/dist/sdk2.esm.js.map +1 -1
- package/dist/sdk2.umd.development.js +8707 -97
- 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/stories/CustomerFlows/DocumentCapture.stories.d.ts +7 -0
- package/dist/themes/index.d.ts +3 -0
- package/dist/version.d.ts +1 -1
- package/package.json +5 -1
|
@@ -3,6 +3,7 @@ import { ThemeInput } from '../../themes';
|
|
|
3
3
|
import { LangOption } from '../../lib/locales';
|
|
4
4
|
import { SubmissionRequest, SubmissionResponse } from '../../contexts/SubmissionContext';
|
|
5
5
|
import { DocumentCaptureWizardClassNames } from '../document_capture/DocumentCaptureWizard';
|
|
6
|
+
import { CameraFeedMode } from '../document_capture/DocumentCaptureScreen';
|
|
6
7
|
export type DocumentCaptureClassNames = DocumentCaptureWizardClassNames;
|
|
7
8
|
export interface DocumentCaptureProps extends PropsWithChildren {
|
|
8
9
|
/** Language code to use. Supported values: 'auto' (detect based on user's OS), 'en' (English), 'es' (Spanish). Defaults to auto. */
|
|
@@ -11,6 +12,8 @@ export interface DocumentCaptureProps extends PropsWithChildren {
|
|
|
11
12
|
submissionToken: string;
|
|
12
13
|
/** URL to hit with all API requests. Defaults to the value specified in your decoded `submissionToken`. */
|
|
13
14
|
submissionUrl?: string;
|
|
15
|
+
/** URL to upload captured documents to via Tus. */
|
|
16
|
+
documentServiceUrl?: string;
|
|
14
17
|
/** Callback function that fires immediately prior to submission, giving the client application an opportunity to specify custom asynchronous logic that mutates the request before it executes. The submission request is passed in as a parameter and a promise resolving to the updated request should be returned. */
|
|
15
18
|
onBeforeSubmit?: (req: SubmissionRequest) => Promise<SubmissionRequest>;
|
|
16
19
|
/** Callback function that fires when the user has completed the flow instead of making a call to IDmission's servers, allowing customers to specify their own submission logic. Arguments: the request payload that would have been dispatched to IDmission's API, which contains the images/documents/video submitted by the user. Note that when this parameter is supplied, `onComplete` will never fire, and the customer will need to implement their own error handling/retry logic. Use at your own risk! */
|
|
@@ -22,6 +25,7 @@ export interface DocumentCaptureProps extends PropsWithChildren {
|
|
|
22
25
|
/** Callback function that fires when the user clicks the exit button from the loading overlay, declining to engage with IDmission. Binding this callback results in the cancel button being rendered on the loading overlay. */
|
|
23
26
|
onUserCancel?: () => void;
|
|
24
27
|
aspectRatio?: number;
|
|
28
|
+
cameraFeedMode?: CameraFeedMode;
|
|
25
29
|
instructions?: ReactNode;
|
|
26
30
|
/** Name of an included theme or object containing theme properties. **/
|
|
27
31
|
theme?: ThemeInput;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
export type CameraFeedMode = 'snapToGuides' | 'fullscreen';
|
|
3
|
+
export type DocumentCaptureScreenClassNames = {
|
|
4
|
+
container?: string;
|
|
5
|
+
cameraFeed?: string;
|
|
6
|
+
};
|
|
7
|
+
export type DocumentCaptureScreenProps = {
|
|
8
|
+
aspectRatio?: number;
|
|
9
|
+
cameraFeedMode?: CameraFeedMode;
|
|
10
|
+
classNames?: DocumentCaptureScreenClassNames;
|
|
11
|
+
instructions?: ReactNode;
|
|
12
|
+
onCaptureClicked?: () => void;
|
|
13
|
+
onSuccess?: (blob: Blob) => void;
|
|
14
|
+
};
|
|
15
|
+
export declare const DocumentCaptureScreen: ({ aspectRatio, cameraFeedMode, classNames, instructions, onCaptureClicked, onSuccess, }: DocumentCaptureScreenProps) => React.JSX.Element;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import React, { Dispatch, ReactNode } from 'react';
|
|
2
|
+
export type DocumentCaptureState = {
|
|
3
|
+
initialDrawComplete: boolean;
|
|
4
|
+
redrawing: boolean;
|
|
5
|
+
rectX: number;
|
|
6
|
+
rectY: number;
|
|
7
|
+
rectWidth: number;
|
|
8
|
+
rectHeight: number;
|
|
9
|
+
rectOffsetTop: number;
|
|
10
|
+
capturing: boolean;
|
|
11
|
+
imageUrl: string;
|
|
12
|
+
imageBlob: Blob | null;
|
|
13
|
+
uploadState: 'not_started' | 'in_progress' | 'succeeded' | 'failed';
|
|
14
|
+
};
|
|
15
|
+
export declare const documentCaptureInitialState: {
|
|
16
|
+
initialDrawComplete: false;
|
|
17
|
+
redrawing: false;
|
|
18
|
+
capturing: false;
|
|
19
|
+
rectX: number;
|
|
20
|
+
rectY: number;
|
|
21
|
+
rectWidth: number;
|
|
22
|
+
rectHeight: number;
|
|
23
|
+
rectOffsetTop: number;
|
|
24
|
+
imageUrl: string;
|
|
25
|
+
imageBlob: null;
|
|
26
|
+
uploadState: "not_started";
|
|
27
|
+
};
|
|
28
|
+
export declare const DocumentCaptureStateContext: React.Context<DocumentCaptureState>;
|
|
29
|
+
export type DocumentCaptureAction = {
|
|
30
|
+
type: 'redrawRequested';
|
|
31
|
+
} | {
|
|
32
|
+
type: 'redrawInProgress';
|
|
33
|
+
} | {
|
|
34
|
+
type: 'redrawCompleted';
|
|
35
|
+
payload: {
|
|
36
|
+
rectX: number;
|
|
37
|
+
rectY: number;
|
|
38
|
+
rectWidth: number;
|
|
39
|
+
rectHeight: number;
|
|
40
|
+
rectOffsetTop: number;
|
|
41
|
+
};
|
|
42
|
+
} | {
|
|
43
|
+
type: 'captureRequested';
|
|
44
|
+
} | {
|
|
45
|
+
type: 'captureCompleted';
|
|
46
|
+
payload: {
|
|
47
|
+
imageUrl: string;
|
|
48
|
+
imageBlob: Blob;
|
|
49
|
+
};
|
|
50
|
+
} | {
|
|
51
|
+
type: 'retryCapture';
|
|
52
|
+
} | {
|
|
53
|
+
type: 'uploadStarted';
|
|
54
|
+
} | {
|
|
55
|
+
type: 'uploadCompleted';
|
|
56
|
+
} | {
|
|
57
|
+
type: 'uploadFailed';
|
|
58
|
+
};
|
|
59
|
+
export type DocumentCaptureDispatch = Dispatch<DocumentCaptureAction>;
|
|
60
|
+
export declare const DocumentCaptureDispatchContext: React.Context<DocumentCaptureDispatch>;
|
|
61
|
+
export declare const documentCaptureStateReducer: (state: DocumentCaptureState, action: DocumentCaptureAction) => DocumentCaptureState;
|
|
62
|
+
export declare const DocumentCaptureStateProvider: ({ children, }: {
|
|
63
|
+
children: ReactNode;
|
|
64
|
+
}) => React.JSX.Element;
|
|
65
|
+
export declare const useDocumentCaptureState: () => [
|
|
66
|
+
DocumentCaptureState,
|
|
67
|
+
DocumentCaptureDispatch
|
|
68
|
+
];
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import React, { ReactNode } from 'react';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
cameraFeed?: string;
|
|
5
|
-
};
|
|
2
|
+
import { CameraFeedMode, DocumentCaptureScreenClassNames } from './DocumentCaptureScreen';
|
|
3
|
+
export type DocumentCaptureWizardClassNames = DocumentCaptureScreenClassNames;
|
|
6
4
|
export type DocumentCaptureWizardProps = {
|
|
7
5
|
onSuccess?: () => void;
|
|
8
6
|
onExitCapture?: () => void;
|
|
9
7
|
onUserCancel?: () => void;
|
|
10
8
|
aspectRatio?: number;
|
|
9
|
+
cameraFeedMode?: CameraFeedMode;
|
|
11
10
|
instructions?: ReactNode;
|
|
12
11
|
classNames?: DocumentCaptureWizardClassNames;
|
|
13
12
|
};
|
|
14
|
-
export declare const DocumentCaptureWizard: ({ aspectRatio, instructions, classNames, }: DocumentCaptureWizardProps) => React.JSX.Element;
|
|
13
|
+
export declare const DocumentCaptureWizard: ({ onSuccess, aspectRatio, cameraFeedMode, instructions, classNames, }: DocumentCaptureWizardProps) => React.JSX.Element;
|
|
@@ -16,6 +16,7 @@ export type IdCapturePrediction = {
|
|
|
16
16
|
bestDocumentOrPassport: DetectedObject | undefined;
|
|
17
17
|
bestMrz: DetectedObject | undefined;
|
|
18
18
|
bestPdf417: DetectedObject | undefined;
|
|
19
|
+
documentInBounds: boolean;
|
|
19
20
|
focusScore: number;
|
|
20
21
|
focusThresholdMet: boolean;
|
|
21
22
|
focusPredictionTime: number;
|
|
@@ -28,7 +29,10 @@ export type IdCaptureThresholds = {
|
|
|
28
29
|
passport?: number;
|
|
29
30
|
mrz?: number;
|
|
30
31
|
pdf417?: number;
|
|
31
|
-
focus?:
|
|
32
|
+
focus?: {
|
|
33
|
+
desktop?: number;
|
|
34
|
+
mobile?: number;
|
|
35
|
+
};
|
|
32
36
|
};
|
|
33
37
|
export declare const PREDICTION_POSITIONS: {
|
|
34
38
|
boxes: number;
|
|
@@ -32,6 +32,7 @@ export type SubmissionState = {
|
|
|
32
32
|
setIdCaptureVideoIdFrontImage: (image: string) => void;
|
|
33
33
|
setIdCaptureVideoIdBackImage: (image: string) => void;
|
|
34
34
|
setAdditionalDocuments: (uploadedDocuments: UploadedDocument[]) => void;
|
|
35
|
+
uploadDocument: (blob: Blob) => Promise<string>;
|
|
35
36
|
logIdFrontCaptureAttempt: (attempt: CaptureAttemptMetadata) => void;
|
|
36
37
|
logIdBackCaptureAttempt: (attempt: CaptureAttemptMetadata) => void;
|
|
37
38
|
logSelfieCaptureAttempt: (attempt: CaptureAttemptMetadata) => void;
|
|
@@ -68,10 +69,11 @@ export type SubmissionProviderProps = {
|
|
|
68
69
|
webhooksSendProcessedImages?: boolean;
|
|
69
70
|
webhooksFireOnReview?: boolean;
|
|
70
71
|
precapturedDocuments?: CapturedDocuments;
|
|
72
|
+
documentServiceUrl?: string;
|
|
71
73
|
onSubmit?: (payload: SubmissionRequest) => void;
|
|
72
74
|
onBeforeSubmit?: (req: SubmissionRequest) => Promise<SubmissionRequest>;
|
|
73
75
|
onBeforeLivenessCheck?: (req: LivenessCheckRequest) => Promise<LivenessCheckRequest>;
|
|
74
76
|
onResponseReceived?: (res: SubmissionResponse, req: SubmissionRequest) => void;
|
|
75
77
|
onRequestFailure?: (err: Error) => void;
|
|
76
78
|
};
|
|
77
|
-
export declare const SubmissionProvider: ({ action, children, url, environment, token, companyId, enrollmentId, personalData, cardData, bypassAgeValidation, bypassNameMatching, needImmediateResponse, manualReviewRequired, idBackImageRequired, idImageResolutionCheck, verifyIdWithExternalDatabases, deduplicationEnabled, deduplicationSynchronous, geolocationEnabled, geolocationRequired, webhooksEnabled, webhooksClientTraceId, webhooksStripSpecialCharacters, webhooksSendInputImages, webhooksSendProcessedImages, webhooksFireOnReview, precapturedDocuments, onSubmit, onBeforeSubmit, onBeforeLivenessCheck, onResponseReceived, onRequestFailure, }: SubmissionProviderProps) => ReactElement;
|
|
79
|
+
export declare const SubmissionProvider: ({ action, children, url, environment, token, companyId, enrollmentId, personalData, cardData, bypassAgeValidation, bypassNameMatching, needImmediateResponse, manualReviewRequired, idBackImageRequired, idImageResolutionCheck, verifyIdWithExternalDatabases, deduplicationEnabled, deduplicationSynchronous, geolocationEnabled, geolocationRequired, webhooksEnabled, webhooksClientTraceId, webhooksStripSpecialCharacters, webhooksSendInputImages, webhooksSendProcessedImages, webhooksFireOnReview, precapturedDocuments, documentServiceUrl, onSubmit, onBeforeSubmit, onBeforeLivenessCheck, onResponseReceived, onRequestFailure, }: SubmissionProviderProps) => ReactElement;
|
|
@@ -7,6 +7,7 @@ var React = require('react');
|
|
|
7
7
|
var ReactDOM = require('react-dom/client');
|
|
8
8
|
var styled = require('styled-components');
|
|
9
9
|
var reactI18next = require('react-i18next');
|
|
10
|
+
var tus = require('tus-js-client');
|
|
10
11
|
var useResizeObserver = require('use-resize-observer');
|
|
11
12
|
var tf = require('@tensorflow/tfjs');
|
|
12
13
|
var LanguageDetector = require('i18next-browser-languagedetector');
|
|
@@ -40,15 +41,17 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
|
40
41
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
41
42
|
var ReactDOM__namespace = /*#__PURE__*/_interopNamespace(ReactDOM);
|
|
42
43
|
var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
|
|
44
|
+
var tus__namespace = /*#__PURE__*/_interopNamespace(tus);
|
|
43
45
|
var useResizeObserver__default = /*#__PURE__*/_interopDefaultLegacy(useResizeObserver);
|
|
44
46
|
var tf__namespace = /*#__PURE__*/_interopNamespace(tf);
|
|
45
47
|
var LanguageDetector__default = /*#__PURE__*/_interopDefaultLegacy(LanguageDetector);
|
|
46
48
|
var i18n__default = /*#__PURE__*/_interopDefaultLegacy(i18n);
|
|
47
49
|
var SignatureCanvas__default = /*#__PURE__*/_interopDefaultLegacy(SignatureCanvas);
|
|
48
50
|
|
|
49
|
-
var webSdkVersion = '1.0.
|
|
51
|
+
var webSdkVersion = '1.0.105';
|
|
50
52
|
|
|
51
53
|
function getPlatform() {
|
|
54
|
+
if (typeof window === 'undefined') return;
|
|
52
55
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
53
56
|
// @ts-ignore
|
|
54
57
|
return window.platform;
|
|
@@ -149,7 +152,7 @@ function attachMetadataToRequest(request, _a) {
|
|
|
149
152
|
back: idBackCaptureAttempts,
|
|
150
153
|
isRealIDCheckRequired: 'false',
|
|
151
154
|
sdkVersion: "WebSDK_".concat(webSdkVersion),
|
|
152
|
-
Resolution: "".concat(window.innerWidth, " x ").concat(window.innerHeight)
|
|
155
|
+
Resolution: typeof window !== 'undefined' ? "".concat(window.innerWidth, " x ").concat(window.innerHeight) : 'unknown'
|
|
153
156
|
};
|
|
154
157
|
var platform = getPlatform();
|
|
155
158
|
if (platform) {
|
|
@@ -193,6 +196,7 @@ var PageContainer = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
|
193
196
|
dimensionsCalculated = _c[0],
|
|
194
197
|
setDimensionsCalculated = _c[1];
|
|
195
198
|
React.useEffect(function () {
|
|
199
|
+
if (typeof window === 'undefined') return;
|
|
196
200
|
setDimensionsCalculated(false);
|
|
197
201
|
var calcAppDimensions = function calcAppDimensions() {
|
|
198
202
|
var doc = document.documentElement;
|
|
@@ -663,6 +667,7 @@ var SubmissionContext = /*#__PURE__*/React.createContext({
|
|
|
663
667
|
setAdditionalDocuments: function setAdditionalDocuments() {
|
|
664
668
|
return null;
|
|
665
669
|
},
|
|
670
|
+
uploadDocument: Promise.resolve,
|
|
666
671
|
logIdFrontCaptureAttempt: function logIdFrontCaptureAttempt() {
|
|
667
672
|
return null;
|
|
668
673
|
},
|
|
@@ -729,6 +734,7 @@ var SubmissionProvider = function SubmissionProvider(_a) {
|
|
|
729
734
|
_t = _a.webhooksFireOnReview,
|
|
730
735
|
webhooksFireOnReview = _t === void 0 ? false : _t,
|
|
731
736
|
precapturedDocuments = _a.precapturedDocuments,
|
|
737
|
+
documentServiceUrl = _a.documentServiceUrl,
|
|
732
738
|
onSubmit = _a.onSubmit,
|
|
733
739
|
onBeforeSubmit = _a.onBeforeSubmit,
|
|
734
740
|
onBeforeLivenessCheck = _a.onBeforeLivenessCheck,
|
|
@@ -1167,6 +1173,7 @@ var SubmissionProvider = function SubmissionProvider(_a) {
|
|
|
1167
1173
|
tokenError = _17[0],
|
|
1168
1174
|
setTokenError = _17[1];
|
|
1169
1175
|
React.useEffect(function () {
|
|
1176
|
+
if (typeof window === 'undefined') return;
|
|
1170
1177
|
(function () {
|
|
1171
1178
|
return tslib.__awaiter(void 0, void 0, void 0, function () {
|
|
1172
1179
|
var parsed, iss, publicKey, resp, e_3, valid, parts, e_4, exp;
|
|
@@ -1239,6 +1246,42 @@ var SubmissionProvider = function SubmissionProvider(_a) {
|
|
|
1239
1246
|
});
|
|
1240
1247
|
})();
|
|
1241
1248
|
}, [token]);
|
|
1249
|
+
var uploadDocument = React.useCallback(function (blob) {
|
|
1250
|
+
return new Promise(function (resolve, reject) {
|
|
1251
|
+
var upload = new tus__namespace.Upload(blob, {
|
|
1252
|
+
endpoint: documentServiceUrl,
|
|
1253
|
+
retryDelays: [0, 3000, 5000, 10000, 20000],
|
|
1254
|
+
metadata: {
|
|
1255
|
+
filename: 'My File',
|
|
1256
|
+
filetype: 'image/jpeg'
|
|
1257
|
+
},
|
|
1258
|
+
headers: {
|
|
1259
|
+
Authorization: "Bearer ".concat(token)
|
|
1260
|
+
},
|
|
1261
|
+
onProgress: function onProgress(bytesUploaded, bytesTotal) {
|
|
1262
|
+
var percentage = (bytesUploaded / bytesTotal * 100).toFixed(2);
|
|
1263
|
+
console.log(bytesUploaded, bytesTotal, percentage + '%');
|
|
1264
|
+
},
|
|
1265
|
+
onSuccess: function onSuccess() {
|
|
1266
|
+
console.log('Download from %s', upload.url);
|
|
1267
|
+
resolve(upload.url);
|
|
1268
|
+
},
|
|
1269
|
+
onError: function onError(error) {
|
|
1270
|
+
console.log('Failed because: ' + error);
|
|
1271
|
+
reject(error);
|
|
1272
|
+
}
|
|
1273
|
+
});
|
|
1274
|
+
// Check if there are any previous uploads to continue.
|
|
1275
|
+
upload.findPreviousUploads().then(function (previousUploads) {
|
|
1276
|
+
// Found previous uploads so we select the first one.
|
|
1277
|
+
if (previousUploads.length) {
|
|
1278
|
+
upload.resumeFromPreviousUpload(previousUploads[0]);
|
|
1279
|
+
}
|
|
1280
|
+
// Start the upload
|
|
1281
|
+
upload.start();
|
|
1282
|
+
});
|
|
1283
|
+
});
|
|
1284
|
+
}, [token]);
|
|
1242
1285
|
var value = {
|
|
1243
1286
|
submit: submit,
|
|
1244
1287
|
submissionStatus: submissionStatus,
|
|
@@ -1266,6 +1309,7 @@ var SubmissionProvider = function SubmissionProvider(_a) {
|
|
|
1266
1309
|
setIdCaptureVideoIdFrontImage: setIdCaptureVideoIdFrontImage,
|
|
1267
1310
|
setIdCaptureVideoIdBackImage: setIdCaptureVideoIdBackImage,
|
|
1268
1311
|
setAdditionalDocuments: setAdditionalDocuments,
|
|
1312
|
+
uploadDocument: uploadDocument,
|
|
1269
1313
|
logIdFrontCaptureAttempt: logIdFrontCaptureAttempt,
|
|
1270
1314
|
logIdBackCaptureAttempt: logIdBackCaptureAttempt,
|
|
1271
1315
|
logSelfieCaptureAttempt: logSelfieCaptureAttempt,
|
|
@@ -1309,6 +1353,7 @@ function str2ab(str) {
|
|
|
1309
1353
|
return buf;
|
|
1310
1354
|
}
|
|
1311
1355
|
function importRsaKey(pem) {
|
|
1356
|
+
if (typeof window === 'undefined') throw new Error('window cannot be undefined');
|
|
1312
1357
|
// fetch the part of the PEM string between header and footer
|
|
1313
1358
|
var pemHeader = '-----BEGIN PUBLIC KEY-----';
|
|
1314
1359
|
var pemFooter = '-----END PUBLIC KEY-----';
|
|
@@ -8781,39 +8826,27 @@ var IdCaptureModelsProvider = function IdCaptureModelsProvider(_a) {
|
|
|
8781
8826
|
var _c = React.useState(false),
|
|
8782
8827
|
ready = _c[0],
|
|
8783
8828
|
setReady = _c[1];
|
|
8784
|
-
var _d = React.useState(
|
|
8785
|
-
|
|
8786
|
-
|
|
8787
|
-
var _e = React.useState(0),
|
|
8788
|
-
passportDetectionThreshold = _e[0],
|
|
8789
|
-
setPassportDetectionThreshold = _e[1];
|
|
8790
|
-
var _f = React.useState(0),
|
|
8791
|
-
mrzDetectionThreshold = _f[0],
|
|
8792
|
-
setMrzDetectionThreshold = _f[1];
|
|
8793
|
-
var _g = React.useState(0),
|
|
8794
|
-
pdf417DetectionThreshold = _g[0],
|
|
8795
|
-
setPdf417DetectionThreshold = _g[1];
|
|
8796
|
-
var _h = React.useState(0),
|
|
8797
|
-
focusThreshold = _h[0],
|
|
8798
|
-
setFocusThreshold = _h[1];
|
|
8829
|
+
var _d = React.useState({}),
|
|
8830
|
+
thresholds = _d[0],
|
|
8831
|
+
setThresholds = _d[1];
|
|
8799
8832
|
var working = React.useRef(false);
|
|
8800
8833
|
var onPredictionHandler = React.useRef();
|
|
8801
8834
|
var lastPredictionCanvas = React.useRef(null);
|
|
8835
|
+
var _e = React.useState(0),
|
|
8836
|
+
detectionTime = _e[0],
|
|
8837
|
+
setDetectionTime = _e[1];
|
|
8838
|
+
var _f = React.useState(0),
|
|
8839
|
+
focusPredictionTime = _f[0],
|
|
8840
|
+
setFocusPredictionTime = _f[1];
|
|
8841
|
+
var _g = React.useState(null),
|
|
8842
|
+
loadingError = _g[0],
|
|
8843
|
+
setLoadingError = _g[1];
|
|
8844
|
+
var _h = React.useState(0),
|
|
8845
|
+
bestFrameDetectionScore = _h[0],
|
|
8846
|
+
setBestFrameDetectionScore = _h[1];
|
|
8802
8847
|
var _j = React.useState(0),
|
|
8803
|
-
|
|
8804
|
-
|
|
8805
|
-
var _k = React.useState(0),
|
|
8806
|
-
focusPredictionTime = _k[0],
|
|
8807
|
-
setFocusPredictionTime = _k[1];
|
|
8808
|
-
var _l = React.useState(null),
|
|
8809
|
-
loadingError = _l[0],
|
|
8810
|
-
setLoadingError = _l[1];
|
|
8811
|
-
var _m = React.useState(0),
|
|
8812
|
-
bestFrameDetectionScore = _m[0],
|
|
8813
|
-
setBestFrameDetectionScore = _m[1];
|
|
8814
|
-
var _o = React.useState(0),
|
|
8815
|
-
bestFrameFocusScore = _o[0],
|
|
8816
|
-
setBestFrameFocusScore = _o[1];
|
|
8848
|
+
bestFrameFocusScore = _j[0],
|
|
8849
|
+
setBestFrameFocusScore = _j[1];
|
|
8817
8850
|
React.useEffect(function () {
|
|
8818
8851
|
setReady(false);
|
|
8819
8852
|
var ddmUrl = documentDetectionModelUrl || defaultDocumentDetectionModelUrl;
|
|
@@ -8875,25 +8908,9 @@ var IdCaptureModelsProvider = function IdCaptureModelsProvider(_a) {
|
|
|
8875
8908
|
(_a = webGLCanvas.removeEventListener) === null || _a === void 0 ? void 0 : _a.call(webGLCanvas, 'webglcontextlost', reloadModels);
|
|
8876
8909
|
};
|
|
8877
8910
|
}, [documentDetectionModelUrl, focusModelUrl]);
|
|
8878
|
-
var
|
|
8879
|
-
|
|
8880
|
-
|
|
8881
|
-
passport: passportDetectionThreshold,
|
|
8882
|
-
mrz: mrzDetectionThreshold,
|
|
8883
|
-
pdf417: pdf417DetectionThreshold,
|
|
8884
|
-
focus: focusThreshold
|
|
8885
|
-
};
|
|
8886
|
-
}, [documentDetectionThreshold, focusThreshold, mrzDetectionThreshold, passportDetectionThreshold, pdf417DetectionThreshold]);
|
|
8887
|
-
var setThresholds = React.useCallback(function (thresholds) {
|
|
8888
|
-
if (thresholds.document) setDocumentDetectionThreshold(thresholds.document);
|
|
8889
|
-
if (thresholds.passport) setPassportDetectionThreshold(thresholds.passport);
|
|
8890
|
-
if (thresholds.mrz) setMrzDetectionThreshold(thresholds.mrz);
|
|
8891
|
-
if (thresholds.pdf417) setPdf417DetectionThreshold(thresholds.pdf417);
|
|
8892
|
-
if (thresholds.focus) setFocusThreshold(thresholds.focus);
|
|
8893
|
-
}, []);
|
|
8894
|
-
var _p = React.useState(0),
|
|
8895
|
-
timesAllZero = _p[0],
|
|
8896
|
-
setTimesAllZero = _p[1];
|
|
8911
|
+
var _k = React.useState(0),
|
|
8912
|
+
timesAllZero = _k[0],
|
|
8913
|
+
setTimesAllZero = _k[1];
|
|
8897
8914
|
var bestPredictionCanvas = React.useRef(null);
|
|
8898
8915
|
var bestFocusScore = React.useRef(0);
|
|
8899
8916
|
var makePrediction = React.useCallback(function (frame) {
|
|
@@ -8977,22 +8994,23 @@ var IdCaptureModelsProvider = function IdCaptureModelsProvider(_a) {
|
|
|
8977
8994
|
ref: bestPredictionCanvas
|
|
8978
8995
|
}));
|
|
8979
8996
|
};
|
|
8997
|
+
var onMobile = isMobile();
|
|
8980
8998
|
function makePredictions(frame, lastPredictionCanvas, thresholds, logPredictions) {
|
|
8981
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
8999
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
8982
9000
|
if (logPredictions === void 0) {
|
|
8983
9001
|
logPredictions = false;
|
|
8984
9002
|
}
|
|
8985
9003
|
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
8986
|
-
var
|
|
8987
|
-
var
|
|
8988
|
-
return tslib.__generator(this, function (
|
|
8989
|
-
switch (
|
|
9004
|
+
var _o, frameWidth, frameHeight, _q, boxes, scores, labels, time, allZero, detectedObjects, bestDocument, bestPassportPage, bestDocumentScore, passportDetectionScore, passportDetectionThresholdMet, bestDocumentOrPassport, detectionScore, detectionThresholdMet, detectedDocumentType, bestMrz, mrzDetectionScore, mrzDetectionThresholdMet, bestPdf417, pdf417DetectionScore, pdf417DetectionThresholdMet, documentInBounds, boundaryPx, _r, boundaryX, boundaryY, boundaryWidth, boundaryHeight, focusPrediction, focusPredictionTime, focusScore, focusThresholdMet, focusThreshold;
|
|
9005
|
+
var _s;
|
|
9006
|
+
return tslib.__generator(this, function (_t) {
|
|
9007
|
+
switch (_t.label) {
|
|
8990
9008
|
case 0:
|
|
8991
|
-
|
|
9009
|
+
_o = getFrameDimensions(frame), frameWidth = _o[0], frameHeight = _o[1];
|
|
8992
9010
|
drawToCanvas(lastPredictionCanvas, frame);
|
|
8993
9011
|
return [4 /*yield*/, makeDocumentDetectionPredictions(frame, logPredictions)];
|
|
8994
9012
|
case 1:
|
|
8995
|
-
|
|
9013
|
+
_q = _t.sent(), boxes = _q.boxes, scores = _q.scores, labels = _q.labels, time = _q.time;
|
|
8996
9014
|
allZero = boxes.length > 0 && !boxes.some(function (box) {
|
|
8997
9015
|
return box.some(function (n) {
|
|
8998
9016
|
return n > 0;
|
|
@@ -9029,14 +9047,31 @@ function makePredictions(frame, lastPredictionCanvas, thresholds, logPredictions
|
|
|
9029
9047
|
});
|
|
9030
9048
|
pdf417DetectionScore = (_g = bestPdf417 === null || bestPdf417 === void 0 ? void 0 : bestPdf417.score) !== null && _g !== void 0 ? _g : 0;
|
|
9031
9049
|
pdf417DetectionThresholdMet = pdf417DetectionScore >= ((_h = thresholds.pdf417) !== null && _h !== void 0 ? _h : 0);
|
|
9050
|
+
documentInBounds = false;
|
|
9051
|
+
if (bestDocumentOrPassport) {
|
|
9052
|
+
boundaryPx = 20;
|
|
9053
|
+
_r = bestDocumentOrPassport.bbox, boundaryX = _r[0], boundaryY = _r[1], boundaryWidth = _r[2], boundaryHeight = _r[3];
|
|
9054
|
+
boundaryX *= frameWidth;
|
|
9055
|
+
boundaryWidth *= frameWidth;
|
|
9056
|
+
boundaryY *= frameHeight;
|
|
9057
|
+
boundaryHeight *= frameHeight;
|
|
9058
|
+
documentInBounds = boundaryY > boundaryPx &&
|
|
9059
|
+
// Is it valid top edge of ID detected?
|
|
9060
|
+
boundaryY + boundaryHeight + boundaryPx < frameHeight && (
|
|
9061
|
+
// Is it valid bottom edge less than max video height
|
|
9062
|
+
boundaryX > boundaryPx || boundaryX < boundaryPx && boundaryX + boundaryWidth > frameWidth * 0.8) &&
|
|
9063
|
+
// If either the left side visible or if not, right edge of ID should be more than 80% of width.
|
|
9064
|
+
boundaryX + boundaryWidth + boundaryPx < frameWidth; // Valid right edge if it's less than video width.
|
|
9065
|
+
}
|
|
9032
9066
|
focusPrediction = null, focusPredictionTime = 0, focusScore = 0, focusThresholdMet = false;
|
|
9033
|
-
if (!detectionThresholdMet) return [3 /*break*/, 3];
|
|
9067
|
+
if (!(detectionThresholdMet && documentInBounds)) return [3 /*break*/, 3];
|
|
9034
9068
|
return [4 /*yield*/, makeFocusPrediction(frame, bestDocumentOrPassport === null || bestDocumentOrPassport === void 0 ? void 0 : bestDocumentOrPassport.bbox, logPredictions)];
|
|
9035
9069
|
case 2:
|
|
9036
|
-
|
|
9070
|
+
_s = _t.sent(), focusPrediction = _s[0], focusPredictionTime = _s[1];
|
|
9037
9071
|
focusScore = (_j = focusPrediction === null || focusPrediction === void 0 ? void 0 : focusPrediction[1]) !== null && _j !== void 0 ? _j : 0;
|
|
9038
|
-
|
|
9039
|
-
|
|
9072
|
+
focusThreshold = (_m = onMobile ? (_k = thresholds.focus) === null || _k === void 0 ? void 0 : _k.mobile : (_l = thresholds.focus) === null || _l === void 0 ? void 0 : _l.desktop) !== null && _m !== void 0 ? _m : 0;
|
|
9073
|
+
focusThresholdMet = focusScore >= focusThreshold;
|
|
9074
|
+
_t.label = 3;
|
|
9040
9075
|
case 3:
|
|
9041
9076
|
return [2 /*return*/, {
|
|
9042
9077
|
detectedObjects: detectedObjects,
|
|
@@ -9053,6 +9088,7 @@ function makePredictions(frame, lastPredictionCanvas, thresholds, logPredictions
|
|
|
9053
9088
|
bestDocumentOrPassport: bestDocumentOrPassport,
|
|
9054
9089
|
bestMrz: bestMrz,
|
|
9055
9090
|
bestPdf417: bestPdf417,
|
|
9091
|
+
documentInBounds: documentInBounds,
|
|
9056
9092
|
focusScore: focusScore,
|
|
9057
9093
|
focusThresholdMet: focusThresholdMet,
|
|
9058
9094
|
focusPredictionTime: focusPredictionTime,
|
|
@@ -9722,6 +9758,7 @@ var reducer$5 = function reducer(state, action) {
|
|
|
9722
9758
|
bestDocumentOrPassport = _a.bestDocumentOrPassport,
|
|
9723
9759
|
bestMrz = _a.bestMrz,
|
|
9724
9760
|
bestPdf417 = _a.bestPdf417,
|
|
9761
|
+
documentInBounds = _a.documentInBounds,
|
|
9725
9762
|
focusScore = _a.focusScore,
|
|
9726
9763
|
focusThresholdMet = _a.focusThresholdMet,
|
|
9727
9764
|
frameWidth = _a.frameWidth,
|
|
@@ -9735,26 +9772,6 @@ var reducer$5 = function reducer(state, action) {
|
|
|
9735
9772
|
goodFramesThreshold = Math.ceil(3 * frameCaptureRate);
|
|
9736
9773
|
}
|
|
9737
9774
|
}
|
|
9738
|
-
var documentInBounds = false;
|
|
9739
|
-
if (bestDocumentOrPassport) {
|
|
9740
|
-
var boundaryPx = 20;
|
|
9741
|
-
var _b = bestDocumentOrPassport.bbox,
|
|
9742
|
-
boundaryX = _b[0],
|
|
9743
|
-
boundaryY = _b[1],
|
|
9744
|
-
boundaryWidth = _b[2],
|
|
9745
|
-
boundaryHeight = _b[3];
|
|
9746
|
-
boundaryX *= frameWidth;
|
|
9747
|
-
boundaryWidth *= frameWidth;
|
|
9748
|
-
boundaryY *= frameHeight;
|
|
9749
|
-
boundaryHeight *= frameHeight;
|
|
9750
|
-
documentInBounds = boundaryY > boundaryPx &&
|
|
9751
|
-
// Is it valid top edge of ID detected?
|
|
9752
|
-
boundaryY + boundaryHeight + boundaryPx < frameHeight && (
|
|
9753
|
-
// Is it valid bottom edge less than max video height
|
|
9754
|
-
boundaryX > boundaryPx || boundaryX < boundaryPx && boundaryX + boundaryWidth > frameWidth * 0.8) &&
|
|
9755
|
-
// If either the left side visible or if not, right edge of ID should be more than 80% of width.
|
|
9756
|
-
boundaryX + boundaryWidth + boundaryPx < frameWidth; // Valid right edge if it's less than video width.
|
|
9757
|
-
}
|
|
9758
9775
|
var barcodeScanRequired = state.autoCaptureBarcodeRequired === true || state.autoCaptureBarcodeRequired === 'mobile' && isMobile();
|
|
9759
9776
|
var shouldScanBarcode = state.barcodeScanningEnabled && pdf417DetectionThresholdMet && barcodeScanRequired;
|
|
9760
9777
|
var waitingForBarcodeScan = shouldScanBarcode && !state.barcodeResult;
|
|
@@ -9925,7 +9942,9 @@ var IdCapture = function IdCapture(_a) {
|
|
|
9925
9942
|
passport: passportPageDetectionThreshold,
|
|
9926
9943
|
mrz: mrzDetectionScoreThreshold,
|
|
9927
9944
|
pdf417: pdf417DetectionThreshold,
|
|
9928
|
-
focus:
|
|
9945
|
+
focus: {
|
|
9946
|
+
mobile: focusScoreThreshold
|
|
9947
|
+
}
|
|
9929
9948
|
});
|
|
9930
9949
|
}, [requiredDocumentType, autoCaptureScoreThreshold, focusScoreThreshold, mrzDetectionScoreThreshold, autoCaptureGoodFramesRequired, autoCaptureBarcodeRequired, barcodeScanningEnabled, maxBarcodeScanAttempts, passportPageDetectionThreshold, pdf417DetectionThreshold, resetBestFrame, setThresholds]);
|
|
9931
9950
|
var animationFrame = React.useRef(0);
|
|
@@ -10565,7 +10584,7 @@ var CameraVideoTag = function CameraVideoTag(_a) {
|
|
|
10565
10584
|
"$isRearFacing": (_b = cameraRef.current) === null || _b === void 0 ? void 0 : _b.isRearFacing
|
|
10566
10585
|
});
|
|
10567
10586
|
};
|
|
10568
|
-
var FullscreenVideoTag = styled__default['default'].video(templateObject_1$h || (templateObject_1$h = tslib.__makeTemplateObject(["\n transform: ", ";\n min-width: 100%;\n min-height: 100%;\n width: auto;\n height: auto;\n object-fit: cover;\n"], ["\n transform: ", ";\n min-width: 100%;\n min-height: 100%;\n width: auto;\n height: auto;\n object-fit: cover;\n"])), function (props) {
|
|
10587
|
+
var FullscreenVideoTag = styled__default['default'].video(templateObject_1$h || (templateObject_1$h = tslib.__makeTemplateObject(["\n transform: ", ";\n min-width: 100%;\n min-height: 100%;\n width: auto;\n height: auto;\n object-fit: cover;\n background: black;\n"], ["\n transform: ", ";\n min-width: 100%;\n min-height: 100%;\n width: auto;\n height: auto;\n object-fit: cover;\n background: black;\n"])), function (props) {
|
|
10569
10588
|
return props.$isRearFacing ? '' : 'scaleX(-1)';
|
|
10570
10589
|
});
|
|
10571
10590
|
var templateObject_1$h;
|
|
@@ -12821,7 +12840,7 @@ var VideoSignatureCapture = function VideoSignatureCapture(_a) {
|
|
|
12821
12840
|
var _b = [cameraRef.current.width, cameraRef.current.height],
|
|
12822
12841
|
w = _b[0],
|
|
12823
12842
|
h = _b[1];
|
|
12824
|
-
var isPortrait = window.innerWidth < window.innerHeight;
|
|
12843
|
+
var isPortrait = typeof window !== 'undefined' && window.innerWidth < window.innerHeight;
|
|
12825
12844
|
var cameraIsLandscape = w > h;
|
|
12826
12845
|
if (isPortrait && cameraIsLandscape) _a = [h, w], w = _a[0], h = _a[1];
|
|
12827
12846
|
outputCanvas.current.width = w;
|
|
@@ -13331,7 +13350,7 @@ var IdVideoCaptureGuides = function IdVideoCaptureGuides(_a) {
|
|
|
13331
13350
|
idBackInstructionText: 'Display the back of your ID card...'
|
|
13332
13351
|
});
|
|
13333
13352
|
var instructionText = requestedAction === 'SHOW_ID_FRONT' ? verbiage.idFrontInstructionText : verbiage.idBackInstructionText;
|
|
13334
|
-
var idGuideWidth = window.innerWidth > window.innerHeight ? '30%' : '75%';
|
|
13353
|
+
var idGuideWidth = typeof window !== 'undefined' && window.innerWidth > window.innerHeight ? '30%' : '75%';
|
|
13335
13354
|
return /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, /*#__PURE__*/React__default['default'].createElement("div", {
|
|
13336
13355
|
style: {
|
|
13337
13356
|
position: 'absolute',
|
|
@@ -13476,7 +13495,7 @@ var ReadTextPromptHeading = styled__default['default'].div(templateObject_2$4 ||
|
|
|
13476
13495
|
var _a, _b, _c, _d, _e, _f;
|
|
13477
13496
|
return ((_c = (_b = (_a = props.theme.idVideoCapture) === null || _a === void 0 ? void 0 : _a.readTextPrompt) === null || _b === void 0 ? void 0 : _b.heading) === null || _c === void 0 ? void 0 : _c.borderRadius) ? "border-radius: ".concat((_f = (_e = (_d = props.theme.idVideoCapture) === null || _d === void 0 ? void 0 : _d.readTextPrompt) === null || _e === void 0 ? void 0 : _e.heading) === null || _f === void 0 ? void 0 : _f.borderRadius, ";") : "";
|
|
13478
13497
|
});
|
|
13479
|
-
var ReadTextPromptText = styled__default['default'].div(templateObject_3$4 || (templateObject_3$4 = tslib.__makeTemplateObject(["\n margin: 0 auto;\n text-align: center;\n padding: 50px;\n font-size: 24px;\n max-width: ", ";\n\n ", ";\n ", ";\n ", ";\n"], ["\n margin: 0 auto;\n text-align: center;\n padding: 50px;\n font-size: 24px;\n max-width: ", ";\n\n ", ";\n ", ";\n ", ";\n"])), window.innerWidth > window.innerHeight ? '40%' : '90%', function (props) {
|
|
13498
|
+
var ReadTextPromptText = styled__default['default'].div(templateObject_3$4 || (templateObject_3$4 = tslib.__makeTemplateObject(["\n margin: 0 auto;\n text-align: center;\n padding: 50px;\n font-size: 24px;\n max-width: ", ";\n\n ", ";\n ", ";\n ", ";\n"], ["\n margin: 0 auto;\n text-align: center;\n padding: 50px;\n font-size: 24px;\n max-width: ", ";\n\n ", ";\n ", ";\n ", ";\n"])), typeof window !== 'undefined' && window.innerWidth > window.innerHeight ? '40%' : '90%', function (props) {
|
|
13480
13499
|
var _a, _b, _c, _d, _e, _f;
|
|
13481
13500
|
return ((_c = (_b = (_a = props.theme.idVideoCapture) === null || _a === void 0 ? void 0 : _a.readTextPrompt) === null || _b === void 0 ? void 0 : _b.prompt) === null || _c === void 0 ? void 0 : _c.backgroundColor) ? "background: ".concat((_f = (_e = (_d = props.theme.idVideoCapture) === null || _d === void 0 ? void 0 : _d.readTextPrompt) === null || _e === void 0 ? void 0 : _e.prompt) === null || _f === void 0 ? void 0 : _f.backgroundColor, ";") : "";
|
|
13482
13501
|
}, function (props) {
|
|
@@ -13592,7 +13611,9 @@ var IdVideoCapture = function IdVideoCapture(_a) {
|
|
|
13592
13611
|
setThresholds({
|
|
13593
13612
|
document: idCardFrontDetectionThreshold,
|
|
13594
13613
|
passport: 1,
|
|
13595
|
-
focus:
|
|
13614
|
+
focus: {
|
|
13615
|
+
mobile: idCardFrontFocusThreshold
|
|
13616
|
+
}
|
|
13596
13617
|
});
|
|
13597
13618
|
}, [idCardFrontDetectionThreshold, idCardFrontFocusThreshold, setThresholds]);
|
|
13598
13619
|
var _4 = React.useState(0),
|