idmission-web-sdk 1.0.318 → 1.0.320

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.
@@ -35,6 +35,7 @@ export type SubmissionState = {
35
35
  setIdCaptureVideoIdBackImage: (image: string) => void;
36
36
  setIdCaptureVideoAudioUrl: (videoDataUrl: string) => void;
37
37
  setIdCaptureVideoAudioStartsAt: (value: number) => void;
38
+ setExpectedAudioText: (value: string) => void;
38
39
  setAdditionalDocuments: (uploadedDocuments: UploadedDocument[]) => void;
39
40
  uploadDocument: (blob: Blob) => Promise<string>;
40
41
  logIdFrontCaptureAttempt: (attempt: CaptureAttemptMetadata) => void;
@@ -79,5 +80,6 @@ export type SubmissionProviderProps = {
79
80
  onBeforeLivenessCheck?: (req: LivenessCheckRequest) => Promise<LivenessCheckRequest>;
80
81
  onResponseReceived?: (res: SubmissionResponse, req: SubmissionRequest) => void;
81
82
  onRequestFailure?: (err: Error) => void;
83
+ readTextPrompt?: string;
82
84
  };
83
85
  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;
@@ -39,7 +39,8 @@ export type SubmissionRequest = {
39
39
  selfie?: string;
40
40
  videoData?: string;
41
41
  voiceData?: string;
42
- voiceStartsAt?: number;
42
+ voiceStartTime?: number;
43
+ expectedAudioText?: string;
43
44
  };
44
45
  signatureData?: {
45
46
  signatureImage?: string;
@@ -50,7 +50,7 @@ var LanguageDetector__default = /*#__PURE__*/_interopDefaultLegacy(LanguageDetec
50
50
  var i18n__default = /*#__PURE__*/_interopDefaultLegacy(i18n);
51
51
  var SignatureCanvas__default = /*#__PURE__*/_interopDefaultLegacy(SignatureCanvas);
52
52
 
53
- var webSdkVersion = '1.0.318';
53
+ var webSdkVersion = '1.0.320';
54
54
 
55
55
  function getPlatform() {
56
56
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -678,6 +678,9 @@ var SubmissionContext = /*#__PURE__*/React.createContext({
678
678
  setIdCaptureVideoAudioStartsAt: function setIdCaptureVideoAudioStartsAt() {
679
679
  return null;
680
680
  },
681
+ setExpectedAudioText: function setExpectedAudioText() {
682
+ return null;
683
+ },
681
684
  setAdditionalDocuments: function setAdditionalDocuments() {
682
685
  return null;
683
686
  },
@@ -808,26 +811,29 @@ var SubmissionProvider = function SubmissionProvider(_a) {
808
811
  idCaptureVideoAudioStartsAt = _11[0],
809
812
  setIdCaptureVideoAudioStartsAt = _11[1];
810
813
  var _12 = React.useState(null),
811
- additionalDocuments = _12[0],
812
- setAdditionalDocuments = _12[1];
814
+ expectedAudioText = _12[0],
815
+ setExpectedAudioText = _12[1];
813
816
  var _13 = React.useState(null),
814
- geolocationResult = _13[0],
815
- setGeolocationResult = _13[1];
816
- var _14 = React.useState(0),
817
- geolocationAttempts = _14[0],
818
- setGeolocationAttempts = _14[1];
819
- var _15 = React.useState(false),
820
- geolocationBlocked = _15[0],
821
- setGeolocationBlocked = _15[1];
822
- var _16 = React.useState([]),
823
- idFrontCaptureAttempts = _16[0],
824
- setIdFrontCaptureAttempts = _16[1];
817
+ additionalDocuments = _13[0],
818
+ setAdditionalDocuments = _13[1];
819
+ var _14 = React.useState(null),
820
+ geolocationResult = _14[0],
821
+ setGeolocationResult = _14[1];
822
+ var _15 = React.useState(0),
823
+ geolocationAttempts = _15[0],
824
+ setGeolocationAttempts = _15[1];
825
+ var _16 = React.useState(false),
826
+ geolocationBlocked = _16[0],
827
+ setGeolocationBlocked = _16[1];
825
828
  var _17 = React.useState([]),
826
- idBackCaptureAttempts = _17[0],
827
- setIdBackCaptureAttempts = _17[1];
829
+ idFrontCaptureAttempts = _17[0],
830
+ setIdFrontCaptureAttempts = _17[1];
828
831
  var _18 = React.useState([]),
829
- selfieCaptureAttempts = _18[0],
830
- setSelfieCaptureAttempts = _18[1];
832
+ idBackCaptureAttempts = _18[0],
833
+ setIdBackCaptureAttempts = _18[1];
834
+ var _19 = React.useState([]),
835
+ selfieCaptureAttempts = _19[0],
836
+ setSelfieCaptureAttempts = _19[1];
831
837
  var logIdFrontCaptureAttempt = React.useCallback(function (attempt) {
832
838
  setIdFrontCaptureAttempts(function (attempts) {
833
839
  return tslib.__spreadArray(tslib.__spreadArray([], attempts, true), [attempt], false);
@@ -958,7 +964,8 @@ var SubmissionProvider = function SubmissionProvider(_a) {
958
964
  return [4 /*yield*/, videoDataUrlToB64(idCaptureVideoAudioUrl)];
959
965
  case 5:
960
966
  _c.voiceData = _g.sent();
961
- submissionRequest.customerData.biometricData.voiceStartsAt = idCaptureVideoAudioStartsAt !== null && idCaptureVideoAudioStartsAt !== void 0 ? idCaptureVideoAudioStartsAt : undefined;
967
+ submissionRequest.customerData.biometricData.voiceStartTime = idCaptureVideoAudioStartsAt !== null && idCaptureVideoAudioStartsAt !== void 0 ? idCaptureVideoAudioStartsAt : undefined;
968
+ submissionRequest.customerData.biometricData.expectedAudioText = expectedAudioText !== null && expectedAudioText !== void 0 ? expectedAudioText : undefined;
962
969
  _g.label = 6;
963
970
  case 6:
964
971
  if (idCaptureVideoIdFrontImage) {
@@ -1197,12 +1204,12 @@ var SubmissionProvider = function SubmissionProvider(_a) {
1197
1204
  setSubmissionStatus(SubmissionStatus.READY);
1198
1205
  retrySubmission();
1199
1206
  }, [retrySubmission]);
1200
- var _19 = React.useState('NOT_PARSED'),
1201
- tokenState = _19[0],
1202
- setTokenState = _19[1];
1203
- var _20 = React.useState(null),
1204
- tokenError = _20[0],
1205
- setTokenError = _20[1];
1207
+ var _20 = React.useState('NOT_PARSED'),
1208
+ tokenState = _20[0],
1209
+ setTokenState = _20[1];
1210
+ var _21 = React.useState(null),
1211
+ tokenError = _21[0],
1212
+ setTokenError = _21[1];
1206
1213
  React.useEffect(function () {
1207
1214
  if (typeof window === 'undefined') return;
1208
1215
  (function () {
@@ -1346,6 +1353,7 @@ var SubmissionProvider = function SubmissionProvider(_a) {
1346
1353
  setIdCaptureVideoIdBackImage: setIdCaptureVideoIdBackImage,
1347
1354
  setIdCaptureVideoAudioUrl: setIdCaptureVideoAudioUrl,
1348
1355
  setIdCaptureVideoAudioStartsAt: setIdCaptureVideoAudioStartsAt,
1356
+ setExpectedAudioText: setExpectedAudioText,
1349
1357
  setAdditionalDocuments: setAdditionalDocuments,
1350
1358
  uploadDocument: uploadDocument,
1351
1359
  logIdFrontCaptureAttempt: logIdFrontCaptureAttempt,
@@ -16207,16 +16215,18 @@ var IdVideoCapture = function IdVideoCapture(_a) {
16207
16215
  var _17 = React.useState(null),
16208
16216
  videoStartsAt = _17[0],
16209
16217
  setVideoStartsAt = _17[1];
16210
- var setIdCaptureVideoAudioStartsAt = React.useContext(SubmissionContext).setIdCaptureVideoAudioStartsAt;
16218
+ var _18 = React.useContext(SubmissionContext),
16219
+ setIdCaptureVideoAudioStartsAt = _18.setIdCaptureVideoAudioStartsAt,
16220
+ setExpectedAudioText = _18.setExpectedAudioText;
16211
16221
  var onSelfiePredictionMade = React.useContext(HighPerformanceSelfieGuidanceModelsContext).onPredictionMade;
16212
- var _18 = useVideoRecorder(cameraRef.current, audioStream),
16213
- isRecordingVideo = _18.isRecordingVideo,
16214
- startRecordingVideo = _18.startRecordingVideo,
16215
- startRecordingAudio = _18.startRecordingAudio,
16216
- stopRecordingVideo = _18.stopRecordingVideo,
16217
- stopRecordingAudio = _18.stopRecordingAudio,
16218
- videoUrl = _18.videoUrl,
16219
- audioUrl = _18.audioUrl;
16222
+ var _19 = useVideoRecorder(cameraRef.current, audioStream),
16223
+ isRecordingVideo = _19.isRecordingVideo,
16224
+ startRecordingVideo = _19.startRecordingVideo,
16225
+ startRecordingAudio = _19.startRecordingAudio,
16226
+ stopRecordingVideo = _19.stopRecordingVideo,
16227
+ stopRecordingAudio = _19.stopRecordingAudio,
16228
+ videoUrl = _19.videoUrl,
16229
+ audioUrl = _19.audioUrl;
16220
16230
  React.useEffect(function () {
16221
16231
  if (!isRecordingVideo && !videoUrl) {
16222
16232
  startRecordingVideo();
@@ -16232,9 +16242,9 @@ var IdVideoCapture = function IdVideoCapture(_a) {
16232
16242
  React.useEffect(function () {
16233
16243
  shouldCaptureFrames.current = videoLoaded && cameraReady && idModelsReady && (!readTextPrompt || microphoneReady);
16234
16244
  }, [cameraReady, idModelsReady, microphoneReady, readTextPrompt, videoLoaded]);
16235
- var _19 = React.useState('SHOW_ID_FRONT'),
16236
- requestedAction = _19[0],
16237
- setRequestedAction = _19[1];
16245
+ var _20 = React.useState('SHOW_ID_FRONT'),
16246
+ requestedAction = _20[0],
16247
+ setRequestedAction = _20[1];
16238
16248
  React.useEffect(function () {
16239
16249
  if (requestedAction !== 'SHOW_ID_FRONT' && requestedAction !== 'SHOW_ID_BACK') return;
16240
16250
  if (!idCaptureModelsEnabled || !idModelsReady || !cameraReady || !videoLoaded) return;
@@ -16262,15 +16272,15 @@ var IdVideoCapture = function IdVideoCapture(_a) {
16262
16272
  }
16263
16273
  });
16264
16274
  }, [idCardBackDetectionThreshold, idCardBackFocusThreshold, idCardFrontDetectionThreshold, idCardFrontFocusThreshold, requestedAction, setThresholds]);
16265
- var _20 = React.useState(0),
16266
- currentDetectionScore = _20[0],
16267
- setCurrentDetectionScore = _20[1];
16268
16275
  var _21 = React.useState(0),
16269
- currentFocusScore = _21[0],
16270
- setCurrentFocusScore = _21[1];
16276
+ currentDetectionScore = _21[0],
16277
+ setCurrentDetectionScore = _21[1];
16271
16278
  var _22 = React.useState(0),
16272
- goodFramesCount = _22[0],
16273
- setGoodFramesCount = _22[1];
16279
+ currentFocusScore = _22[0],
16280
+ setCurrentFocusScore = _22[1];
16281
+ var _23 = React.useState(0),
16282
+ goodFramesCount = _23[0],
16283
+ setGoodFramesCount = _23[1];
16274
16284
  var goodFramesThreshold = requestedAction === 'SHOW_ID_FRONT' ? goodIdCardFrontFramesThreshold : goodIdCardBackFramesThreshold;
16275
16285
  var goodFramesThresholdMet = goodFramesCount >= goodFramesThreshold;
16276
16286
  React.useEffect(function () {
@@ -16288,30 +16298,32 @@ var IdVideoCapture = function IdVideoCapture(_a) {
16288
16298
  }
16289
16299
  });
16290
16300
  }, [idCaptureModelsEnabled, idCardFrontDetectionThreshold, onIdPredictionMade]);
16291
- var _23 = React.useState(null),
16292
- idFrontCaptureStartedAt = _23[0],
16293
- setFirstGoodFrameTime = _23[1];
16301
+ var _24 = React.useState(null),
16302
+ idFrontCaptureStartedAt = _24[0],
16303
+ setFirstGoodFrameTime = _24[1];
16294
16304
  React.useEffect(function () {
16295
16305
  if (goodFramesCount === 1) setFirstGoodFrameTime(new Date().getTime());
16296
16306
  }, [goodFramesCount]);
16297
16307
  var delaySatisfied = requestedAction !== 'SHOW_ID_FRONT' || idFrontCaptureStartedAt !== null && new Date().getTime() > idFrontCaptureStartedAt + idCardFrontDelay;
16308
+ var translatedText = useVerbiage(readTextPrompt, '');
16298
16309
  var onIdBackCaptureComplete = React.useCallback(function () {
16299
16310
  var _a;
16300
- if (readTextPrompt) {
16311
+ if (translatedText) {
16301
16312
  setRequestedAction('READ_TEXT');
16302
16313
  startRecordingAudio();
16303
16314
  setIdCaptureVideoAudioStartsAt(new Date().getTime() - ((_a = videoStartsAt === null || videoStartsAt === void 0 ? void 0 : videoStartsAt.getTime()) !== null && _a !== void 0 ? _a : 0));
16315
+ setExpectedAudioText(translatedText);
16304
16316
  } else {
16305
16317
  stopRecordingVideo();
16306
16318
  }
16307
- }, [readTextPrompt, setIdCaptureVideoAudioStartsAt, startRecordingAudio, stopRecordingVideo, videoStartsAt]);
16319
+ }, [translatedText, setIdCaptureVideoAudioStartsAt, startRecordingAudio, stopRecordingVideo, videoStartsAt]);
16308
16320
  var frameWidth = (_c = (_b = videoRef.current) === null || _b === void 0 ? void 0 : _b.videoWidth) !== null && _c !== void 0 ? _c : 0;
16309
16321
  var frameHeight = (_e = (_d = videoRef.current) === null || _d === void 0 ? void 0 : _d.videoHeight) !== null && _e !== void 0 ? _e : 0;
16310
16322
  var faceBox = (_f = faces === null || faces === void 0 ? void 0 : faces[0]) === null || _f === void 0 ? void 0 : _f.box;
16311
16323
  var faceCentered = !faceBox || !frameWidth || faceBox.xMin > frameWidth * edgeBoundary && faceBox.yMin > frameHeight * edgeBoundary && faceBox.xMax < frameWidth * (1 - edgeBoundary) && faceBox.yMax < frameHeight * (1 - edgeBoundary);
16312
- var _24 = React.useState(),
16313
- countdownStartedAt = _24[0],
16314
- setCountdownStartedAt = _24[1];
16324
+ var _25 = React.useState(),
16325
+ countdownStartedAt = _25[0],
16326
+ setCountdownStartedAt = _25[1];
16315
16327
  var frameLock = React.useRef(false);
16316
16328
  var captureFrame = React.useCallback(function () {
16317
16329
  return tslib.__awaiter(void 0, void 0, void 0, function () {
@@ -16409,9 +16421,9 @@ var IdVideoCapture = function IdVideoCapture(_a) {
16409
16421
  };
16410
16422
  }, [captureCountdownSeconds, captureFrame, countdownStartedAt]);
16411
16423
  var timeoutStartedAt = useTimeout(readTextTimeoutDurationMs, stopRecording, requestedAction !== 'READ_TEXT', false, requestedAction === 'READ_TEXT').timeoutStartedAt;
16412
- var _25 = React.useState(0),
16413
- numFramesWithoutFaces = _25[0],
16414
- setNumFramesWithoutFaces = _25[1];
16424
+ var _26 = React.useState(0),
16425
+ numFramesWithoutFaces = _26[0],
16426
+ setNumFramesWithoutFaces = _26[1];
16415
16427
  React.useEffect(function () {
16416
16428
  onSelfiePredictionMade(function (faces) {
16417
16429
  setFaces(faces);
@@ -16426,14 +16438,14 @@ var IdVideoCapture = function IdVideoCapture(_a) {
16426
16438
  }
16427
16439
  }, [numFramesWithoutFaces, onFaceNotDetected]);
16428
16440
  var theme = styled.useTheme();
16429
- var _26 = useTranslations(rawVerbiage, {
16441
+ var _27 = useTranslations(rawVerbiage, {
16430
16442
  faceNotCenteredText: 'Please move your face to the center...',
16431
16443
  searchingForIdCardText: 'Searching for ID card...',
16432
16444
  captureBtnText: 'Capture'
16433
16445
  }),
16434
- captureBtnText = _26.captureBtnText,
16435
- faceNotCenteredText = _26.faceNotCenteredText,
16436
- searchingForIdCardText = _26.searchingForIdCardText;
16446
+ captureBtnText = _27.captureBtnText,
16447
+ faceNotCenteredText = _27.faceNotCenteredText,
16448
+ searchingForIdCardText = _27.searchingForIdCardText;
16437
16449
  var debugScalingDetails = useDebugScalingDetails({
16438
16450
  enabled: debugMode,
16439
16451
  pageWidth: width,