UNPKG

@privateid/ultra-web-sdk-alpha

Version:
189 lines (188 loc) 6.74 kB
import { callbackTypeEnum } from './createCallback'; import { CameraFaceMode } from './types'; interface CameraOpenResult { stream: MediaStream | null; devices: MediaDeviceInfo[] | null; faceMode: CameraFaceMode | null; settings: MediaTrackSettings | null; status: boolean; errorMessage?: string | null; capabilities: MediaTrackCapabilities | null; } interface openCameraProps { videoElementId: string; deviceId?: string; requestFaceMode?: CameraFaceMode; canvasResolution?: { width: number; height: number; }; isDocumentScan?: boolean; } export declare const openCamera: ({ videoElementId, deviceId, requestFaceMode, canvasResolution, isDocumentScan, }: openCameraProps) => Promise<CameraOpenResult>; /** * This function close camera, and clear all memories related to the camera. * @category Face * @param domElement id of the video tag */ export declare const closeCamera: (element: string) => Promise<void>; interface openCameraProps { videoElementId: string; deviceId?: string; requestFaceMode?: CameraFaceMode; canvasResolution?: { width: number; height: number; }; isDocumentScan?: boolean; } /** * This function switch camera from front to back on mobile, and to another device on desktop * @category Face * @param selectedCamera Selected camera either front or back * @param device Selected camera ID * @param canvasResolution */ export declare const switchCamera: (selectedCamera: CameraFaceMode | null, device: string, canvasResolution?: { width: number; height: number; } | null) => Promise<{ capabilities: MediaTrackCapabilities | null; settings: MediaTrackSettings | null; } | null>; interface enrollProps { callback: (result: any) => void; config?: any; element?: string; returnPortrait?: boolean; } export declare const getBaseConfigEnroll: () => { input_image_format: string; angle_rotation_left_threshold: number; angle_rotation_right_threshold: number; threshold_high_vertical_enroll: number; threshold_down_vertical_enroll: number; anti_spoofing_threshold: number; threshold_profile_enroll: number; blur_threshold_enroll_pred: number; threshold_user_too_close: number; threshold_user_too_far: number; allow_only_one_face: boolean; threshold_user_up: number; threshold_user_down: number; threshold_user_left: number; threshold_user_right: number; }; export declare function enroll({ callback, config, element, returnPortrait }: enrollProps): Promise<ImageData | { result: number; imageData: Uint8ClampedArray; height: number; width: number; } | { result: string; }>; interface BaseProps { callback: (result: any) => void; config?: any; element?: string; returnPortrait?: boolean; } interface FaceLoginProps extends BaseProps { } interface PredictProps extends BaseProps { image?: ImageData; } /** * This function performs faceLogin, the camera should already be open. the functions performs the identification and return the result. This function is more restrictive than predict1Fa. * @category Face * @param callback Callbacks triggered on the `predict` operation * @param config Configuration recommeded default: { input_image_format: "rgba" } * @param element Element id of video tag. (Optional) By default it uses the element id used when opening the camera using openCamera() */ interface FaceLoginProps { callback: (result: any) => void; config?: any; element?: string; returnPortrait?: boolean; } export declare const estimateAge: (options: Parameters<typeof runUltraProcess>[1]) => Promise<any>; type PredictFunction = (images: ImageData[], isSimd: boolean, config: string, resultProxy: any) => Promise<any>; declare const runUltraProcess: (fn: PredictFunction, options: { callback: (result: any) => void; config?: any; element?: string; image?: ImageData; returnPortrait?: boolean; useExistingCanvas?: boolean; logMessage?: string; callbackType?: callbackTypeEnum; }) => Promise<any>; /** * Face login function */ export declare const faceLogin: (props: FaceLoginProps) => Promise<any>; /** * This function performs predict, the camera should already be open. the functions performs the identification return the result then restart again. * @category Face * @param callback Callbacks triggered on the predict operation * @param config Configuration recommeded default: { input_image_format: "rgba" } * @param element Element id of video tag. (Optional) By default it uses the element id used when opening the camera using openCamera() * @param image ImageData, If there is an image passed, it will be predicting the image instead of the video feed. */ export declare const predictVerify: (props: PredictProps) => Promise<any>; export declare const predict: (props: PredictProps) => Promise<any>; export declare const predictWithStatus: (props: PredictProps) => Promise<any>; export declare const predictConfirmUser: (props: PredictProps) => Promise<any>; export declare const predictDeleteUser: (props: PredictProps) => Promise<any>; export declare const pkiEncryptData: (payload: any) => Promise<{ encryptedKey: string; iv: string; gcmAad: string; gcmTag: string; encrptedMessage: string; }>; export declare const checkIfModelsAreLoaded: (isEnroll: boolean) => Promise<number>; interface frontScanInterface { callback: (returnData: any) => void; config?: any; doOcr?: boolean; } export declare const scanFrontDocument: ({ callback, config }: frontScanInterface) => Promise<{ result: string; } | { result: number; }>; export declare const scanPassport: ({ callback, config }: frontScanInterface) => Promise<{ result: string; } | { result: number; }>; interface backScanInterface { callback: (returnData: any) => void; image?: ImageData; config?: any; } export declare const scanBackDocument: ({ callback, image, config }: backScanInterface) => Promise<{ result: string; } | { [x: string]: any; result?: undefined; } | { result: number; }>; export declare const compareEmbeddings: (embeddingsA: string, embeddingsB: string, config: {}, callback: (result: any) => void, encryptData?: boolean) => Promise<{ result: number; imageData: Uint8ClampedArray; height: number; width: number; }>; interface documentOcrInterface { inputImage: string; callback: (returnData: any) => void; config?: any; } export declare const documentOcr: ({ inputImage, callback, config }: documentOcrInterface) => Promise<{ result: number; }>; export declare const freeFrontScanMemory: () => Promise<boolean>; export {};