@idscan/onboarding
Version:
Wrapper of the IDVC library for DIVE Online.
224 lines (200 loc) • 6.1 kB
TypeScript
import { default as default_2 } from '@idscan/idvc2';
import { DocumentTypeIndex } from '@idscan/idvc2/dist/types/environment/documentTypes';
import { DocumentTypeName } from '@idscan/idvc2/dist/types/environment/documentTypes';
import { IConfig } from '@idscan/idvc2/dist/types/modules/Config';
import { StepConfig } from '@idscan/idvc2/dist/types/defaultConfig';
declare type AdditionalData = Record<string, string>;
declare type ApplicantDocument = {
abbr3Country: string;
abbrCountry: string;
address: string;
city: string;
class: string;
country: string;
dob: string;
expires: string;
eyes: string;
familyName: string;
firstName: string;
fullName: string;
gender: string;
hair: string;
height: string;
id: string;
idType: string;
issued: string;
middleName: string;
postalBox: string;
state: string;
issuedBy: string;
template: string;
weight: string;
zip: string;
ssn?: string;
};
declare type DocumentType_2 = {
type: DocumentTypeName;
steps: StepConfig[];
};
declare type DocumentValidationTest = {
displayName: string;
name: string;
status: number;
statusString: string;
reason: string;
};
declare type FailedApplicantValidationResult = {
code: string;
message: string;
additionalData: AdditionalData;
propertyErrors: string;
multipleErrors: string[];
traceId: string;
};
declare type IDVCConfigCallbacks = IDVCLibCallbacks & WrapperCallbacks;
declare type IDVCLibCallbacks = {
onChange?: IConfig['onChange'];
onRetakeHook?: IConfig['onRetakeHook'];
onReset?: IConfig['onReset'];
onCameraError?: IConfig['onCameraError'];
onMounted?: IConfig['onMounted'];
onReloaded?: () => void;
submit?: IConfig['submit'];
};
declare type InvalidDataError = {
code: string;
message: string | null;
};
declare interface IWebLibDocument extends DocumentType_2 {
isActive?: boolean;
}
declare interface IWrapperConfig {
applicantId: string;
callbacks?: IDVCConfigCallbacks;
demoMode?: boolean;
domainApi: string;
domainId: string;
publicKey: string;
documentTypes?: IWebLibDocument[];
el?: string;
chunkPublicPath?: string;
isAuth?: boolean;
faceOnly?: boolean;
useCDN?: boolean;
preferApiConfig?: boolean;
networkUrl?: string;
hideDocumentTitle?: boolean;
processingImageFormat?: 'jpeg' | 'png' | 'webp';
wrapperSettings?: Partial<Omit<SuccessConfiguration, 'jsonSettings' | 'cssStyles' | 'cssVariables'>>;
qrCodeLinkOrigin?: string;
getApplicantIdFromURL?: boolean;
IDVCDownloadVersion?: PackageNumberVersion | 'latest';
}
declare type JSON_2 = string;
declare type JSONString = string;
declare type PackageNumberVersion = string;
declare enum ResponseStatus {
SUCCESS = 0,
FAIL = 1,
INVALID_DATA = 2,
ERROR = 3,
COMPLETE = 4
}
declare type SuccessApplicantValidation = {
documentType: DocumentTypeIndex;
document: ApplicantDocument;
attemptsLeft: number;
status: ResponseStatus;
isCompleted: boolean;
validationStatus: ValidationStatus;
invalidDataErrors: InvalidDataError[] | null;
faceSuccess: boolean;
documentSuccess: boolean;
documentHasNotExpired: boolean;
documentValidationTests: DocumentValidationTest[];
callBackUrl: string;
applicantId: string;
attemptId: number;
attemptsCount: number;
notificationType: number;
};
declare type SuccessConfiguration = {
cssStyles: JSON_2;
cssVariables: JSON_2;
jsonSettings: JSON_2;
consentText: string;
checkboxText: string;
showConsentForm: boolean;
verifyFace: boolean;
showQrCode: boolean;
};
declare type ValidateCallbackData = ValidationApplicant & {
forceComplete?: boolean;
};
declare type ValidationApplicant = SuccessApplicantValidation & FailedApplicantValidationResult;
declare type ValidationStatus = {
expired: boolean;
documentIsValid: boolean;
faceIsValid: boolean;
antiSpoofingIsValid: boolean;
};
declare class Wrapper {
private api;
private lib;
private configs;
private readonly IDVCModule;
private validationOutput;
private form;
private validationModal;
private QRCodeModal;
private options;
private embeddedAppConnectionId;
private readonly config;
private readonly fingerPrintData;
private qrCodeBtn;
private wrapperContainerId;
constructor(config: IWrapperConfig, IDVCModule: typeof default_2);
private get isEmbeddedFromQR();
private get QRCodeIsAvailable();
updateConfig(newConfig: JSONString): void;
/**
* reinitialize the library with new applicant id
*/
setApplicant(applicantId: string): Promise<void>;
restart(): Promise<void>;
showLoader(val: boolean, bottomText?: string, topText?: string): void;
private wrapIDVCComponent;
private beforeMount;
private applyWrapperConfigSettings;
private mountQRCodeButton;
private mount;
private unmount;
private checkApplicantIsValid;
private prepareConfig;
private showSpinner;
private submit;
private showValidationSuccess;
private createPostModel;
private start;
private mountQR;
private loadOptions;
private forceClose;
private mountValidationModal;
private mountQRCodeModal;
private processEmbeddedAppStart;
private processEmbeddedAppEnd;
private onError;
}
export default Wrapper;
declare type WrapperCallbacks = {
onValidate?: (data: ValidateCallbackData) => void;
onError?: (data: WrapperError) => void;
onGetOptionsStart?: () => void;
onGetOptionsComplete?: (result: SuccessConfiguration) => void;
};
declare class WrapperError extends Error {
content: string;
header: string;
statusCode?: number;
}
export { }