idmission-web-sdk 2.2.6 → 2.2.7

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
@@ -200,7 +200,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
200
200
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
201
201
  };
202
202
 
203
- var webSdkVersion = '2.2.6';
203
+ var webSdkVersion = '2.2.7';
204
204
 
205
205
  function getPlatform() {
206
206
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -4321,105 +4321,107 @@ var _reducer = function reducer(state, action) {
4321
4321
  guideImageHeight: action.payload.height
4322
4322
  });
4323
4323
  case 'objectsDetected':
4324
- var _d = action.payload.prediction,
4325
- detectedObjects = _d.detectedObjects,
4326
- detectionThresholdMet = _d.detectionThresholdMet,
4327
- detectedDocumentType = _d.detectedDocumentType,
4328
- idCardFrontDetectionScore = _d.idCardFrontDetectionScore,
4329
- idCardFrontDetectionThresholdMet = _d.idCardFrontDetectionThresholdMet,
4330
- idCardBackDetectionScore = _d.idCardBackDetectionScore,
4331
- idCardBackDetectionThresholdMet = _d.idCardBackDetectionThresholdMet,
4332
- passportDetectionScore = _d.passportDetectionScore,
4333
- passportDetectionThresholdMet = _d.passportDetectionThresholdMet,
4334
- bestDocument = _d.bestDocument,
4335
- documentInBounds = _d.documentInBounds,
4336
- documentTooClose = _d.documentTooClose,
4337
- documentIsStable = _d.documentIsStable,
4338
- focusScore = _d.focusScore,
4339
- focusThresholdMet = _d.focusThresholdMet,
4340
- frameWidth = _d.frameWidth,
4341
- frameHeight = _d.frameHeight;
4342
- var frameCapturedAt = new Date();
4343
- var frameCaptureRate = 0;
4344
- var goodFramesThreshold = state.goodFramesThreshold;
4345
- if (state.lastFrameCapturedAt) {
4346
- var frameTime = frameCapturedAt.getTime() - state.lastFrameCapturedAt.getTime();
4347
- if (frameTime > 0) {
4348
- frameCaptureRate = 1000.0 / frameTime;
4349
- if (frameCaptureRate > 0) {
4350
- goodFramesThreshold = Math.ceil(3 * frameCaptureRate);
4324
+ {
4325
+ var _d = action.payload.prediction,
4326
+ detectedObjects = _d.detectedObjects,
4327
+ detectionThresholdMet = _d.detectionThresholdMet,
4328
+ detectedDocumentType = _d.detectedDocumentType,
4329
+ idCardFrontDetectionScore = _d.idCardFrontDetectionScore,
4330
+ idCardFrontDetectionThresholdMet = _d.idCardFrontDetectionThresholdMet,
4331
+ idCardBackDetectionScore = _d.idCardBackDetectionScore,
4332
+ idCardBackDetectionThresholdMet = _d.idCardBackDetectionThresholdMet,
4333
+ passportDetectionScore = _d.passportDetectionScore,
4334
+ passportDetectionThresholdMet = _d.passportDetectionThresholdMet,
4335
+ bestDocument = _d.bestDocument,
4336
+ documentInBounds = _d.documentInBounds,
4337
+ documentTooClose = _d.documentTooClose,
4338
+ documentIsStable = _d.documentIsStable,
4339
+ focusScore = _d.focusScore,
4340
+ focusThresholdMet = _d.focusThresholdMet,
4341
+ frameWidth = _d.frameWidth,
4342
+ frameHeight = _d.frameHeight;
4343
+ var frameCapturedAt = new Date();
4344
+ var frameCaptureRate = 0;
4345
+ var goodFramesThreshold = state.goodFramesThreshold;
4346
+ if (state.lastFrameCapturedAt) {
4347
+ var frameTime = frameCapturedAt.getTime() - state.lastFrameCapturedAt.getTime();
4348
+ if (frameTime > 0) {
4349
+ frameCaptureRate = 1000.0 / frameTime;
4350
+ if (frameCaptureRate > 0) {
4351
+ goodFramesThreshold = Math.ceil(3 * frameCaptureRate);
4352
+ }
4351
4353
  }
4352
4354
  }
4353
- }
4354
- var idCardDetectedButNotAllowed = detectedDocumentType.includes('idCard') && !state.captureRequirement.includes('idCard');
4355
- var passportNotAllowed = !state.captureRequirement.toLowerCase().includes('passport');
4356
- var idCardFrontWasCaptured = 'idCardFront' in state.capturedDocuments;
4357
- var idCardBackWasCaptured = 'idCardBack' in state.capturedDocuments;
4358
- var idCardBeingCaptured = idCardFrontWasCaptured && !idCardBackWasCaptured || !idCardFrontWasCaptured && idCardBackWasCaptured;
4359
- var passportDetectedButNotAllowed = detectedDocumentType === 'passport' && (passportNotAllowed || idCardBeingCaptured);
4360
- var flipRequired = !state.overrideWrongDocumentTypeGuidance && (state.allowIdCardBackToFrontCapture ? idCardFrontWasCaptured && detectedDocumentType === 'idCardFront' : state.requestedDocumentType === 'idCardBack' && detectedDocumentType === 'idCardFront');
4361
- var backDetectedFirst = !state.overrideWrongDocumentTypeGuidance && (state.allowIdCardBackToFrontCapture ? idCardBackWasCaptured && detectedDocumentType === 'idCardBack' : state.requestedDocumentType === 'idCardFront' && detectedDocumentType === 'idCardBack');
4362
- var wrongDocumentTypePredictions = state.wrongDocumentTypePredictions;
4363
- if (state.captureState === 'capturing' && (flipRequired || backDetectedFirst)) {
4364
- wrongDocumentTypePredictions += 1;
4365
- }
4366
- var isGoodFrame = detectionThresholdMet && documentInBounds && !documentTooClose && !flipRequired && !backDetectedFirst && focusThresholdMet && !idCardDetectedButNotAllowed && !passportDetectedButNotAllowed && documentIsStable;
4367
- var goodFramesCount = state.goodFramesCount;
4368
- if (isGoodFrame) {
4369
- goodFramesCount += 1;
4370
- }
4371
- var goodFramesThresholdMet = goodFramesCount >= goodFramesThreshold;
4372
- var requestedDocumentType = state.requestedDocumentType;
4373
- if (state.captureRequirement.includes('idCard') && state.allowIdCardBackToFrontCapture) {
4374
- if (detectedDocumentType === 'idCardFront' && state.requestedDocumentType !== 'idCardFront' && !idCardFrontWasCaptured) {
4375
- requestedDocumentType = 'idCardFront';
4376
- } else if (detectedDocumentType === 'idCardBack' && state.requestedDocumentType !== 'idCardBack' && !idCardBackWasCaptured) {
4377
- requestedDocumentType = 'idCardBack';
4355
+ var idCardDetectedButNotAllowed = detectedDocumentType.includes('idCard') && !state.captureRequirement.includes('idCard');
4356
+ var passportNotAllowed = !state.captureRequirement.toLowerCase().includes('passport');
4357
+ var idCardFrontWasCaptured = 'idCardFront' in state.capturedDocuments;
4358
+ var idCardBackWasCaptured = 'idCardBack' in state.capturedDocuments;
4359
+ var idCardBeingCaptured = idCardFrontWasCaptured && !idCardBackWasCaptured || !idCardFrontWasCaptured && idCardBackWasCaptured;
4360
+ var passportDetectedButNotAllowed = detectedDocumentType === 'passport' && (passportNotAllowed || idCardBeingCaptured);
4361
+ var flipRequired = !state.overrideWrongDocumentTypeGuidance && (state.allowIdCardBackToFrontCapture ? idCardFrontWasCaptured && detectedDocumentType === 'idCardFront' : state.requestedDocumentType === 'idCardBack' && detectedDocumentType === 'idCardFront');
4362
+ var backDetectedFirst = !state.overrideWrongDocumentTypeGuidance && (state.allowIdCardBackToFrontCapture ? idCardBackWasCaptured && detectedDocumentType === 'idCardBack' : state.requestedDocumentType === 'idCardFront' && detectedDocumentType === 'idCardBack');
4363
+ var wrongDocumentTypePredictions = state.wrongDocumentTypePredictions;
4364
+ if (state.captureState === 'capturing' && (flipRequired || backDetectedFirst)) {
4365
+ wrongDocumentTypePredictions += 1;
4378
4366
  }
4379
- }
4380
- if (state.captureRequirement === 'idCardOrPassport') {
4381
- if (detectedDocumentType === 'passport' && state.requestedDocumentType !== 'passport') {
4382
- requestedDocumentType = 'passport';
4367
+ var isGoodFrame = detectionThresholdMet && documentInBounds && !documentTooClose && !flipRequired && !backDetectedFirst && focusThresholdMet && !idCardDetectedButNotAllowed && !passportDetectedButNotAllowed && documentIsStable;
4368
+ var goodFramesCount = state.goodFramesCount;
4369
+ if (isGoodFrame) {
4370
+ goodFramesCount += 1;
4383
4371
  }
4384
- if (requestedDocumentType === 'passport' && passportDetectionScore < 0.3) {
4385
- requestedDocumentType = idCardFrontWasCaptured ? 'idCardBack' : 'idCardFront';
4372
+ var goodFramesThresholdMet = goodFramesCount >= goodFramesThreshold;
4373
+ var requestedDocumentType = state.requestedDocumentType;
4374
+ if (state.captureRequirement.includes('idCard') && state.allowIdCardBackToFrontCapture) {
4375
+ if (detectedDocumentType === 'idCardFront' && state.requestedDocumentType !== 'idCardFront' && !idCardFrontWasCaptured) {
4376
+ requestedDocumentType = 'idCardFront';
4377
+ } else if (detectedDocumentType === 'idCardBack' && state.requestedDocumentType !== 'idCardBack' && !idCardBackWasCaptured) {
4378
+ requestedDocumentType = 'idCardBack';
4379
+ }
4386
4380
  }
4381
+ if (state.captureRequirement === 'idCardOrPassport') {
4382
+ if (detectedDocumentType === 'passport' && state.requestedDocumentType !== 'passport') {
4383
+ requestedDocumentType = 'passport';
4384
+ }
4385
+ if (requestedDocumentType === 'passport' && passportDetectionScore < 0.3) {
4386
+ requestedDocumentType = idCardFrontWasCaptured ? 'idCardBack' : 'idCardFront';
4387
+ }
4388
+ }
4389
+ var hasBeenRunningForLongEnough = !!state.captureStartedAt && new Date().getTime() - state.captureStartedAt.getTime() > 1000;
4390
+ var overrideFlipRequirementThreshold = Math.ceil(state.allowOverrideWrongDocumentTypeAfterMs / 1000 * frameCaptureRate);
4391
+ var allowOverrideFlipRequirement = state.enableOverrideWrongDocumentTypeDialog && hasBeenRunningForLongEnough && !state.overrideWrongDocumentTypeGuidance && overrideFlipRequirementThreshold > 0 && (state.allowOverrideWrongDocumentTypeGuidance || wrongDocumentTypePredictions >= overrideFlipRequirementThreshold);
4392
+ return _assign(_assign({}, state), {
4393
+ videoWidth: frameWidth,
4394
+ videoHeight: frameHeight,
4395
+ detectedObjects: detectedObjects,
4396
+ bestDocument: bestDocument,
4397
+ requestedDocumentType: requestedDocumentType,
4398
+ detectedDocumentType: detectedDocumentType,
4399
+ detectionThresholdMet: detectionThresholdMet,
4400
+ documentInBounds: documentInBounds,
4401
+ documentTooClose: documentTooClose,
4402
+ documentIsStable: documentIsStable,
4403
+ flipRequired: flipRequired,
4404
+ backDetectedFirst: backDetectedFirst,
4405
+ idCardDetectedButNotAllowed: idCardDetectedButNotAllowed,
4406
+ passportDetectedButNotAllowed: passportDetectedButNotAllowed,
4407
+ allowOverrideWrongDocumentTypeGuidance: allowOverrideFlipRequirement,
4408
+ wrongDocumentTypePredictions: wrongDocumentTypePredictions,
4409
+ idCardFrontDetectionScore: idCardFrontDetectionScore,
4410
+ idCardFrontDetectionThresholdMet: idCardFrontDetectionThresholdMet,
4411
+ idCardBackDetectionScore: idCardBackDetectionScore,
4412
+ idCardBackDetectionThresholdMet: idCardBackDetectionThresholdMet,
4413
+ passportDetectionScore: passportDetectionScore,
4414
+ passportDetectionThresholdMet: passportDetectionThresholdMet,
4415
+ focusScore: focusScore,
4416
+ focusThresholdMet: focusThresholdMet,
4417
+ isGoodFrame: isGoodFrame,
4418
+ goodFramesCount: goodFramesCount,
4419
+ goodFramesThreshold: goodFramesThreshold,
4420
+ goodFramesThresholdMet: goodFramesThresholdMet,
4421
+ lastFrameCapturedAt: frameCapturedAt,
4422
+ frameCaptureRate: frameCaptureRate
4423
+ });
4387
4424
  }
4388
- var hasBeenRunningForLongEnough = !!state.captureStartedAt && new Date().getTime() - state.captureStartedAt.getTime() > 1000;
4389
- var overrideFlipRequirementThreshold = Math.ceil(state.allowOverrideWrongDocumentTypeAfterMs / 1000 * frameCaptureRate);
4390
- var allowOverrideFlipRequirement = state.enableOverrideWrongDocumentTypeDialog && hasBeenRunningForLongEnough && !state.overrideWrongDocumentTypeGuidance && overrideFlipRequirementThreshold > 0 && (state.allowOverrideWrongDocumentTypeGuidance || wrongDocumentTypePredictions >= overrideFlipRequirementThreshold);
4391
- return _assign(_assign({}, state), {
4392
- videoWidth: frameWidth,
4393
- videoHeight: frameHeight,
4394
- detectedObjects: detectedObjects,
4395
- bestDocument: bestDocument,
4396
- requestedDocumentType: requestedDocumentType,
4397
- detectedDocumentType: detectedDocumentType,
4398
- detectionThresholdMet: detectionThresholdMet,
4399
- documentInBounds: documentInBounds,
4400
- documentTooClose: documentTooClose,
4401
- documentIsStable: documentIsStable,
4402
- flipRequired: flipRequired,
4403
- backDetectedFirst: backDetectedFirst,
4404
- idCardDetectedButNotAllowed: idCardDetectedButNotAllowed,
4405
- passportDetectedButNotAllowed: passportDetectedButNotAllowed,
4406
- allowOverrideWrongDocumentTypeGuidance: allowOverrideFlipRequirement,
4407
- wrongDocumentTypePredictions: wrongDocumentTypePredictions,
4408
- idCardFrontDetectionScore: idCardFrontDetectionScore,
4409
- idCardFrontDetectionThresholdMet: idCardFrontDetectionThresholdMet,
4410
- idCardBackDetectionScore: idCardBackDetectionScore,
4411
- idCardBackDetectionThresholdMet: idCardBackDetectionThresholdMet,
4412
- passportDetectionScore: passportDetectionScore,
4413
- passportDetectionThresholdMet: passportDetectionThresholdMet,
4414
- focusScore: focusScore,
4415
- focusThresholdMet: focusThresholdMet,
4416
- isGoodFrame: isGoodFrame,
4417
- goodFramesCount: goodFramesCount,
4418
- goodFramesThreshold: goodFramesThreshold,
4419
- goodFramesThresholdMet: goodFramesThresholdMet,
4420
- lastFrameCapturedAt: frameCapturedAt,
4421
- frameCaptureRate: frameCaptureRate
4422
- });
4423
4425
  case 'captureStarted':
4424
4426
  return _assign(_assign({}, state), {
4425
4427
  captureStartedAt: new Date(),