@scandit/web-datacapture-id
Version:
Scandit Data Capture SDK for the Web
395 lines (394 loc) • 13.9 kB
TypeScript
import type { Prettify, QuadrilateralJSON } from "@scandit/web-datacapture-core";
import type { DataConsistencyCheck } from "./DataConsistencyCheck";
/**
*
* A CapturedId has many steps through which it does to reach its final shape.
* Here is a break-down of the used types accross the different steps:
*
* ------------
* | Centaurus |
* ------------
* |
* | VIZResultJSON: The VIZ data coming from Centaurus.
* |
* | VIZResultExtendedJSON: The VIZ data coming from Centaurus, but augmented with extra information like the location
* |
* | CapturedIdFromCentaurusJSON: A captured id containing the data extracted by Centaurus, as well as the location information.
* V
* ------------
* | SDC |
* ------------
* |
* | CapturedIdBeforeAnonymizationJSON: final shape, but the data does not use anonymized field data yet and it has no image information
* |
* | CapturedIdWithRawImageInfoJSON: final shape, but the image format still needs to be processed in the main thread
* V
* ---------------
* | Main Thread |
* ---------------
* |
* | CapturedIdJSON: The public, final shape
* |
* V
*
* CapturedId
*/
export type CapturedIdDataField<T> = T;
export interface DateResultJSON {
day: number | null;
month: number | null;
year: number;
}
export interface ProfessionalDrivingPermitJSON {
dateOfExpiry: DateResultJSON;
codes: string[];
}
export interface VehicleRestrictionJSON {
vehicleCode: string;
vehicleRestriction: string;
dateOfIssue: DateResultJSON;
}
export interface DrivingLicenseCategoryJSON {
code: string;
dateOfIssue: DateResultJSON | null;
dateOfExpiry: DateResultJSON | null;
}
export interface DrivingLicenseDetailsJSON {
drivingLicenseCategories: DrivingLicenseCategoryJSON[];
restrictions: string | null;
endorsements: string | null;
}
export interface ImageInfoJSON {
front: {
face: string | null;
croppedDocument: string | null;
frame: string | null;
};
back: {
face: string | null;
croppedDocument: string | null;
frame: string | null;
};
}
export type CapturedIdJSON = Prettify<{
firstName: CapturedIdDataField<string | null>;
lastName: CapturedIdDataField<string | null>;
fullName: CapturedIdDataField<string | null>;
sex: CapturedIdDataField<string | null>;
nationality: CapturedIdDataField<string | null>;
address: CapturedIdDataField<string | null>;
issuingCountry: CapturedIdDataField<string | null>;
issuingCountryIso: CapturedIdDataField<string | null>;
documentNumber: CapturedIdDataField<string | null>;
documentAdditionalNumber: CapturedIdDataField<string | null>;
dateOfBirth: CapturedIdDataField<DateResultJSON | null>;
dateOfExpiry: CapturedIdDataField<DateResultJSON | null>;
dateOfIssue: CapturedIdDataField<DateResultJSON | null>;
documentType: CapturedIdDataField<string | null>;
documentSubtype: CapturedIdDataField<string | null>;
imageInfo: ImageInfoJSON | null;
barcodeResult: BarcodeResultJSON | null;
mrzResult: MRZResultJSON | null;
vizResult: VIZResultJSON | null;
mobileDocumentOcrResult: MobileDocumentOCRResultJSON | null;
verificationResult: VerificationResultJSON | null;
idVerificationDataComparisonAvailable: boolean;
usRealIdStatus: string | null;
isExpired: CapturedIdDataField<boolean | null>;
age: CapturedIdDataField<number | null>;
isCitizenPassport: boolean;
isCapturingComplete: boolean;
anonymizedFields: string[];
}>;
interface FrameInfo {
data: Uint8ClampedArray | null;
width: number;
height: number;
mirrorAxis: number;
orientation: number;
}
export interface RawImageInfo {
front: {
face: string | null;
croppedDocument: {
image: string | null;
obscuredRegions: QuadrilateralJSON[];
};
frame: {
image: FrameInfo;
obscuredRegions: QuadrilateralJSON[];
};
};
back: {
face: null;
croppedDocument: {
image: string | null;
obscuredRegions: QuadrilateralJSON[];
};
frame: {
image: FrameInfo;
obscuredRegions: QuadrilateralJSON[];
};
};
}
export type CapturedIdWithRawImageInfoJSON = CapturedIdJSON & {
rawImageInfo: RawImageInfo;
};
export type CapturedIdCommonFieldsJSON = Pick<CapturedIdJSON, "address" | "age" | "dateOfBirth" | "dateOfExpiry" | "dateOfIssue" | "documentAdditionalNumber" | "documentNumber" | "documentType" | "documentSubtype" | "firstName" | "fullName" | "isExpired" | "issuingCountry" | "issuingCountryIso" | "lastName" | "nationality" | "sex">;
type VizResultFieldsCalculatedBySDC = "age" | "isExpired";
export type VIZResultExtendedJSON = Prettify<Omit<VIZResultJSON, VizResultFieldsCalculatedBySDC> & {
location: QuadrilateralJSON | null;
frontFieldLocations: Partial<Record<string, QuadrilateralJSON>>;
backFieldLocations: Partial<Record<string, QuadrilateralJSON>>;
}>;
export type CapturedIdFromCentaurusJSON = Prettify<Omit<CapturedIdJSON, keyof CapturedIdCommonFieldsJSON | "idVerificationDataComparisonAvailable" | "usRealIdStatus" | "isCapturingComplete" | "isCitizenPassport" | "anonymizedFields"> & {
vizResult: VIZResultExtendedJSON;
}>;
export interface BarcodeResultJSON {
aamvaVersion: number | null;
address: string | null;
aliasFamilyName: string | null;
aliasGivenName: string | null;
aliasSuffixName: string | null;
barcodeMetadata: BarcodeMetadataJSON | null;
bloodType: string | null;
branchOfService: string | null;
cardInstanceIdentifier: string | null;
cardRevisionDate: DateResultJSON | null;
categories: string[] | null;
champusEffectiveDate: DateResultJSON | null;
champusExpiryDate: DateResultJSON | null;
citizenshipStatus: string | null;
civilianHealthCareFlagCode: string | null;
civilianHealthCareFlagDescription: string | null;
commissaryFlagCode: string | null;
commissaryFlagDescription: string | null;
countryOfBirth: string | null;
countryOfBirthIso: string | null;
dateOfBirth: DateResultJSON | null;
dateOfExpiry: DateResultJSON | null;
dateOfIssue: DateResultJSON | null;
deersDependentSuffixCode: number | null;
deersDependentSuffixDescription: string | null;
dictionary: Record<string, string>;
directCareFlagCode: string | null;
directCareFlagDescription: string | null;
documentAdditionalNumber: string | null;
documentCopy: string | null;
documentDiscriminatorNumber: string | null;
documentNumber: string | null;
documentSubtype: string | null;
documentType: string | null;
driverNamePrefix: string | null;
driverNameSuffix: string | null;
driverRestrictionCodes: number[] | null;
ediPersonIdentifier: string | null;
endorsementsCode: string | null;
exchangeFlagCode: string | null;
exchangeFlagDescription: string | null;
eyeColor: string | null;
familySequenceNumber: number | null;
firstName: string | null;
firstNameTruncation: string | null;
firstNameWithoutMiddleName: string | null;
formNumber: string | null;
fullName: string | null;
genevaConventionCategory: string | null;
hairColor: string | null;
heightCm: number | null;
heightInch: number | null;
identificationType: string | null;
iin: string | null;
isRealId: boolean | null;
issuingCountry: string | null;
issuingCountryIso: string | null;
issuingJurisdiction: string | null;
issuingJurisdictionIso: string | null;
jpegData: string | null;
jurisdictionVersion: number | null;
lastName: string | null;
lastNameTruncation: string | null;
licenseCountryOfIssue: string | null;
location: QuadrilateralJSON | null;
middleName: string | null;
middleNameTruncation: string | null;
mwrFlagCode: string | null;
mwrFlagDescription: string | null;
nationality: string | null;
payGrade: string | null;
payPlanCode: string | null;
payPlanGradeCode: string | null;
personDesignatorDocument: number | null;
personDesignatorTypeCode: string | null;
personMiddleInitial: string | null;
personalIdNumber: string | null;
personalIdNumberType: string | null;
personnelCategoryCode: string | null;
personnelEntitlementConditionType: string | null;
placeOfBirth: string | null;
professionalDrivingPermit: ProfessionalDrivingPermitJSON | null;
race: string | null;
rank: string | null;
rawData: string | null;
relationshipCode: string | null;
relationshipDescription: string | null;
restrictionsCode: string | null;
securityCode: string | null;
serviceCode: string | null;
sex: string | null;
sexOriginal: string | null;
sponsorFlag: string | null;
sponsorName: string | null;
sponsorPersonDesignatorIdentifier: number | null;
statusCode: string | null;
statusCodeDescription: string | null;
vehicleClass: string | null;
vehicleRestrictions: VehicleRestrictionJSON[] | null;
version: string | null;
weightKg: number | null;
weightLbs: number | null;
}
export interface MRZResultJSON {
address: string | null;
capturedMrz: string | null;
dateOfBirth: DateResultJSON | null;
dateOfExpiry: DateResultJSON | null;
dateOfIssue: DateResultJSON | null;
documentCode: string;
documentNumber: string | null;
firstName: string | null;
fullName: string | null;
fullNameSimplifiedChinese: string | null;
issuingAuthorityCode: string | null;
lastName: string | null;
namesAreTruncated: boolean;
nationality: string | null;
omittedCharacterCountInGbkName: number | null;
omittedNameCount: number | null;
optionalDataInLine1: string | null;
optionalDataInLine2: string | null;
passportDateOfExpiry: DateResultJSON | null;
passportIssuerIso: string | null;
passportNumber: string | null;
personalIdNumber: string | null;
renewalTimes: number | null;
sex: string | null;
}
export interface VIZResultJSON {
additionalAddressInformation: string | null;
additionalNameInformation: string | null;
address: string | null;
bloodType: string | null;
capturedSides: string;
dateOfBirth: DateResultJSON | null;
dateOfExpiry: DateResultJSON | null;
dateOfIssue: DateResultJSON | null;
documentAdditionalNumber: string | null;
documentNumber: string | null;
documentSubtype: string | null;
documentType: string | null;
drivingLicenseDetails: DrivingLicenseDetailsJSON | null;
employer: string | null;
fathersName: string | null;
firstName: string | null;
fullName: string | null;
isBackSideCaptureSupported: boolean;
issuingAuthority: string | null;
issuingCountry: string | null;
issuingCountryIso: string | null;
issuingJurisdiction: string | null;
issuingJurisdictionIso: string | null;
lastName: string | null;
location: QuadrilateralJSON | null;
maritalStatus: string | null;
mothersName: string | null;
mrzDetected: boolean;
nationality: string | null;
passportNumber: string | null;
personalIdNumber: string | null;
placeOfBirth: string | null;
profession: string | null;
race: string | null;
religion: string | null;
residentialStatus: string | null;
sex: string | null;
sexOriginal: string | null;
sponsor: string | null;
usRealIdStatus: string | null;
vehicleOwner: string | null;
visaNumber: string | null;
}
export interface MobileDocumentOCRResultJSON {
dateOfBirth: DateResultJSON | null;
dateOfExpiry: DateResultJSON | null;
dateOfIssue: DateResultJSON | null;
documentNumber: string | null;
documentAdditionalNumber: string | null;
firstName: string | null;
fullName: string | null;
lastName: string | null;
sex: string | null;
nationality: string | null;
address: string | null;
issuingJurisdiction: string | null;
issuingJurisdictionIso: string | null;
}
export interface IdCaptureErrorJSON {
type: string;
message: string;
}
export interface IdCaptureSessionJSON {
newlyCapturedId: CapturedIdJSON | null;
localizedOnlyId: LocalizedOnlyIdJSON | null;
newlyRejectedId: RejectedIdJSON | null;
frameSequenceId: number;
error: IdCaptureErrorJSON | null;
}
export interface LocalizedOnlyIdJSON {
location: QuadrilateralJSON;
}
export interface RejectedIdJSON {
location: QuadrilateralJSON;
rejectionReason: string;
}
export interface AamvaBarcodeVerificationResultJSON {
allChecksPassed: boolean;
error: string;
serverResponseJSON: string;
isSuccess: boolean;
}
export interface BarcodeMetadataJSON {
errorCorrection: number;
moduleCountX: number;
moduleCountY: number;
}
export interface DataConsistencyResultJSON {
allChecksPassed: boolean;
failedChecks: DataConsistencyCheck[];
skippedChecks: DataConsistencyCheck[];
passedChecks: DataConsistencyCheck[];
frontFieldLocations: Record<string, QuadrilateralJSON> | null;
frontImage: string | null;
}
export interface VerificationResultJSON {
dataConsistencyResult: DataConsistencyResultJSON | null;
}
export interface DurationJSON {
days: number;
months: number;
years: number;
}
export interface CentaurusSettingsJSON {
filter: {
enableBarcodeId: boolean;
enableFullDocumentRecognition: boolean;
enableMrzId: boolean;
enableMrzPassport: boolean;
enableMrzVisa: boolean;
enablePhotoId: boolean;
};
scanUnsupportedBack: boolean;
skipImagesOccludedByHand: boolean;
combineResultsFromMultipleInputImages: boolean;
}
export {};