@idscan/idvc2 3.8.0 → 3.9.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.
@@ -3,6 +3,7 @@ import { DocumentTypeName } from './environment/documentTypes';
3
3
  import { StepType } from './environment/stepsDescription';
4
4
  import { AllLabels, supportedLanguages } from './environment/langs';
5
5
  import { ModalPositionKeys } from './environment/modalPosition';
6
+ import { MessageAfterDelay } from './types/core/MessageAfterDelay';
6
7
  import { DeepPartial } from './types/helpers/DeepPartial';
7
8
  export type ValidationFn = 'validateElement' | 'validateString' | 'validateDocumentTypes' | 'validateDistinctStringInArray' | 'validateNumber' | 'validateFunction' | 'ValidateDictionaryLangMatch' | 'validateBool' | 'validateAllowCameraSelection';
8
9
  type DefaultValueFunction = () => boolean;
@@ -25,6 +26,7 @@ export type StepConfig = {
25
26
  enableFourCornerCapture?: boolean;
26
27
  shouldRecordMultiImages?: boolean;
27
28
  delayUntilCaptureButtonVisible?: number;
29
+ messageAfterDelay?: MessageAfterDelay;
28
30
  };
29
31
  export type DocumentType = {
30
32
  type: DocumentTypeName;
@@ -39,7 +41,7 @@ export type DefaultConfigName = 'el' | 'licenseKey' | 'networkUrl' | 'language'
39
41
  * @param {string} name,
40
42
  * @param {'String' | 'Array' | 'Number' | 'Boolean' | 'Function' | 'Object'} type,
41
43
  * @param {string} description,
42
- * @param {string | boolean | DefaultValueFunction | number | DocumentType[]} defaultValue,
44
+ * @param {string | boolean | DefaultValueFunction | number | DocumentType[] | MessageAfterDelay} defaultValue,
43
45
  * @param {ValidationFn} validationFn,
44
46
  * @parma {boolean} hidden?,
45
47
  * @param {RealFaceMode[]} values?,
@@ -50,7 +52,7 @@ export interface IDefaultConfig {
50
52
  name: DefaultConfigName;
51
53
  type: 'String' | 'Array' | 'Number' | 'Boolean' | 'Function' | 'Object';
52
54
  description: string;
53
- defaultValue: StepMode | string | boolean | DefaultValueFunction | number | DocumentType[];
55
+ defaultValue: StepMode | string | boolean | DefaultValueFunction | number | DocumentType[] | MessageAfterDelay;
54
56
  validationFn: ValidationFn;
55
57
  hidden?: boolean;
56
58
  values?: ModalPositionKeys[] | RealFaceMode[] | typeof supportedLanguages[number][] | ImageURI[] | DeepPartial<AllLabels>;
@@ -0,0 +1,6 @@
1
+ export type Base64 = string;
2
+ export type Base64DataUrl = string;
3
+ export declare const base64ToUint8Array: (base64: string) => Uint8Array;
4
+ export declare const isBase64DataUrl: (value: string) => value is string;
5
+ export declare const extractBase64: (input?: string | null) => Base64;
6
+ export declare const blobToBase64DataUrl: (blob: Blob) => Promise<Base64DataUrl>;
@@ -0,0 +1,4 @@
1
+ export declare const createCancelableTimeout: () => {
2
+ start: (cb: () => void, delay: number) => void;
3
+ cancel: () => void;
4
+ };
@@ -1,6 +1,5 @@
1
1
  import { ICrop } from './ts/common';
2
2
  import { Bbox } from '../types/geometry';
3
- export type Base64Image = string;
4
3
  export type RGBAColor = string;
5
4
  export type RGBColor8 = Uint8ClampedArray;
6
5
  export type RGBColor32 = Float32Array;
@@ -1,8 +1,3 @@
1
- import { Base64Image } from './image';
2
- export declare const encodeMeta: (metadata: any) => string;
3
- export declare const decodeMeta: (str: string) => any;
4
- export declare const base64ToArrayBuffer: (base64: string) => Uint8Array;
5
- export declare const getDataFromBase64Img: (imgString: Base64Image) => string;
6
1
  export declare const splitWordByUpperLetters: (word: string) => string[];
7
2
  export declare const normalizeCamelCase: (word: string) => string;
8
3
  export declare const removeHtmlEntities: (str: string) => string;
@@ -1,3 +1,4 @@
1
+ import { MessageAfterDelay } from '../types/core/MessageAfterDelay';
1
2
  /**
2
3
  * check value to be boolean
3
4
  * @param val
@@ -42,6 +43,7 @@ type ValidationResult = {
42
43
  invalidPathsWithReason: Record<string, string>;
43
44
  };
44
45
  export declare const isValidDeepPartial: <T extends Record<string, unknown>>(original: T, candidate: unknown) => ValidationResult;
46
+ export declare const validateMessageAfterDelay: (value: unknown, name: string, type: string) => MessageAfterDelay | undefined;
45
47
  declare const _default: {
46
48
  isValidBool: (val: any) => boolean;
47
49
  isValidFunction: (val: any) => boolean;
@@ -1,6 +1,8 @@
1
1
  import { IConfig } from './modules/Config';
2
2
  import type { SupportedLanguage } from './environment/langs';
3
3
  import type { IDocumentTypeConfig } from './modules/validator';
4
+ export { prepareRequestDataForDiveApi, } from './integrations/prepareRequestDataForDiveApi';
5
+ export type { IPrepareRequestDataForDiveApiParams } from './integrations/prepareRequestDataForDiveApi';
4
6
  export default class VideoCapturing {
5
7
  constructor(config: IConfig);
6
8
  get version(): string;
@@ -0,0 +1,59 @@
1
+ import { IDataForSubmit } from '../util';
2
+ import { Base64 } from '../helpers/base64';
3
+ import { DocumentTypeIndex } from '../environment/documentTypes';
4
+ interface IRequestBase {
5
+ frontImageBase64: Base64;
6
+ backOrSecondImageBase64: Base64;
7
+ faceImageBase64: Base64;
8
+ ssn: string;
9
+ frontMultiImagesBase64: Base64;
10
+ faceMultiImagesBase64: Base64;
11
+ documentType: DocumentTypeIndex | 0;
12
+ }
13
+ interface IRequestV3 extends IRequestBase {
14
+ trackString: string;
15
+ verifyFace: boolean;
16
+ captureMethod: string;
17
+ userAgent: string;
18
+ frontEndMetadata: string;
19
+ metadata?: string;
20
+ }
21
+ interface IRequestV4 extends IRequestBase {
22
+ trackString: {
23
+ data: string;
24
+ barcodeParams: string;
25
+ };
26
+ metadata: {
27
+ captureMethod: string;
28
+ userAgent: string;
29
+ frontEndMetadata: string;
30
+ otherMetadata?: string;
31
+ };
32
+ }
33
+ export interface IPrepareRequestDataForDiveApiParams<P = Record<string, unknown>> {
34
+ data?: IDataForSubmit;
35
+ payload?: P;
36
+ versionAPI?: '3' | '3.1' | '4';
37
+ }
38
+ type IRequestPayload = Record<string, unknown>;
39
+ /**
40
+ * Prepares request payload for Dive API (v3 / v3.1 / v4) based on submitted capture data.
41
+ *
42
+ * Builds a normalized request object:
43
+ * - extracts base64 images (front, back/second, face)
44
+ * - prepares multi-capture images if available
45
+ * - parses metadata
46
+ * - adjusts payload structure depending on API version
47
+ *
48
+ * @template P - Additional custom payload fields to be merged into the request
49
+ *
50
+ * @param params - Parameters object
51
+ * @param params.data - Raw data collected from the results of the IDVC capture flow
52
+ * @param params.payload - Optional custom fields to extend the request payload
53
+ * @param params.versionAPI - Target Dive API version (`'3' | '3.1' | '4'`)
54
+ *
55
+ * @returns Promise resolving to a prepared Dive API request object
56
+ * compatible with the specified API version and extended with custom payload fields
57
+ */
58
+ export declare const prepareRequestDataForDiveApi: <P extends IRequestPayload>({ data, versionAPI, payload, }: IPrepareRequestDataForDiveApiParams<P>) => Promise<(IRequestV3 | IRequestV4) & P>;
59
+ export {};
@@ -3,8 +3,6 @@ export interface IMrzCoords {
3
3
  locations: MRZLocation;
4
4
  color: 'green' | 'yellow';
5
5
  }
6
- export declare const loopTimeout: (ms: number) => Promise<void>;
7
- export declare const demandCapturingTimeout: (ms: number) => Promise<void>;
8
6
  export declare const unmountIDVC: () => void;
9
7
  export declare const loop: () => Promise<false>;
10
8
  declare const _default: {
@@ -1,6 +1,6 @@
1
- import { Base64Image } from './helpers/image';
1
+ import { Base64 } from './helpers/base64';
2
2
  type Base64Object = {
3
- data: ImageData | Base64Image | null;
3
+ data: ImageData | Base64 | null;
4
4
  err: boolean;
5
5
  };
6
6
  declare const dropFile: (base64Obj: Base64Object) => Promise<void>;
@@ -1,8 +1,9 @@
1
- import { Base64Image } from '../helpers/image';
2
1
  import { StepType, StepTypeImageName } from '../environment/stepsDescription';
3
2
  import { StepMode } from '../defaultConfig';
4
3
  import { ErrorCodes } from '../environment/langs';
5
4
  import { DocumentTypeName } from '../environment/documentTypes';
5
+ import { Base64 } from '../helpers/base64';
6
+ import { MessageAfterDelay } from '../types/core/MessageAfterDelay';
6
7
  export interface IStepConfigMode {
7
8
  name: 'mode';
8
9
  value: StepMode;
@@ -14,7 +15,7 @@ export interface IStepObj {
14
15
  name: string;
15
16
  type: StepType;
16
17
  camera: VideoFacingModeEnum;
17
- img: Base64Image | null;
18
+ img: Base64 | null;
18
19
  err?: string | null;
19
20
  text?: string;
20
21
  time?: number;
@@ -22,10 +23,11 @@ export interface IStepObj {
22
23
  stepTypeImageName: StepTypeImageName;
23
24
  shouldRecordMultiImages?: boolean;
24
25
  delayUntilCaptureButtonVisible?: number;
26
+ messageAfterDelay?: MessageAfterDelay;
25
27
  }
26
28
  export interface IStepCallback {
27
29
  /** base64 encoded step image */
28
- img: Base64Image | null;
30
+ img: Base64 | null;
29
31
  /** blob step image */
30
32
  blob: Blob | null;
31
33
  /** blob step MultiImages */
@@ -43,7 +45,7 @@ export interface IStepCallback {
43
45
  /** mrz recognized text */
44
46
  mrzText?: string;
45
47
  /** cropped base64 encoded mrz image */
46
- mrzImg?: Base64Image | null;
48
+ mrzImg?: Base64 | null;
47
49
  /** cropped blob mrz image */
48
50
  mrzBlob?: Blob | null;
49
51
  /** recognized text */
@@ -54,7 +56,7 @@ export default class Step implements IStepCallback, IStepObj {
54
56
  multiImagesBlob: Blob | null;
55
57
  errorCode: ErrorCodes | null | undefined;
56
58
  mrzText?: string;
57
- mrzImg?: Base64Image | null;
59
+ mrzImg?: Base64 | null;
58
60
  mrzBlob?: Blob | null;
59
61
  trackString?: string;
60
62
  err?: string | null;
@@ -65,11 +67,12 @@ export default class Step implements IStepCallback, IStepObj {
65
67
  name: string;
66
68
  type: StepType;
67
69
  camera: VideoFacingModeEnum;
68
- img: Base64Image | null;
70
+ img: Base64 | null;
69
71
  cameraInfo: Record<string, any>;
70
72
  stepTypeImageName: StepTypeImageName;
71
73
  shouldRecordMultiImages: boolean;
72
74
  delayUntilCaptureButtonVisible?: number;
75
+ messageAfterDelay?: MessageAfterDelay;
73
76
  constructor(nameOrObj: string | IStepObj);
74
77
  get isShowManualSwitchButton(): boolean;
75
78
  get capturingMode(): StepMode;
@@ -1,5 +1,5 @@
1
- import type { Base64Image } from '../helpers/image';
2
1
  import type { ErrorCodeNames } from '../environment/langs';
2
+ import { Base64 } from '../helpers/base64';
3
3
  type ProcessingErrorCode = ErrorCodeNames | '';
4
4
  type Coordinate = {
5
5
  x: number;
@@ -22,9 +22,9 @@ export declare const pdfProcess: (smallImage: any, { perimeter }: {
22
22
  }) => Promise<boolean>;
23
23
  /**
24
24
  *
25
- * @param {Base64Image} data - base64 image
25
+ * @param {Base64} data - base64 image
26
26
  */
27
- export declare const barCodeProcess: (data: Base64Image) => Promise<boolean>;
27
+ export declare const barCodeProcess: (data: Base64) => Promise<boolean>;
28
28
  export declare const frontProcess: ({ side, perimeter, isHasFace }: {
29
29
  side: any;
30
30
  perimeter: any;
@@ -13,6 +13,7 @@ export declare class CanvasWrapper {
13
13
  generalTypeCanvas: HTMLCanvasElement;
14
14
  blazeFaceCanvas: HTMLCanvasElement;
15
15
  meshFaceCanvas: HTMLCanvasElement;
16
+ multiImagesSourceCanvas: HTMLCanvasElement;
16
17
  mrzCtx: CanvasRenderingContext2D;
17
18
  scaledCtx: CanvasRenderingContext2D;
18
19
  videoCtx: CanvasRenderingContext2D;
@@ -21,8 +22,10 @@ export declare class CanvasWrapper {
21
22
  faceCtx: CanvasRenderingContext2D;
22
23
  blazeFaceCtx: CanvasRenderingContext2D;
23
24
  meshFaceCtx: CanvasRenderingContext2D;
25
+ multiImagesSourceCtx: CanvasRenderingContext2D;
26
+ isStartedRecord: boolean;
24
27
  private readonly video;
25
- private readonly faceOffset;
28
+ private readonly faceCrop;
26
29
  private readonly canvasNames;
27
30
  private readonly canvasCtxNames;
28
31
  private multiImagesRecorder;
@@ -31,6 +34,10 @@ export declare class CanvasWrapper {
31
34
  restoreCanvas(): void;
32
35
  toggleBorderCanvas(currentStepType: StepType, isStarted: boolean): void;
33
36
  toggleRecordMultiImages(currentStepObj: Step, isStarted: boolean): void;
37
+ private getCenteredSquareCrop;
38
+ private getCenteredCropForRatio;
39
+ private getMultiImageDrawParams;
40
+ private prepareMultiImageSourceCanvas;
34
41
  clearBorderCtx(): void;
35
42
  setVideoCanvasSizes({ width, height }: Size): void;
36
43
  getBaseSizes(coefficient?: number): {
@@ -42,7 +49,7 @@ export declare class CanvasWrapper {
42
49
  prepareFaceCanvas(width: number, height: number): void;
43
50
  drawVideo(): void;
44
51
  recreateWorkingCanvas(browser: BrowserInfo, browserMajorVersion: number): void;
45
- drawResizedVideo(currentStepType: StepType, isRealFaceAvailable: boolean): void;
52
+ drawResizedVideo(currentStepType: StepType, isRealFaceAvailable: boolean, sizeK: number): void;
46
53
  private drawResized;
47
54
  private drawFace;
48
55
  private recreateCanvas;
@@ -7,8 +7,8 @@ export declare class CaptureButton implements ICaptureButton {
7
7
  private controlButton;
8
8
  private readonly checkIsCameraErrorVisible;
9
9
  constructor(element: HTMLElement, onClick: ControlButtonEvents, checkIsCameraErrorVisible: () => boolean);
10
- private timeout;
11
- private showCaptureButtonTimeout;
10
+ private captureButtonTimeout;
11
+ private showCaptureButton;
12
12
  private setVisible;
13
13
  setStart: () => void;
14
14
  setStop: () => void;
@@ -1,8 +1,10 @@
1
1
  export declare class MultiImagesRecorderService {
2
+ private canvas;
2
3
  private mediaRecorder;
3
4
  private recordedBlobs;
4
5
  private multiImagesType;
5
- startRecording(canvas: HTMLCanvasElement): void;
6
+ constructor(canvas: HTMLCanvasElement);
7
+ startRecording(): void;
6
8
  stopRecording(): void;
7
9
  private handleDataAvailable;
8
10
  private handleStop;
@@ -7,7 +7,8 @@ import LoggerController from '../controllers/LoggerController';
7
7
  import Step from '../modules/Step';
8
8
  import { AllLabels } from '../environment/langs';
9
9
  import { StepType } from '../environment/stepsDescription';
10
- import { Base64Image, Offset, Size } from '../helpers/image';
10
+ import { Base64 } from '../helpers/base64';
11
+ import { Offset, Size } from '../helpers/image';
11
12
  import { RealFaceTurnSide } from './enums/realFace';
12
13
  import { StepConfig, StepMode } from '../defaultConfig';
13
14
  import { DeepPartial } from './helpers/DeepPartial';
@@ -45,7 +46,7 @@ export type Context = {
45
46
  steps: Step[];
46
47
  currentStepType: StepType;
47
48
  currentStepCamera: VideoFacingModeEnum;
48
- currentStepImg: Base64Image | null;
49
+ currentStepImg: Base64 | null;
49
50
  currentStepBlob: Blob | null;
50
51
  curStep: number;
51
52
  currentStep: number;
@@ -0,0 +1,4 @@
1
+ export interface MessageAfterDelay {
2
+ delay?: number;
3
+ text?: string;
4
+ }
@@ -1,4 +1,4 @@
1
- import { Base64Image } from './helpers/image';
1
+ import { Base64 } from './helpers/base64';
2
2
  import { IStepCallback } from './modules/Step';
3
3
  import { DocumentTypeIndex, DocumentTypeName } from './environment/documentTypes';
4
4
  import { Context } from './types/context';
@@ -22,5 +22,5 @@ export declare const filterWithForbiddenKeysValues: (obj: any, forbiddenKeys: an
22
22
  export declare const prepareCameraErr: (err: IError) => IError;
23
23
  export declare const formDataForSubmit: (steps: IStepCallback[], c: Context, payload?: {}) => IDataForSubmit;
24
24
  export declare const imageToImageData: (img: HTMLImageElement) => ImageData;
25
- export declare const base64ToImageData: (base64: Base64Image) => Promise<ImageData>;
25
+ export declare const base64ToImageData: (base64: Base64) => Promise<ImageData>;
26
26
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@idscan/idvc2",
3
- "version": "3.8.0",
3
+ "version": "3.9.1",
4
4
  "description": "component for the capturing documents",
5
5
  "main": "dist/idvc.js",
6
6
  "types": "dist/types/idvc.d.ts",