@idscan/idvc2 2.7.8 → 2.8.1

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
- export declare const MIN_BACK_WITHOUT_BARCODE_FRAMES = 5;
1
+ export declare const MIN_BACK_WITHOUT_BARCODE_FRAMES = 6;
@@ -6,7 +6,7 @@ import Step from './modules/Step';
6
6
  import { Base64Image, ISize, IOffset } from './helpers/image';
7
7
  import MetaData from './modules/MetaData';
8
8
  import { StepType } from './environment/stepsDescription';
9
- import { IStepMode } from './defaultConfig';
9
+ import { StepConfig, StepMode } from './defaultConfig';
10
10
  import { IMRZResults } from './types/mrz';
11
11
  import { RealFaceTurnSide } from './types/enums/realFace';
12
12
  import { InitClient } from './modules/supaBaseClient';
@@ -72,6 +72,7 @@ export interface Context {
72
72
  isShowStayText: boolean;
73
73
  isShowHoldText: boolean;
74
74
  isShowHelpText: boolean;
75
+ isShowSwitchToUploaderText: boolean;
75
76
  isShowCloserText: boolean;
76
77
  isShowCenterText: boolean;
77
78
  isShowAwayText: boolean;
@@ -104,7 +105,9 @@ export interface Context {
104
105
  offsetsFace: IOffset;
105
106
  offsetsResized: IOffset;
106
107
  offsets: IOffset;
107
- get currentStepMode(): IStepMode;
108
+ loop: null | LoopFunction;
109
+ get currentStepMode(): StepMode;
110
+ get currentStepDelay(): number;
108
111
  get hasFrontStep(): boolean;
109
112
  calculateIsMirroring(): void;
110
113
  dropKeys(): void;
@@ -122,7 +125,7 @@ export interface Context {
122
125
  init(): void;
123
126
  dropCounters(): void;
124
127
  updateRealFaceTurnSide(): void;
125
- loop: null | LoopFunction;
128
+ getStepConfigValue<K extends keyof StepConfig>(key: K): StepConfig[K];
126
129
  }
127
130
  declare const context: Context;
128
131
  export default context;
@@ -10,29 +10,31 @@ export type NormalizedType = 'Path';
10
10
  * { boolean? } uploader
11
11
  * { boolean? } video
12
12
  */
13
- export interface IStepMode {
13
+ export type StepMode = {
14
14
  uploader?: boolean;
15
15
  video?: boolean;
16
- }
17
- export type IStepModeKeys = keyof IStepMode;
18
- export interface IStepConfig {
16
+ };
17
+ export type IStepModeKeys = keyof StepMode;
18
+ export type StepConfig = {
19
19
  type: StepType;
20
20
  name: string;
21
- mode: IStepMode;
22
- }
23
- export interface IDocumentType {
21
+ mode: StepMode;
22
+ autocaptureDelay?: number;
23
+ enableDesktopNotification?: boolean;
24
+ };
25
+ export type DocumentType = {
24
26
  type: DocumentTypeName;
25
- steps: IStepConfig[];
26
- mode?: IStepMode;
27
- }
27
+ steps: StepConfig[];
28
+ mode?: StepMode;
29
+ };
28
30
  type ImageURI = 'png' | 'jpeg' | 'webp';
29
- export type DefaultConfigName = 'el' | 'licenseKey' | 'networkUrl' | 'chunkPublicPath' | 'language' | 'documentTypes' | 'realFaceMode' | 'modalPosition' | 'resizeUploadedImage' | 'showSubmitBtn' | 'h_stepMode' | 'isShowDocumentTypeSelect' | 'useCDN' | 'useHeic' | 'processingImageFormat' | 'hideDocumentTitle' | 'autoContinue' | 'isShowGuidelinesButton' | 'fixFrontOrientAfterUpload' | 'onChange' | 'clickGuidlines' | 'onReset' | 'submit' | 'onRetakeHook' | 'onCameraError' | 'onMounted' | 'onReloaded';
31
+ export type DefaultConfigName = 'el' | 'licenseKey' | 'networkUrl' | 'chunkPublicPath' | 'language' | 'documentTypes' | 'realFaceMode' | 'modalPosition' | 'resizeUploadedImage' | 'showSubmitBtn' | 'h_stepMode' | 'isShowDocumentTypeSelect' | 'useCDN' | 'useHeic' | 'processingImageFormat' | 'hideDocumentTitle' | 'autoContinue' | 'autocaptureDelay' | 'isShowGuidelinesButton' | 'fixFrontOrientAfterUpload' | 'onChange' | 'clickGuidlines' | 'onReset' | 'submit' | 'onRetakeHook' | 'onCameraError' | 'onMounted' | 'onReloaded';
30
32
  /**
31
33
  * IDefaultConfig
32
34
  * @param {string} name,
33
35
  * @param {'String' | 'Array' | 'Number' | 'Boolean' | 'Function' | 'Object'} type,
34
36
  * @param {string} description,
35
- * @param {string | boolean | DefaultValueFunction | number | IDocumentType[]} defaultValue,
37
+ * @param {string | boolean | DefaultValueFunction | number | DocumentType[]} defaultValue,
36
38
  * @param {ValidationFn} validationFn,
37
39
  * @parma {boolean} hidden?,
38
40
  * @param {RealFaceMode[]} values?,
@@ -43,7 +45,7 @@ export interface IDefaultConfig {
43
45
  name: DefaultConfigName;
44
46
  type: 'String' | 'Array' | 'Number' | 'Boolean' | 'Function' | 'Object';
45
47
  description: string;
46
- defaultValue: IStepMode | string | boolean | DefaultValueFunction | number | IDocumentType[];
48
+ defaultValue: StepMode | string | boolean | DefaultValueFunction | number | DocumentType[];
47
49
  validationFn: ValidationFn;
48
50
  hidden?: boolean;
49
51
  values?: ModalPositionKeys[] | RealFaceMode[] | typeof supportedLanguages[number][] | ImageURI[];
@@ -22,6 +22,7 @@ interface IHintTexts {
22
22
  mrz: string;
23
23
  capturing: string;
24
24
  pdf: string;
25
+ switchToUploader: string;
25
26
  back: string;
26
27
  barcode: string;
27
28
  hold: string;
@@ -54,6 +55,10 @@ interface IGeneral {
54
55
  continueBtn: string;
55
56
  submitBtn: string;
56
57
  resetAllStepsBtn: string;
58
+ desktopNotification: {
59
+ barcode: string;
60
+ other: string;
61
+ };
57
62
  btnUploader: string;
58
63
  btnCamera: string;
59
64
  pressToUpdateText: string;
@@ -20,7 +20,7 @@ export declare const drawImageOnTestCanvas: (idata: ImageData | HTMLImageElement
20
20
  canvas: HTMLCanvasElement;
21
21
  ctx: CanvasRenderingContext2D;
22
22
  };
23
- export declare const drawCropOnCanvas: (idata: ImageData, bbox: Bbox, ctx: CanvasRenderingContext2D) => void;
23
+ export declare const drawCropOnCanvas: (bbox: Bbox, ctx: CanvasRenderingContext2D) => void;
24
24
  export declare const resize: (src: HTMLCanvasElement | HTMLVideoElement, dst: HTMLCanvasElement, offsets?: IOffset, cropSizes?: ISize) => ImageData;
25
25
  export declare const cropAndResize: (src: HTMLCanvasElement | HTMLVideoElement, dst: HTMLCanvasElement) => {
26
26
  crop: ICrop;
@@ -31,5 +31,16 @@ export declare const rectCenter: (start: Point, end: Point) => Point;
31
31
  export declare const angleBetweenTwoVectors: (vector1: number[], vector2: number[]) => number;
32
32
  export declare const distanceBetweenPointsXoR: (p1: Point, p2: Point) => number;
33
33
  export declare const triangleArea: (a: number, b: number, c: number) => number;
34
+ export declare const calculateBboxAspectRatio: (bbox: {
35
+ topLeft: {
36
+ x: number;
37
+ y: number;
38
+ };
39
+ bottomRight: {
40
+ x: number;
41
+ y: number;
42
+ };
43
+ }) => number;
44
+ export declare const isValidAspectRatio: (aspectRatio: number) => boolean;
34
45
  declare const geometry: Geometry;
35
46
  export default geometry;
@@ -4,15 +4,15 @@ import { SupportedLanguage } from './environment/langs';
4
4
  import { IDocumentTypeConfig } from './modules/validator';
5
5
  export default class VideoCapturing {
6
6
  constructor(config: IConfig);
7
- private init;
7
+ get version(): string;
8
8
  /**
9
9
  *
10
10
  * @param language
11
11
  */
12
12
  changeLanguage(language: SupportedLanguage): void;
13
- get version(): string;
14
13
  resetAllSteps(): void;
15
14
  reloadComponent(newConfig: Partial<IConfig>): void;
16
15
  updateDocumentTypes(documentTypes: IDocumentTypeConfig): void;
17
16
  showSpinner(val: any): void;
17
+ private init;
18
18
  }
@@ -1,4 +1,4 @@
1
- import { IStepConfig, ValidationFn } from '../defaultConfig';
1
+ import { StepConfig, ValidationFn } from '../defaultConfig';
2
2
  import { RealFaceMode } from '../environment/realFaceModes';
3
3
  import { SupportedLanguage } from '../environment/langs';
4
4
  import { StepType } from '../environment/stepsDescription';
@@ -57,8 +57,10 @@ export interface IConfig {
57
57
  * - video - capturing an image using the auto capture feature
58
58
  */
59
59
  documentTypes: IDocumentTypeConfig | null;
60
- /** the setting that enables the automatic transition from one step to the next step. Default */
60
+ /** the setting that enables the automatic transition from one step to the next step. Default is false */
61
61
  autoContinue?: boolean;
62
+ /** the setting the delay (in ms) when automatically switching steps. Default is 1000ms */
63
+ autocaptureDelay?: number;
62
64
  /** sets the maximum size in pixels (of the largest of the height or width) for a manually uploaded picture */
63
65
  resizeUploadedImage?: number;
64
66
  /** this setting will change the orientation of a front step's image if it is not horizontal when it is uploaded */
@@ -122,10 +124,11 @@ declare class Config implements IConfig {
122
124
  el: string;
123
125
  commonStepTypes: Set<StepType>;
124
126
  types: DocumentTypeName[];
125
- steps: IStepConfig[];
127
+ steps: StepConfig[];
126
128
  documentTypes: IDocumentTypeConfig | null;
127
129
  licenseKey: string;
128
130
  autoContinue: boolean;
131
+ autocaptureDelay: number;
129
132
  resizeUploadedImage: number;
130
133
  fixFrontOrientAfterUpload: boolean;
131
134
  useCDN: boolean;
@@ -1,13 +1,16 @@
1
1
  import { ClassLocalExitType } from '../neural models/classLocal/exits';
2
2
  export type Status = 'PENDING' | 'FULFILLED';
3
- interface ProcessUploadedImageResult {
3
+ type ClassLocalRecognitionResult = Promise<{
4
4
  side: ClassLocalExitType;
5
+ aspectRatio: number;
6
+ }>;
7
+ type ProcessUploadedImageResult = Awaited<ClassLocalRecognitionResult> & {
5
8
  perimeter: 'low' | 'ok';
6
- }
7
- interface FillingQueueResult {
8
- promise: Promise<ClassLocalExitType>;
9
+ };
10
+ type FillingQueueResult = {
9
11
  status: Status;
10
- }
12
+ promise: ClassLocalRecognitionResult;
13
+ };
11
14
  export declare const clearQueue: () => void;
12
15
  export declare const processUploadedImage: (smallImage: ImageData) => Promise<ProcessUploadedImageResult>;
13
16
  export declare const fillingQueue: (smallImage?: ImageData) => Promise<FillingQueueResult>;
@@ -13,7 +13,7 @@ export declare class PdfModule {
13
13
  out: any;
14
14
  isAllocate: boolean;
15
15
  successCount: number;
16
- _errorId: number;
16
+ pdfCapturedCount: number;
17
17
  edgMem: any;
18
18
  src2: any;
19
19
  outLen: any;
@@ -25,7 +25,19 @@ export declare class PdfModule {
25
25
  minPDFframes: number;
26
26
  cropSizes: ISize;
27
27
  canvasSizes: ISize;
28
- constructor(core: any, processor: any);
28
+ private preProcessCore;
29
+ private readonly preProcessReader;
30
+ constructor(pdf: {
31
+ core: any;
32
+ processor: any;
33
+ }, pdfWithPreProcess?: {
34
+ core: any;
35
+ processor: any;
36
+ });
37
+ _errorId: number;
38
+ get errorId(): number;
39
+ set errorId(id: number);
40
+ get errorVal(): any;
29
41
  /**
30
42
  *
31
43
  * @param geometry
@@ -34,9 +46,6 @@ export declare class PdfModule {
34
46
  * @param {{width: number, height: number}} canvasSizes - ui.borderCanvas
35
47
  */
36
48
  init(geometry: any, minPDFframes: any, cropSize: any, canvasSizes: any): void;
37
- set errorId(id: number);
38
- get errorId(): number;
39
- get errorVal(): any;
40
49
  /**
41
50
  * returns error Object
42
51
  * @return {{errorType: string, error: boolean, errorVal: string}}
@@ -61,9 +70,8 @@ export declare class PdfModule {
61
70
  bh: number;
62
71
  };
63
72
  allocate(): void;
64
- readPDF(data: any): any;
65
73
  drawCords(locations: Record<string, number>): Coord[];
66
- proccessPDF(data: ImageData): {
74
+ processPDF(data: ImageData): {
67
75
  status: boolean;
68
76
  predict: boolean;
69
77
  touch: boolean;
@@ -75,6 +83,21 @@ export declare class PdfModule {
75
83
  pdfSuccessCount: number;
76
84
  pdfCount: number;
77
85
  isSuccessProcess: boolean;
86
+ pdfCapturedCount: number;
87
+ };
88
+ processPDFWithPreProcess(data: ImageData): {
89
+ error: boolean;
90
+ errorType: string;
91
+ errorVal: any;
92
+ } | {
93
+ direction: any;
94
+ status: any;
95
+ error: any;
96
+ location: any;
97
+ resultParams: any;
98
+ trackString: any;
78
99
  };
100
+ private readPDF;
101
+ private readPDFWithPreProcess;
79
102
  }
80
103
  export default PdfModule;
@@ -1,9 +1,9 @@
1
1
  import { Base64Image } from '../helpers/image';
2
2
  import { StepType } from '../environment/stepsDescription';
3
- import { IStepMode } from '../defaultConfig';
3
+ import { StepMode } from '../defaultConfig';
4
4
  export interface IStepConfigMode {
5
5
  name: 'mode';
6
- value: IStepMode;
6
+ value: StepMode;
7
7
  }
8
8
  export type StepConfig = IStepConfigMode;
9
9
  export type StepConfigNames = StepConfig['name'];
@@ -60,11 +60,11 @@ export default class Step implements IStepCallback, IStepObj {
60
60
  img: Base64Image | null;
61
61
  cameraInfo: Record<string, any>;
62
62
  constructor(nameOrObj: string | IStepObj, type?: StepType, camera?: VideoFacingModeEnum, time?: number, img?: Base64Image | null);
63
+ get isShowManualSwitchButton(): boolean;
64
+ get capturingMode(): StepMode;
65
+ static createStep(stepObj: IStepObj): Step;
63
66
  setConfig(configName: StepConfigNames, configValue: StepConfigValues): void;
64
67
  hasConfig(configName: StepConfigNames): StepConfig | undefined;
65
68
  getConfig(configName: StepConfigNames): StepConfigValues | null;
66
- get isShowManualSwitchButton(): boolean;
67
- get capturingMode(): IStepMode;
68
69
  prepareStepForCallback(index: number): IStepCallback;
69
- static createStep(stepObj: IStepObj): Step;
70
70
  }
@@ -1,20 +1,3 @@
1
- import { Status } from '../FrontProcessing';
2
- import { ClassLocalExitType } from '../../neural models/classLocal/exits';
3
- interface ClassLocalResult {
4
- type: ClassLocalExitType;
5
- status: Status;
6
- }
7
1
  export declare const dropRes: () => void;
8
- declare const _default: (data: ImageData, result?: ClassLocalResult) => Promise<{
9
- status: boolean;
10
- predict: boolean;
11
- touch: boolean;
12
- image: ImageData;
13
- type: string;
14
- error: any;
15
- coords: any[];
16
- trackString: string;
17
- pdfSuccessCount: number;
18
- pdfCount: number;
19
- }>;
2
+ declare const _default: (data: ImageData) => Promise<Record<string, any>>;
20
3
  export default _default;
@@ -1,26 +1,30 @@
1
+ import type { StepType } from '../../environment/stepsDescription';
2
+ import { DocumentTypeIndex } from '../../environment/documentTypes';
1
3
  declare class MaskCapture {
2
- #private;
3
- private svg;
4
- private strokeMask;
4
+ private readonly svg;
5
+ private readonly strokeMask;
5
6
  private successMask;
7
+ private readonly pdfHint;
8
+ private readonly mrz2Hint;
9
+ private readonly mrz3Hint;
6
10
  private type;
7
11
  private cssVarContainer;
8
12
  private borders;
9
13
  private cssVars;
14
+ private hintElements;
15
+ constructor(cssVarContainer: any);
10
16
  _mainContainerSizes: {
11
17
  width: string;
12
18
  height: string;
13
19
  };
14
- constructor(cssVarContainer: any);
15
20
  /**
16
- * get computed width and height of element
17
- * @param {HTMLElement} el
18
- * @return {{width: string, height: string}}
21
+ * resizes frame based on width and height of main container
22
+ * @param {{width: number, height: number}} param - width and height of main container
19
23
  */
20
- getSizes: (el: any) => {
21
- width: string;
22
- height: string;
23
- };
24
+ set mainContainerSizes({ width, height }: {
25
+ width: any;
26
+ height: any;
27
+ });
24
28
  get svgSizes(): {
25
29
  width: string;
26
30
  height: string;
@@ -40,13 +44,33 @@ declare class MaskCapture {
40
44
  * @param {VideoFacingModeEnum} type - 'environment', 'user'
41
45
  */
42
46
  set maskType(type: any);
47
+ private set borderSizes(value);
43
48
  /**
44
- * resizes frame based on width and height of main container
45
- * @param {{width: number, height: number}} param - width and height of main container
49
+ * get computed width and height of element
50
+ * @param {HTMLElement} el
51
+ * @return {{width: string, height: string}}
46
52
  */
47
- set mainContainerSizes({ width, height }: {
48
- width: any;
49
- height: any;
50
- });
53
+ getSizes: (el: any) => {
54
+ width: string;
55
+ height: string;
56
+ };
57
+ applyMaskCaptureSizes(mainContainer: Element, currentStepType: StepType, currentDocument: DocumentTypeIndex | 0): void;
58
+ applyCaptureHintMask(mainContainer: Element): void;
59
+ applyMainContainerSize(mainContainer: Element): void;
60
+ changeHintState(currentStepType: any, currentDocument: any): void;
61
+ hideAllHints(): void;
62
+ showHintForCurrentStep(currentStepType: any, currentDocument: any): void;
63
+ private calculateUserSizes;
64
+ private calculateEnvironmentSizes;
65
+ private calculateFieldMaskSizes;
66
+ private applySizes;
67
+ private addAnimation;
68
+ private removeAnimation;
69
+ /**
70
+ *
71
+ * @param {Number} size1
72
+ * @param {Number} size2
73
+ */
74
+ private calculateSize;
51
75
  }
52
76
  export default MaskCapture;
@@ -1,20 +1,20 @@
1
- import { DefaultConfigName, IDocumentType } from '../../defaultConfig';
1
+ import { DefaultConfigName, DocumentType } from '../../defaultConfig';
2
2
  import { DocumentTypeName } from '../../environment/documentTypes';
3
3
  import { StepType } from '../../environment/stepsDescription';
4
4
  import { IDocumentTypeConfig, IValidator } from '../validator';
5
- declare class ValidateDocumentTypes implements IValidator<IDocumentType[]> {
5
+ declare class ValidateDocumentTypes implements IValidator<DocumentType[]> {
6
6
  types: any[];
7
7
  steps: any[];
8
8
  commonStepTypes: Set<StepType>;
9
9
  documentTypes: IDocumentTypeConfig;
10
- validate(val: IDocumentType[], fallback: IDocumentType[], configName: DefaultConfigName): {
10
+ validate(val: DocumentType[], fallback: DocumentType[], configName: DefaultConfigName): {
11
11
  types: any[];
12
12
  steps: any[];
13
13
  commonStepTypes: Set<StepType>;
14
14
  documentTypes: IDocumentTypeConfig;
15
15
  };
16
16
  validateTypes(types: string[]): DocumentTypeName[];
17
- transformDocType({ type, steps }: IDocumentType): void;
17
+ transformDocType({ type, steps }: DocumentType): void;
18
18
  setCommonStepTypes(): void;
19
19
  }
20
20
  export default ValidateDocumentTypes;
@@ -1,8 +1,8 @@
1
1
  import { DocumentTypeName } from '../environment/documentTypes';
2
- import { DefaultConfigName, IStepConfig } from '../defaultConfig';
2
+ import { DefaultConfigName, StepConfig } from '../defaultConfig';
3
3
  export type IDocumentTypeConfig = {
4
4
  type: DocumentTypeName;
5
- steps: IStepConfig[];
5
+ steps: StepConfig[];
6
6
  }[];
7
7
  type SimpleValidate<T> = (val: T, fallback: T, configName: DefaultConfigName) => any;
8
8
  type OneOfArray<T> = (valueToSet: T, defaultValue: T, configName: DefaultConfigName, availableValues: T[]) => any;
@@ -32,6 +32,7 @@ declare class Ui {
32
32
  pressToUpdateText: HTMLElement;
33
33
  pressToUpdateTextSuccess: HTMLElement;
34
34
  documentType: HTMLParagraphElement;
35
+ desktopNotification: HTMLDivElement;
35
36
  videoErrorText: HTMLElement;
36
37
  mainContainer: HTMLElement;
37
38
  Mask: MaskCapture;
@@ -45,6 +46,7 @@ declare class Ui {
45
46
  constructor();
46
47
  initTypeSelect(): void;
47
48
  resizeMainContainer(): void;
49
+ updateMaskCapture(): void;
48
50
  updateHoldText(data?: number, isCorrectDirection?: boolean): void;
49
51
  updateStepImg(): void;
50
52
  showVideoError(errorCode: string): void;
@@ -82,6 +84,7 @@ declare class Ui {
82
84
  getFakeContourWidth(width: number): number;
83
85
  setFakeContourStyles(width: number): void;
84
86
  setMirroring(): void;
87
+ setDesktopNotificationVisibility(): void;
85
88
  }
86
89
  declare const ui: {
87
90
  ui: Ui | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@idscan/idvc2",
3
- "version": "2.7.8",
3
+ "version": "2.8.1",
4
4
  "description": "component for the capturing documents",
5
5
  "main": "dist/idvc.js",
6
6
  "types": "dist/types/idvc.d.ts",