@vouched.id/vouched-js
Version:
Vouched Javascript SDK
453 lines (426 loc) • 11.3 kB
TypeScript
/// <reference types="user-agent-data-types" />
export declare enum Step {
preDetected = 'preDetected',
detected = 'detected',
postable = 'postable'
}
export declare enum Instruction {
noCard = 'noCard',
onlyOne = 'onlyOne',
moveCloser = 'moveCloser',
moveAway = 'moveAway',
glare = 'glare',
dark = 'dark',
blur = 'blur',
holdSteady = 'holdSteady',
noFace = 'noFace',
openMouth = 'openMouth',
closeMouth = 'closeMouth',
lookForward = 'lookForward',
lookLeft = 'lookLeft',
lookRight = 'lookRight',
none = 'none',
flipCard = 'flipCard'
}
export enum Type {
idv = 'id-verification',
reverify = 'id-reverification'
}
export interface FaceDetectResult {
boudingBox?: {
topLeft: number[];
bottomRight: number[];
};
step: Step;
instruction: Instruction;
image?: string;
}
export interface FaceDetect {
detect(
video: HTMLVideoElement | ImageData,
dimensions?: {
width: number;
height: number;
}
): Promise<FaceDetectResult>;
reset(): void;
restart(): Promise<{
destroyCount: number;
successful: boolean;
}>;
}
export declare class FaceDetectFactory {
static get(
livenessMode?: LivenessMode,
holdSteadyInterval?: number,
enableUxFeedback?: boolean,
enableEyeCheck?: boolean | null
): Promise<FaceDetect>;
}
export interface CardDetectResult {
card?: DetectedCard;
step: Step;
instruction: Instruction;
image?: string;
cardImageData?: ImageData;
distanceImage?: string;
}
export interface DetectedCard {
score: number;
box: CardBox;
}
export interface CardBox {
x: number;
y: number;
width: number;
height: number;
vx: number;
vy: number;
vwidth: number;
vheight: number;
}
export interface CardDetect {
detect(video: HTMLVideoElement): Promise<CardDetectResult>;
reset(): void;
destroy(): void;
}
export declare class CardDetectFactory {
static get(holdSteadyInterval?: number, idLiveness?: string | null): Promise<CardDetect>;
}
export declare enum LivenessMode {
mouthMovement = 0,
straight = 1,
orientation = 2,
distance = 3,
none = 4
}
export declare class Confidence {
faceMatch: number;
idMatch: number;
idQuality: number;
nameMatch: number;
selfie: number;
idGlareQuality: number;
selfieSunglasses: number | null;
selfieEyeglasses: number | null;
id: number;
idFraud: number;
constructor(
faceMatch: number,
idMatch: number,
idQuality: number,
nameMatch: number,
selfie: number,
idGlareQuality: number,
selfieSunglasses: number,
selfieEyeglasses: number,
id: number,
idFraud: number
);
}
export declare class IPFraudType {
ipFraud?: boolean | null;
count?: number | null;
jobIdList?: [string] | null;
}
export declare class JobResult {
success: boolean;
successWithSuggestion?: boolean;
hasPDF417Back?: boolean | null;
hasPDF417Front?: boolean | null;
captureBackId?: boolean | null;
type?: string;
id?: string;
firstName?: string;
lastName?: string;
issueDate?: string;
expireDate?: string;
country?: string;
state?: string;
confidences?: Confidence;
ipFraudCheck?: IPFraudType;
birthDate?: string;
middleName?: string;
geoLocation?: { latitude: number; longitude: number; error: string };
consent?: { timestamp: string; consent: boolean; method: string };
constructor(
success: boolean,
successWithSuggestion: boolean,
hasPDF417Back: boolean | null,
hasPDF417Front: boolean | null,
captureBackId: boolean | null,
type: string,
id: string,
firstName: string,
lastName: string,
issueDate: string,
expireDate: string,
country: string,
state: string,
confidences: Confidence,
ipFraudCheck: IPFraudType,
birthDate?: string,
middleName?: string,
geoLocation?: { latitude: number; longitude: number; error: string },
consent?: { timestamp: string; consent: boolean; method: string }
);
}
export declare class Insights {
category: string | null;
message: string | null;
type: string | null;
fields: string[] | [];
property: string | null;
}
export declare class JobError {
type: string;
message: string;
constructor(type: string, message: string);
}
export declare class Job {
result: JobResult;
errors: JobError[];
signals: Insights[];
id: string;
token: string;
status: string;
constructor(result: JobResult, errors: JobError[], signals: Insights[], id: string, token: string, status: string);
}
export class PhotoInfo {
width?: number;
height?: number;
exif?: string;
created?: string;
type?: string;
modified?: string;
size?: number;
name?: string;
constructor(
width?: number,
height?: number,
exif?: string,
created?: string,
type?: string,
modified?: string,
size?: number,
name?: string
);
}
export class Property {
name: string;
value: string;
constructor(name: string, value: string);
}
export type ThemeName = 'verbose' | 'classic' | 'avant' | 'tesla';
export declare class ClientData {
theme?: ThemeName | null;
client?: 'JS Plugin';
capture?: 'manual' | 'automatic';
includeBarcode?: boolean;
}
export declare class Params {
firstName?: string;
lastName?: string;
email?: string;
phone?: string;
birthDate?: string;
idPhoto?: string;
idDistancePhoto?: string;
idPhotoInfo?: PhotoInfo;
backIdPhoto?: string;
backIdPhotoInfo?: PhotoInfo;
userPhotoInfo?: PhotoInfo;
userPhoto?: string;
userDistancePhoto?: string;
required?: {
idPhoto: boolean;
userPhoto: boolean;
};
enableIPAddress?: boolean;
enablePhysicalAddress?: boolean;
enableDarkWeb?: boolean;
enableCrossCheck?: boolean;
enableDriversLicenseValidation?: boolean;
enableAAMVA?: boolean;
barcodeText?: string;
userConfirmation?: UserConfirmation;
clientData?: ClientData;
geoLocation?: { latitude: number; longitude: number; error: string };
consent?: { timestamp: string; consent: boolean; method: string };
constructor(
firstName?: string,
lastName?: string,
email?: string,
phone?: string,
birthDate?: string,
idPhoto?: string,
idDistancePhoto?: string,
idPhotoInfo?: PhotoInfo,
backIdPhoto?: string,
backIdPhotoInfo?: PhotoInfo,
userPhotoInfo?: PhotoInfo,
userPhoto?: string,
userDistancePhoto?: string,
required?: {
idPhoto: boolean;
userPhoto: boolean;
},
enableIPAddress?: boolean,
enablePhysicalAddress?: boolean,
enableDarkWeb?: boolean,
enableCrossCheck?: boolean,
enableDriversLicenseValidation?: boolean,
enableAAMVA?: boolean,
barcodeText?: string,
userConfirmation?: UserConfirmation,
clientData?: ClientData,
geoLocation?: { latitude: number; longitude: number; error: string },
consent?: { timestamp: string; consent: boolean; method: string }
);
}
export interface AuthenticateResult {
match: number;
}
export declare class VouchedSessionError implements Error {
name: string;
message: string;
constructor(message: string, name?: string);
}
export interface VouchedSessionParameters {
apiKey: string;
apiUrl?: string;
token?: string;
groupId?: string;
debug?: boolean;
jobConfigId?: string;
callbackURL?: string;
properties?: Property[];
handoff?: boolean;
configuration?: string;
type?: Type;
}
export interface VouchedClearSessionParameters {
token?: boolean;
groupId?: boolean;
jobConfigId?: boolean;
callbackURL?: boolean;
properties?: boolean;
}
export declare class VouchedSession {
private apiKey;
private apiUrl?;
private token;
private groupId?;
private jobConfigId?;
private callbackURL?;
private properties?;
private handoff?;
private configuration?;
constructor({
apiKey,
apiUrl,
groupId,
token,
jobConfigId,
callbackURL,
properties,
handoff,
configuration,
type
}: VouchedSessionParameters);
initJob(paramaters?: Params): Promise<Job>;
postSMS(paramaters?: Params): Promise<any>;
postId(frontIdImage: string, backIdImage: string, paramaters?: Params, extras?: any): Promise<Job>;
postFrontId(detectedCard: CardDetectResult, paramaters?: Params): Promise<Job>;
postBackId(detectedCard: CardDetectResult, paramaters?: Params, extras?: any): Promise<Job>;
postFace(detectedFace: FaceDetectResult, parameters?: Params): Promise<Job>;
postAuthenticate(detectedFace: FaceDetectResult, jobId: string, photoType: string, _jobSid: string): Promise<Job>;
confirm(paramaters?: Params): Promise<Job>;
getJobByToken(token: string, useTokenForSubsequent?: boolean): Promise<Job>;
postSurvey({ surveyPoll, message }: { surveyPoll: number; message: string }): Promise<Job>;
postInvite({
firstName,
internalId,
lastName,
email,
contact,
phone
}: {
firstName: string;
lastName: string;
internalId: string;
email: string;
contact: string;
phone: string;
}): Promise<void>;
postExtractConfirmation(confirmed: boolean): Promise<Job>;
clearValues({ groupId, token, jobConfigId, callbackURL, properties }: VouchedClearSessionParameters): void;
private defaultSessionRequest;
}
export interface CardTrack {
detect(
video: HTMLVideoElement | ImageData,
mediaStream: MediaStreamTrack,
orientation?: boolean
): Promise<CardDetectResult>;
detectForBarcodeScanning(
video: HTMLVideoElement | ImageData,
_unused: unknown,
orientation?: boolean
): Promise<CardDetectResult>;
reset(): void;
destroy(): void;
}
export declare class CardTrackFactory {
static get(
holdSteadyInterval?: number,
enableUxFeedback?: boolean,
idLiveness?: string | null,
isMobile: boolean
): Promise<CardTrack>;
}
export declare enum RetryableCardError {
InvalidIdPhotoError = 'InvalidIdPhotoError',
BlurryIdPhotoError = 'BlurryIdPhotoError',
GlareIdPhotoError = 'GlareIdPhotoError'
}
export declare enum RetryableFaceError {
InvalidUserPhotoError = 'InvalidUserPhotoError'
}
export interface RetryableOptions {
recognizeIDThreshold?: number;
generalThreshold?: number;
glareQualityThreshold?: number;
qualityThreshold?: number;
}
export declare class VouchedUtils {
private constructor();
static extractRetryableCardErrors: (job: Job, options?: RetryableOptions) => RetryableCardError[];
static extractSignals: (job: Job, signal: Insights[]) => string[];
static missingFields: (job: Job, signal: Insights[]) => boolean;
static extractRetryableFaceErrors: (job: Job, options?: RetryableOptions) => RetryableFaceError[];
}
export declare class DeviceDetect {
private constructor(userAgent?: string);
/**
* @param {string} userAgent default value is navigator.userAgent
* @returns {DeviceDetect}
*/
static get(userAgent?: string): DeviceDetect;
readonly userAgent: string;
readonly deviceType: string;
readonly deviceModel: string;
readonly osVersion: string;
readonly osName: string;
readonly deviceVendor: string;
get isMobile(): boolean;
get isOnlyMobile(): boolean;
get isTablet(): boolean;
get isIOS(): boolean;
get isAndroid(): boolean;
get isSafari(): boolean;
get isChrome(): boolean;
get isFirefox(): boolean;
get isIPad13(): boolean;
}
export declare const deviceDetect: DeviceDetect;