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.
@@ -1 +1 @@
1
- {"version":3,"file":"IdCaptureStateProvider.d.ts","sourceRoot":"","sources":["../../../src/components/id_capture/IdCaptureStateProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAEZ,QAAQ,EACR,SAAS,EAKV,MAAM,OAAO,CAAA;AAEd,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,oBAAoB,EAErB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAEL,mBAAmB,EACpB,MAAM,2BAA2B,CAAA;AAClC,OAAO,EACL,cAAc,EACd,YAAY,EACb,MAAM,oCAAoC,CAAA;AAC3C,OAAO,EACL,0BAA0B,EAE3B,MAAM,8BAA8B,CAAA;AAErC,MAAM,MAAM,YAAY,GAAG,WAAW,GAAG,UAAU,GAAG,gBAAgB,CAAA;AAEtE,MAAM,MAAM,cAAc,GAAG;IAC3B,mBAAmB,EAAE,OAAO,CAAA;IAC5B,SAAS,EAAE,OAAO,CAAA;IAElB,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;IAClB,cAAc,EAAE,MAAM,CAAA;IACtB,eAAe,EAAE,MAAM,CAAA;IACvB,kBAAkB,EAAE,MAAM,CAAA;IAC1B,eAAe,EAAE,MAAM,CAAA;IACvB,gBAAgB,EAAE,MAAM,CAAA;IAExB,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;IAClB,WAAW,EAAE,MAAM,CAAA;IAEnB,eAAe,EAAE,cAAc,EAAE,CAAA;IACjC,YAAY,EAAE,cAAc,GAAG,SAAS,CAAA;IAExC,oBAAoB,CAAC,EAAE,oBAAoB,CAAA;IAC3C,oBAAoB,EAAE,YAAY,CAAA;IAClC,qBAAqB,EAAE,OAAO,CA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D;IACE,IAAI,EAAE,iBAAiB,CAAA;IACvB,OAAO,EAAE;QAAE,UAAU,EAAE,mBAAmB,CAAA;KAAE,CAAA;CAC7C,GACD;IAAE,IAAI,EAAE,kBAAkB,CAAC;IAAC,OAAO,EAAE,gBAAgB,CAAA;CAAE,GACvD;IAAE,IAAI,EAAE,0BAA0B,CAAC;IAAC,OAAO,EAAE;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,GACpE;IAAE,IAAI,EAAE,sBAAsB,CAAA;CAAE,GAChC;IAAE,IAAI,EAAE,8BAA8B,CAAA;CAAE,GACxC;IAAE,IAAI,EAAE,yBAAyB,CAAA;CAAE,GACnC;IAAE,IAAI,EAAE,aAAa,CAAA;CAAE,GACvB;IAAE,IAAI,EAAE,gBAAgB,CAAA;CAAE,CAAA;AAE9B,MAAM,MAAM,iBAAiB,GAAG,QAAQ,CAAC,eAAe,CAAC,CAAA;AAEzD,eAAO,MAAM,qBAAqB,+BAA8C,CAAA;AAChF,eAAO,MAAM,wBAAwB,kCAEpC,CAAA;AA8aD,eAAO,MAAM,sBAAsB,kBAEhC;IACD,QAAQ,EAAE,SAAS,CAAA;CACpB,sBA8BA,CAAA;AAED,eAAO,MAAM,iBAAiB,QAAO,CAAC,cAAc,EAAE,iBAAiB,CAStE,CAAA"}
1
+ {"version":3,"file":"IdCaptureStateProvider.d.ts","sourceRoot":"","sources":["../../../src/components/id_capture/IdCaptureStateProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAEZ,QAAQ,EACR,SAAS,EAKV,MAAM,OAAO,CAAA;AAEd,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,oBAAoB,EAErB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAEL,mBAAmB,EACpB,MAAM,2BAA2B,CAAA;AAClC,OAAO,EACL,cAAc,EACd,YAAY,EACb,MAAM,oCAAoC,CAAA;AAC3C,OAAO,EACL,0BAA0B,EAE3B,MAAM,8BAA8B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AG,QAAQ,CAAC,eAAe,CAAC,CAAA;AAEzD,eAAO,MAAM,qBAAqB,+BAA8C,CAAA;AAChF,eAAO,MAAM,wBAAwB,kCAEpC,CAAA;AA+aD,eAAO,MAAM,sBAAsB,kBAEhC;IACD,QAAQ,EAAE,SAAS,CAAA;CACpB,sBA8BA,CAAA;AAED,eAAO,MAAM,iBAAiB,QAAO,CAAC,cAAc,EAAE,iBAAiB,CAStE,CAAA"}
@@ -230,7 +230,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
230
230
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
231
231
  };
232
232
 
233
- var webSdkVersion = '2.2.6';
233
+ var webSdkVersion = '2.2.7';
234
234
 
235
235
  function getPlatform() {
236
236
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -4351,105 +4351,107 @@ var _reducer = function reducer(state, action) {
4351
4351
  guideImageHeight: action.payload.height
4352
4352
  });
4353
4353
  case 'objectsDetected':
4354
- var _d = action.payload.prediction,
4355
- detectedObjects = _d.detectedObjects,
4356
- detectionThresholdMet = _d.detectionThresholdMet,
4357
- detectedDocumentType = _d.detectedDocumentType,
4358
- idCardFrontDetectionScore = _d.idCardFrontDetectionScore,
4359
- idCardFrontDetectionThresholdMet = _d.idCardFrontDetectionThresholdMet,
4360
- idCardBackDetectionScore = _d.idCardBackDetectionScore,
4361
- idCardBackDetectionThresholdMet = _d.idCardBackDetectionThresholdMet,
4362
- passportDetectionScore = _d.passportDetectionScore,
4363
- passportDetectionThresholdMet = _d.passportDetectionThresholdMet,
4364
- bestDocument = _d.bestDocument,
4365
- documentInBounds = _d.documentInBounds,
4366
- documentTooClose = _d.documentTooClose,
4367
- documentIsStable = _d.documentIsStable,
4368
- focusScore = _d.focusScore,
4369
- focusThresholdMet = _d.focusThresholdMet,
4370
- frameWidth = _d.frameWidth,
4371
- frameHeight = _d.frameHeight;
4372
- var frameCapturedAt = new Date();
4373
- var frameCaptureRate = 0;
4374
- var goodFramesThreshold = state.goodFramesThreshold;
4375
- if (state.lastFrameCapturedAt) {
4376
- var frameTime = frameCapturedAt.getTime() - state.lastFrameCapturedAt.getTime();
4377
- if (frameTime > 0) {
4378
- frameCaptureRate = 1000.0 / frameTime;
4379
- if (frameCaptureRate > 0) {
4380
- goodFramesThreshold = Math.ceil(3 * frameCaptureRate);
4354
+ {
4355
+ var _d = action.payload.prediction,
4356
+ detectedObjects = _d.detectedObjects,
4357
+ detectionThresholdMet = _d.detectionThresholdMet,
4358
+ detectedDocumentType = _d.detectedDocumentType,
4359
+ idCardFrontDetectionScore = _d.idCardFrontDetectionScore,
4360
+ idCardFrontDetectionThresholdMet = _d.idCardFrontDetectionThresholdMet,
4361
+ idCardBackDetectionScore = _d.idCardBackDetectionScore,
4362
+ idCardBackDetectionThresholdMet = _d.idCardBackDetectionThresholdMet,
4363
+ passportDetectionScore = _d.passportDetectionScore,
4364
+ passportDetectionThresholdMet = _d.passportDetectionThresholdMet,
4365
+ bestDocument = _d.bestDocument,
4366
+ documentInBounds = _d.documentInBounds,
4367
+ documentTooClose = _d.documentTooClose,
4368
+ documentIsStable = _d.documentIsStable,
4369
+ focusScore = _d.focusScore,
4370
+ focusThresholdMet = _d.focusThresholdMet,
4371
+ frameWidth = _d.frameWidth,
4372
+ frameHeight = _d.frameHeight;
4373
+ var frameCapturedAt = new Date();
4374
+ var frameCaptureRate = 0;
4375
+ var goodFramesThreshold = state.goodFramesThreshold;
4376
+ if (state.lastFrameCapturedAt) {
4377
+ var frameTime = frameCapturedAt.getTime() - state.lastFrameCapturedAt.getTime();
4378
+ if (frameTime > 0) {
4379
+ frameCaptureRate = 1000.0 / frameTime;
4380
+ if (frameCaptureRate > 0) {
4381
+ goodFramesThreshold = Math.ceil(3 * frameCaptureRate);
4382
+ }
4381
4383
  }
4382
4384
  }
4383
- }
4384
- var idCardDetectedButNotAllowed = detectedDocumentType.includes('idCard') && !state.captureRequirement.includes('idCard');
4385
- var passportNotAllowed = !state.captureRequirement.toLowerCase().includes('passport');
4386
- var idCardFrontWasCaptured = 'idCardFront' in state.capturedDocuments;
4387
- var idCardBackWasCaptured = 'idCardBack' in state.capturedDocuments;
4388
- var idCardBeingCaptured = idCardFrontWasCaptured && !idCardBackWasCaptured || !idCardFrontWasCaptured && idCardBackWasCaptured;
4389
- var passportDetectedButNotAllowed = detectedDocumentType === 'passport' && (passportNotAllowed || idCardBeingCaptured);
4390
- var flipRequired = !state.overrideWrongDocumentTypeGuidance && (state.allowIdCardBackToFrontCapture ? idCardFrontWasCaptured && detectedDocumentType === 'idCardFront' : state.requestedDocumentType === 'idCardBack' && detectedDocumentType === 'idCardFront');
4391
- var backDetectedFirst = !state.overrideWrongDocumentTypeGuidance && (state.allowIdCardBackToFrontCapture ? idCardBackWasCaptured && detectedDocumentType === 'idCardBack' : state.requestedDocumentType === 'idCardFront' && detectedDocumentType === 'idCardBack');
4392
- var wrongDocumentTypePredictions = state.wrongDocumentTypePredictions;
4393
- if (state.captureState === 'capturing' && (flipRequired || backDetectedFirst)) {
4394
- wrongDocumentTypePredictions += 1;
4395
- }
4396
- var isGoodFrame = detectionThresholdMet && documentInBounds && !documentTooClose && !flipRequired && !backDetectedFirst && focusThresholdMet && !idCardDetectedButNotAllowed && !passportDetectedButNotAllowed && documentIsStable;
4397
- var goodFramesCount = state.goodFramesCount;
4398
- if (isGoodFrame) {
4399
- goodFramesCount += 1;
4400
- }
4401
- var goodFramesThresholdMet = goodFramesCount >= goodFramesThreshold;
4402
- var requestedDocumentType = state.requestedDocumentType;
4403
- if (state.captureRequirement.includes('idCard') && state.allowIdCardBackToFrontCapture) {
4404
- if (detectedDocumentType === 'idCardFront' && state.requestedDocumentType !== 'idCardFront' && !idCardFrontWasCaptured) {
4405
- requestedDocumentType = 'idCardFront';
4406
- } else if (detectedDocumentType === 'idCardBack' && state.requestedDocumentType !== 'idCardBack' && !idCardBackWasCaptured) {
4407
- requestedDocumentType = 'idCardBack';
4385
+ var idCardDetectedButNotAllowed = detectedDocumentType.includes('idCard') && !state.captureRequirement.includes('idCard');
4386
+ var passportNotAllowed = !state.captureRequirement.toLowerCase().includes('passport');
4387
+ var idCardFrontWasCaptured = 'idCardFront' in state.capturedDocuments;
4388
+ var idCardBackWasCaptured = 'idCardBack' in state.capturedDocuments;
4389
+ var idCardBeingCaptured = idCardFrontWasCaptured && !idCardBackWasCaptured || !idCardFrontWasCaptured && idCardBackWasCaptured;
4390
+ var passportDetectedButNotAllowed = detectedDocumentType === 'passport' && (passportNotAllowed || idCardBeingCaptured);
4391
+ var flipRequired = !state.overrideWrongDocumentTypeGuidance && (state.allowIdCardBackToFrontCapture ? idCardFrontWasCaptured && detectedDocumentType === 'idCardFront' : state.requestedDocumentType === 'idCardBack' && detectedDocumentType === 'idCardFront');
4392
+ var backDetectedFirst = !state.overrideWrongDocumentTypeGuidance && (state.allowIdCardBackToFrontCapture ? idCardBackWasCaptured && detectedDocumentType === 'idCardBack' : state.requestedDocumentType === 'idCardFront' && detectedDocumentType === 'idCardBack');
4393
+ var wrongDocumentTypePredictions = state.wrongDocumentTypePredictions;
4394
+ if (state.captureState === 'capturing' && (flipRequired || backDetectedFirst)) {
4395
+ wrongDocumentTypePredictions += 1;
4408
4396
  }
4409
- }
4410
- if (state.captureRequirement === 'idCardOrPassport') {
4411
- if (detectedDocumentType === 'passport' && state.requestedDocumentType !== 'passport') {
4412
- requestedDocumentType = 'passport';
4397
+ var isGoodFrame = detectionThresholdMet && documentInBounds && !documentTooClose && !flipRequired && !backDetectedFirst && focusThresholdMet && !idCardDetectedButNotAllowed && !passportDetectedButNotAllowed && documentIsStable;
4398
+ var goodFramesCount = state.goodFramesCount;
4399
+ if (isGoodFrame) {
4400
+ goodFramesCount += 1;
4413
4401
  }
4414
- if (requestedDocumentType === 'passport' && passportDetectionScore < 0.3) {
4415
- requestedDocumentType = idCardFrontWasCaptured ? 'idCardBack' : 'idCardFront';
4402
+ var goodFramesThresholdMet = goodFramesCount >= goodFramesThreshold;
4403
+ var requestedDocumentType = state.requestedDocumentType;
4404
+ if (state.captureRequirement.includes('idCard') && state.allowIdCardBackToFrontCapture) {
4405
+ if (detectedDocumentType === 'idCardFront' && state.requestedDocumentType !== 'idCardFront' && !idCardFrontWasCaptured) {
4406
+ requestedDocumentType = 'idCardFront';
4407
+ } else if (detectedDocumentType === 'idCardBack' && state.requestedDocumentType !== 'idCardBack' && !idCardBackWasCaptured) {
4408
+ requestedDocumentType = 'idCardBack';
4409
+ }
4416
4410
  }
4411
+ if (state.captureRequirement === 'idCardOrPassport') {
4412
+ if (detectedDocumentType === 'passport' && state.requestedDocumentType !== 'passport') {
4413
+ requestedDocumentType = 'passport';
4414
+ }
4415
+ if (requestedDocumentType === 'passport' && passportDetectionScore < 0.3) {
4416
+ requestedDocumentType = idCardFrontWasCaptured ? 'idCardBack' : 'idCardFront';
4417
+ }
4418
+ }
4419
+ var hasBeenRunningForLongEnough = !!state.captureStartedAt && new Date().getTime() - state.captureStartedAt.getTime() > 1000;
4420
+ var overrideFlipRequirementThreshold = Math.ceil(state.allowOverrideWrongDocumentTypeAfterMs / 1000 * frameCaptureRate);
4421
+ var allowOverrideFlipRequirement = state.enableOverrideWrongDocumentTypeDialog && hasBeenRunningForLongEnough && !state.overrideWrongDocumentTypeGuidance && overrideFlipRequirementThreshold > 0 && (state.allowOverrideWrongDocumentTypeGuidance || wrongDocumentTypePredictions >= overrideFlipRequirementThreshold);
4422
+ return _assign(_assign({}, state), {
4423
+ videoWidth: frameWidth,
4424
+ videoHeight: frameHeight,
4425
+ detectedObjects: detectedObjects,
4426
+ bestDocument: bestDocument,
4427
+ requestedDocumentType: requestedDocumentType,
4428
+ detectedDocumentType: detectedDocumentType,
4429
+ detectionThresholdMet: detectionThresholdMet,
4430
+ documentInBounds: documentInBounds,
4431
+ documentTooClose: documentTooClose,
4432
+ documentIsStable: documentIsStable,
4433
+ flipRequired: flipRequired,
4434
+ backDetectedFirst: backDetectedFirst,
4435
+ idCardDetectedButNotAllowed: idCardDetectedButNotAllowed,
4436
+ passportDetectedButNotAllowed: passportDetectedButNotAllowed,
4437
+ allowOverrideWrongDocumentTypeGuidance: allowOverrideFlipRequirement,
4438
+ wrongDocumentTypePredictions: wrongDocumentTypePredictions,
4439
+ idCardFrontDetectionScore: idCardFrontDetectionScore,
4440
+ idCardFrontDetectionThresholdMet: idCardFrontDetectionThresholdMet,
4441
+ idCardBackDetectionScore: idCardBackDetectionScore,
4442
+ idCardBackDetectionThresholdMet: idCardBackDetectionThresholdMet,
4443
+ passportDetectionScore: passportDetectionScore,
4444
+ passportDetectionThresholdMet: passportDetectionThresholdMet,
4445
+ focusScore: focusScore,
4446
+ focusThresholdMet: focusThresholdMet,
4447
+ isGoodFrame: isGoodFrame,
4448
+ goodFramesCount: goodFramesCount,
4449
+ goodFramesThreshold: goodFramesThreshold,
4450
+ goodFramesThresholdMet: goodFramesThresholdMet,
4451
+ lastFrameCapturedAt: frameCapturedAt,
4452
+ frameCaptureRate: frameCaptureRate
4453
+ });
4417
4454
  }
4418
- var hasBeenRunningForLongEnough = !!state.captureStartedAt && new Date().getTime() - state.captureStartedAt.getTime() > 1000;
4419
- var overrideFlipRequirementThreshold = Math.ceil(state.allowOverrideWrongDocumentTypeAfterMs / 1000 * frameCaptureRate);
4420
- var allowOverrideFlipRequirement = state.enableOverrideWrongDocumentTypeDialog && hasBeenRunningForLongEnough && !state.overrideWrongDocumentTypeGuidance && overrideFlipRequirementThreshold > 0 && (state.allowOverrideWrongDocumentTypeGuidance || wrongDocumentTypePredictions >= overrideFlipRequirementThreshold);
4421
- return _assign(_assign({}, state), {
4422
- videoWidth: frameWidth,
4423
- videoHeight: frameHeight,
4424
- detectedObjects: detectedObjects,
4425
- bestDocument: bestDocument,
4426
- requestedDocumentType: requestedDocumentType,
4427
- detectedDocumentType: detectedDocumentType,
4428
- detectionThresholdMet: detectionThresholdMet,
4429
- documentInBounds: documentInBounds,
4430
- documentTooClose: documentTooClose,
4431
- documentIsStable: documentIsStable,
4432
- flipRequired: flipRequired,
4433
- backDetectedFirst: backDetectedFirst,
4434
- idCardDetectedButNotAllowed: idCardDetectedButNotAllowed,
4435
- passportDetectedButNotAllowed: passportDetectedButNotAllowed,
4436
- allowOverrideWrongDocumentTypeGuidance: allowOverrideFlipRequirement,
4437
- wrongDocumentTypePredictions: wrongDocumentTypePredictions,
4438
- idCardFrontDetectionScore: idCardFrontDetectionScore,
4439
- idCardFrontDetectionThresholdMet: idCardFrontDetectionThresholdMet,
4440
- idCardBackDetectionScore: idCardBackDetectionScore,
4441
- idCardBackDetectionThresholdMet: idCardBackDetectionThresholdMet,
4442
- passportDetectionScore: passportDetectionScore,
4443
- passportDetectionThresholdMet: passportDetectionThresholdMet,
4444
- focusScore: focusScore,
4445
- focusThresholdMet: focusThresholdMet,
4446
- isGoodFrame: isGoodFrame,
4447
- goodFramesCount: goodFramesCount,
4448
- goodFramesThreshold: goodFramesThreshold,
4449
- goodFramesThresholdMet: goodFramesThresholdMet,
4450
- lastFrameCapturedAt: frameCapturedAt,
4451
- frameCaptureRate: frameCaptureRate
4452
- });
4453
4455
  case 'captureStarted':
4454
4456
  return _assign(_assign({}, state), {
4455
4457
  captureStartedAt: new Date(),