UNPKG

@microblink/blinkid-react-native

Version:

A small and powerful ID card scanning library. Powered by Microblink (www.microblink.com).

1,975 lines (1,719 loc) 105 kB
"use strict"; import { BlinkIdUtilities } from "./blinkIdUtilities.js"; /** * ClassFilter represents the document filter used to determine which documents will be processed. * Document information (Country, Region, Type) is evaluated with the content set in the filter, and their inclusion or exclusion depends on the defined rules. * To set the document information, use {@link DocumentFilter}. * The recognition results of the excluded documents will not be returned. * If using the standard BlinkID UX, an alert will be displayed that the document will not be scanned. * * By default, the ClassFilter is turned off, and all documents will be included. */ export class ClassFilter { /** * Document classes that will be explicitly accepted by this filter. * Only documents belonging to the specified classes will be processed. All other documents will be rejected. * * If this list is empty, no restrictions are applied, and documents will be accepted unless explicitly excluded by `excludeDocuments`. * * Example usage: * * ``` * final classFilter = ClassFilter(); * classFilter.includeDocuments = [ * DocumentFilter.country(Country.Usa), * DocumentFilter.countryType(Country.Croatia, DocumentType.Id), * ]; * * * ``` * * * NOTE: from the example above, the class filter is set to only accept all documents from USA, and Croatian IDs. * All other documents will be rejected. * * Rules can be combined, for example, to set all three properties (Country Region, Type), two (e.g., Country and Type) or just one (e.g, Region). * * See {@link DocumentFilter} for setting the combinations. */ /** * Document classes that will be explicitly rejected by this filter. * Documents belonging to the specified classes will not be processed. Other documents, not included with `excludeDocuments` will be accepted. * * If this array is empty, no restrictions are applied, and documents will be excluded only if not present in `includeDocuments`. * * Example usage: * * ``` * final classFilter = ClassFilter(); * classFilter.excludeDocuments = [ * DocumentFilter.country(Country.Usa), * DocumentFilter.countryType(Country.Croatia, DocumentType.Id), * ]; * * * ``` * * NOTE: from the example above, the class filter is set to only exclude all documents from USA, and Croatian IDs. * All other classes will be accepted. * * Rules can be combined, for example, to set all three properties (Country Region, Type), two (e.g., Country and Type) or just one (e.g, Region). * * See {@link DocumentFilter} for setting the combinations. */ /** * * @param includeDocuments - specifies which document classes that will be explicitly accepted by this filter. * @param excludeDocuments - specifies which document classes that will be explicitly rejected by this filter. */ constructor(includeDocuments, excludeDocuments) { this.includeDocuments = includeDocuments; this.excludeDocuments = excludeDocuments; } } /** * Represents the document filter. * * Used with other classes like the {@link ClassFilter}, {@link DocumentRules} and the {@link DocumentAnonymizationSettings}. */ export class DocumentFilter { /** * If set, only specified country will pass the filter criteria. * Otherwise, issuing country will not betaken into account. */ /** * If set, only specified country will pass the filter criteria. * Otherwise, issuing region will not be taken into account. */ /** * If set, only specified type will pass the filter criteria. * Otherwise, issuing type will not be taken into account. */ /** * * @param country - specifies the {@link Country} that will pass the filter criteria. * * @param region - specifies the {@link Region} that will pass the filter criteria. * * @param documentType - specifies the {@link DocumentType} that will pass the filter criteria. * * * All parameters are optional, and do not need to be added. * The filter can be set to be more generic (for example, to only accept document from USA): * ``` * DocumentFilter(Country.Usa); * ``` * or, it can be set to be more specific (for example, to specifically accept USA drivers licenses from California): * ``` * DocumentFilter(Country.Usa, Region.California, DocumentType.Dl); * ``` */ constructor(country, region, documentType) { this.country = country; this.region = region; this.documentType = documentType; } } /** * Represents the custom document rules. * * This setting allows users to narrow down our internal rules on mandatory fields. All undefined fields will become optional. * It is not possible to mark fields as mandatory if they cannot theoretically appear on the document. * The more detailed document filter will have priority over the other. * * Document fields are validated using internal rules that define mandatory fields for the scanned document class. */ export class DocumentRules { /** * Specified fields will overrule our document class field rules if filter conditions are met. * * See {@link DocumentFilter} for more information. */ /** * Fields to overrule our class field rules. * * See {@link DetailedFieldType} for more information. */ /** * Represents the custom document rules. * * This setting allows users to narrow down our internal rules on mandatory fields. All undefined fields will become optional. * It is not possible to mark fields as mandatory if they cannot theoretically appear on the document. * The more detailed document filter will have priority over the other. * * Document fields are validated using internal rules that define mandatory fields for the scanned document class. * Defines custom rules for specific document class. * * When defining {@link DocumentRules}, the {@link DocumentFilter} paramter is optionally set to specify the document to which the rule applies, and a `fields` with * the appropriate `alphabetType` should be specified as mandatory for that document. * If a `fields` is set to a field that is optional for that document or does not exist on it, all fields on the document become optional. * If a `fields` is set to a field with an incorrect alphabetType, all fields on the document become optional. * If a `fields` is set to a field that doesn’t exist in the internal rules, that rule is ignored. * When adding multiple `fields`, any field that does not match our rules is ignored. Only fields that comply with our rules are set as mandatory. * If the documentFilter fields `country`, `region`, or `type` are set to `null`, all supported values for those fields will be considered. * For example, if `country = null`, the rule will apply to all supported countries in BlinkID. * * @param fields - specifies the list of {@link DetailedFieldType} for overruling our class field rules. * This parameter is mandatory. * @param documentFilter - specifies the {@link DocumentFilter} to specify the document to which the rule applies. * This parameter is optional. */ constructor(fields, documentFilter) { this.fields = fields; this.documentFilter = documentFilter; } } /** * Represents the detailed field type. * */ export class DetailedFieldType { /** * The field type. * * See {@link FieldType} for more information. */ /** * The alphabet type. * * See {@link AlphabetType} for more information. */ /** * * @param fieldType - specifies the {@link FieldType}. * @param alphabetType - specifies the {@link AlphabetType}. * * Both parameters are mandatory. */ constructor(fieldType, alphabetType) { this.fieldType = fieldType; this.alphabetType = alphabetType; } } /** * Represents the document anonymization settings. * */ export class DocumentAnonymizationSettings { /** * Document fields that will be anonymized. * */ /** * Specified fields will be anonymized if filter conditions are met. * */ /** * Document number anonymization settings. * */ /** * * @param fields - specifies the document fields that will be anonymized. This parameter is mandatory. * * @param documentFilter - specifies the document filter. * * If the conditions of the filter are met, fields of those documents will be anonymized. * This parameter is mandatory. * @param documentNumberAnonymizationSettings - specifies the document number anonymization settings. * * If this parameter is set, it will anonymize the document number, even if the document number is not set in the `fields` parameter. * If the default constructor for {@link DocumentNumberAnonymizationSettings} is used, all of the digits within the document number will be anonymized. * * This parameter is optional. */ constructor(fields, documentFilter, documentNumberAnonymizationSettings) { this.fields = fields; this.documentFilter = documentFilter; this.documentNumberAnonymizationSettings = documentNumberAnonymizationSettings; } } /** * Represents the document number anonymization settings. * * Both settings, `prefixDigitsVisible` and `suffixDigitsVisible`, can be modified and set. * * By default, `prefixDigitsVisible` and `suffixDigitsVisible` are set to 0. * This results that no digits within the document number will be visible. * * If any parameter is `undefined`, the value of the parameter will be set to `0`. */ export class DocumentNumberAnonymizationSettings { /** * Defines how many digits at the beginning of the document number remain visible after anonymization. * */ /** * Defines how many digits at the end of the document number remain visible after anonymization. * */ constructor(prefixDigitsVisible = 0, suffixDigitsVisible = 0) { this.prefixDigitsVisible = prefixDigitsVisible; this.suffixDigitsVisible = suffixDigitsVisible; } } /** * Represents the configuration used to enable/disable recognition of specific * document groups. * * By default all modes are enabled. */ export class RecognitionModeFilter { /** * Enable scanning of MRZ IDs. * */ /** * Enable scanning of visa MRZ. * */ /** * Enable scanning of Passport MRZ. * */ /** * Enable scanning of Photo ID. * */ /** * Enable scanning of barcode IDs. * */ /** * Enable full document recognition. * */ constructor() { this.enableMrzId = true; this.enableMrzVisa = true; this.enableMrzPassport = true; this.enablePhotoId = true; this.enableBarcodeId = true; this.enableFullDocumentRecognition = true; } } /** * Represents the document class information. * */ export class DocumentClassInfo { /** * The document country. * * See {@link Country} for more information. */ /** * The document region. * * See {@link Region} for more information. */ /** * The type of the scanned document. * * See {@link DocumentType} for more information. */ /** * Flag that indicates if the document class information is empty * */ /** * The name of the country that issued the scanned document. * */ /** * The ISO numeric code of the country that issued the scanned document. * */ /** * The 2 letter ISO code of the country that issued the scanned document. * */ /** * The 3 letter ISO code of the country that issued the scanned document. * */ /** * * @param nativeDocumentClassInfo * */ constructor(nativeDocumentClassInfo) { this.country = nativeDocumentClassInfo.country; this.region = nativeDocumentClassInfo.region; this.documentType = nativeDocumentClassInfo.documentType; this.empty = nativeDocumentClassInfo.empty; this.countryName = nativeDocumentClassInfo.countryName; this.isoNumericCountryCode = nativeDocumentClassInfo.isoNumericCountryCode; this.isoAlpha2CountryCode = nativeDocumentClassInfo.isoAlpha2CountryCode; this.isoAlpha3CountryCode = nativeDocumentClassInfo.isoAlpha3CountryCode; } } /** * Represents the result of the data match. * */ export class DataMatchResult { /** * The state of the data match on the whole document. * * See {@link DataMatchState} for more information. */ /** * The data match state of each field. * * See {@link DataMatchResultField} for more information. */ /** * * @param nativeDataMatchResult */ constructor(nativeDataMatchResult) { this.overallState = nativeDataMatchResult.overallState != undefined ? nativeDataMatchResult.overallState : undefined; this.states = nativeDataMatchResult.states; } } /** * Represents the state of the field in the data match. * */ export class DataMatchResultField { /** * The type of the field. * * See {@link DataMatchField} for more information. */ /** * The state of the field. * * See {@link DataMatchState} for more information. */ /** * * @param nativeDataMatchResultField * */ constructor(nativeDataMatchResultField) { this.field = nativeDataMatchResultField.field; this.state = nativeDataMatchResultField.state; } } /** * Represents the multi-alphabet string result extracted from the OCR. * * The result contains the extracted strings, their locations, and the sides of the extracted strings. * */ export class StringResult { /** * All strings separated by new line * */ /** * String for field in latin alphabet * */ /** * String for field in arabic alphabet * */ /** * String for field in cyrillic alphabet * */ /** * String for field in greek alphabet * */ /** * Document field location. * * See {@link Location} for more information. */ /** * The document side where the field is located. * * See {@link Side} for more information. */ /** * * @param nativeStringResult * */ constructor(nativeStringResult) { this.value = nativeStringResult.value; this.latin = nativeStringResult.latin; this.cyrillic = nativeStringResult.cyrillic; this.arabic = nativeStringResult.arabic; this.greek = nativeStringResult.greek; this.location = nativeStringResult.location != undefined ? new Location(nativeStringResult.location) : undefined; this.side = nativeStringResult.side != undefined ? new Side(nativeStringResult.side) : undefined; } } /** * Represents the rectangle location of each document field * */ export class Rectangle { /** * X location * */ /** * Y location * */ /** * Rectangle width * */ /** * Rectangle height. * */ /** * * @param nativeRectangle * */ constructor(nativeRectangle) { this.x = nativeRectangle.x; this.y = nativeRectangle.y; this.width = nativeRectangle.width; this.height = nativeRectangle.height; } } /** * Represents the information about the location of an element within a document or image. * */ export class Location { /** * Rectangle location of the result extracted from the OCR in the latin alphabet. * */ /** * Rectangle location of the result extracted from the OCR in the arabic alphabet. * */ /** * Rectangle location of the result extracted from the OCR in the cyrillic alphabet. * */ /** * Rectangle location of the result extracted from the OCR in the greek alphabet. * */ /** * * @param nativeLocation * */ constructor(nativeLocation) { this.latin = nativeLocation.latin != undefined ? new Rectangle(nativeLocation.latin) : undefined; this.arabic = nativeLocation.arabic != undefined ? new Rectangle(nativeLocation.arabic) : undefined; this.cyrillic = nativeLocation.cyrillic != undefined ? new Rectangle(nativeLocation.cyrillic) : undefined; this.greek = nativeLocation.greek != undefined ? new Rectangle(nativeLocation.greek) : undefined; } } /** * Side of the document on which the specific result is located. * */ export class Side { /** * Document side of the result extracted from the OCR in the latin alphabet. * */ /** * Document side of the result extracted from the OCR in the arabic alphabet. * */ /** * Document side of the result extracted from the OCR in the cyrillic alphabet. * */ /** * Document side of the result extracted from the OCR in the cyrillic alphabet. * */ /** * * @param nativeSide * */ constructor(nativeSide) { this.latin = nativeSide.latin; this.arabic = nativeSide.arabic; this.cyrillic = nativeSide.cyrillic; this.greek = nativeSide.greek; } } /** * Represents the result of the date extraction. * * Contains the extracted date, along with additional date information. */ export class DateResult { /** * The extracted date information. * * See {@link Date} for more information. */ /** * Original string representation of the date which has been extracted. * * Depending of the information source, it can either be of type {@link StringResult} or `string`. */ /** * Indicates that date does not appear on the document * but is filled by our internal domain knowledge. */ /** * Indicates whether date was successfully parsed. * */ constructor(nativeDateResult) { this.date = nativeDateResult.date; this.originalString = BlinkIdUtilities.handleStringType(nativeDateResult.originalString); this.isFilledByDomainKnowledge = nativeDateResult.isFilledByDomainKnowledge; this.successfullyParsed = nativeDateResult.successfullyParsed; } } /** * Represents the extracted date. * */ export class Date { /** * Day of the month. * * The first day of the month has value 1. */ /** * Month of the year. * * The first month of the year has value 1. */ /** * Full year. * */ /** * * @param nativeDate */ constructor(nativeDate) { this.day = nativeDate.day; this.month = nativeDate.month; this.year = nativeDate.year; } } /** * Represents detailed extracted information about the driver license. * */ export class DriverLicenseDetailedInfo { /** * The restrictions to driving privileges for the United States driver license owner. * * Depending of the information source, it can either be of type {@link StringResult} or `String`. */ /** * The additional privileges granted to the US driver license owner. * * Depending of the information source, it can either be of type {@link StringResult} or `String`. */ /** * The type of vehicle the driver license owner has privilege to drive. * * Depending of the information source, it can either be of type {@link StringResult} or `String`. */ /** * The driver license conditions. * * Depending of the information source, it can either be of type {@link StringResult} or `String`. */ /** * The additional information on vehicle class. * * See {@link VehicleClassInfo} for more information. */ constructor(nativeDriverLicenseDetailedInfo) { this.restrictions = BlinkIdUtilities.handleStringType(nativeDriverLicenseDetailedInfo.restrictions); this.endorsements = BlinkIdUtilities.handleStringType(nativeDriverLicenseDetailedInfo.endorsements); this.vehicleClass = BlinkIdUtilities.handleStringType(nativeDriverLicenseDetailedInfo.vehicleClass); this.vehicleClassesInfo = nativeDriverLicenseDetailedInfo.vehicleClassesInfo; } } /** * Represents the information about the vehicle class extraction. * */ export class VehicleClassInfo { /** * The type of driver licence. * * Depending of the information source, it can either be of type {@link StringResult} or `string`. */ /** * The type of vehicle the driver license owner has privilege to drive. * * Depending of the information source, it can either be of type {@link StringResult} or `String`. */ /** * The date since licence is effective. * * See {@link DateResult} for more information. */ /** * The date of expiry of licence. * * See {@link DateResult} for more information. */ constructor(nativeVehicleClassInfo) { this.licenceType = BlinkIdUtilities.handleStringType(nativeVehicleClassInfo.licenceType); this.vehicleClass = BlinkIdUtilities.handleStringType(nativeVehicleClassInfo.vehicleClass); this.effectiveDate = nativeVehicleClassInfo.effectiveDate; this.expiryDate = nativeVehicleClassInfo.expiryDate; } } /** * Information about the dependent. * */ export class DependentInfo { /** * The date of birth of the dependent. * */ /** * The sex or gender of the dependent. * */ /** * The document number of the dependent. * */ /** * The full name of the dependent. * */ /** * Checks if the dependent's information is empty. * */ constructor(nativeDependentInfo) { this.dateOfBirth = nativeDependentInfo.dateOfBirth; this.sex = nativeDependentInfo.sex; this.documentNumber = nativeDependentInfo.documentNumber; this.fullName = nativeDependentInfo.fullName; this.empty = nativeDependentInfo.empty; } } /** * Represents the result of the image crop transformation with additional details. * */ export class DetailedCroppedImageResult { /** * The cropped image in the Base64 format * */ /** * The document side that was cropped. * */ /** * The location of the cropped image in the transformed image of the document. * */ /** * * @param nativeDetailedCroppedImageResult * */ constructor(nativeDetailedCroppedImageResult) { this.image = nativeDetailedCroppedImageResult.image; this.side = nativeDetailedCroppedImageResult.side != undefined ? nativeDetailedCroppedImageResult.side : undefined; this.location = nativeDetailedCroppedImageResult.location != undefined ? new Rectangle(nativeDetailedCroppedImageResult.location) : undefined; } } /** * Represents the result of scanning a single side of the document. * * Contains the data extracted from the Visual Inspection Zone, Machine Readable Zone, * barcode, the input image, and the cropped document, face, and signature images. */ export class SingleSideScanningResult { /** * The data extracted from the Visual Inspection Zone. * */ /** * The data extracted from the Machine Readable Zone. * */ /** * The data extracted from the barcode. * */ /** * The input image in the Base64 format. * */ /** * The input image containing parsable barcode in the Base64 format. * */ /** * The cropped document image in the Base64 format. * */ /** * The cropped face image with additional info. * */ /** * The cropped signature image with additional info. * */ /** * * @param nativeSingleSideScanningResult - specifies the single side scanning result obtained from the native SDK. * */ constructor(nativeSingleSideScanningResult) { this.viz = nativeSingleSideScanningResult.viz; this.mrz = nativeSingleSideScanningResult.mrz; this.barcode = nativeSingleSideScanningResult.barcode; this.inputImage = nativeSingleSideScanningResult.inputImage; this.barcodeInputImage = nativeSingleSideScanningResult.barcodeInputImage; this.documentImage = nativeSingleSideScanningResult.documentImage; this.faceImage = nativeSingleSideScanningResult.faceImage; this.signatureImage = nativeSingleSideScanningResult.signatureImage; } } /** * Represents the result of the Visual Inspection Zone of a document. * */ export class VizResult { /** * The first name of the document owner. * */ /** * The last name of the document owner. * */ /** * The full name of the document owner. * */ /** * The additional name information of the document owner. * */ /** * The localized name of the document owner. * */ /** * The fathers name of the document owner. * */ /** * The mothers name of the document owner. * */ /** * The address of the document owner. * */ /** * The additional address information of the document owner. * */ /** * The one more additional address information of the document owner. * */ /** * The place of birth of the document owner. * */ /** * The nationality of the document owner. * */ /** * The race of the document owner. * */ /** * The religion of the document owner. * */ /** * The profession of the document owner. * */ /** * The marital status of the document owner. * */ /** * The residential status of the document owner. * */ /** * The employer of the document owner. * */ /** * The sex of the document owner. * */ /** * The sponsor of the document owner. * */ /** * The blood type of the document owner. * */ /** * The date of birth of the document owner. * */ /** * The date of issue of the document. * */ /** * The date of expiry of the document. * */ /** * The date of entry of the document owner. * */ /** * The locality code of the document owner. * */ /** * The maiden name of the document owner. * */ /** * The municipality code of the document owner. * */ /** * The municipality of registration of the document owner. * */ /** * The polling station code of the document owner. * */ /** * The registration center code of the document owner. * */ /** * The section code of the document owner. * */ /** * The state code of the document owner. * */ /** * The state of the document owner. * */ /** * Determines if date of expiry is permanent. * */ /** * The document number. * */ /** * The personal identification number. * */ /** * The additional number of the document. * */ /** * The one more additional number of the document. * */ /** * The additional personal identification number. * */ /** * The issuing authority of the document. * */ /** * The visa type of the document. * */ /** * The driver license detailed info. * */ /** * The transcription of the document subtype. * */ /** * The remarks on the residence permit. * */ /** * The residence permit type. */ /** * The manufacturing year. * */ /** * The vehicle type. * */ /** * The eligibility category. * */ /** * The specific document validity. * */ /** * The dependents info. * */ /** * The vehicle owner. * */ /** * The country code of the document owner. * */ /** * The certificate number of the document owner. * */ /** * The national insurance number of the document owner. * */ /** * * @param nativeVizResult * */ constructor(nativeVizResult) { this.firstName = nativeVizResult.firstName; this.lastName = nativeVizResult.lastName; this.fullName = nativeVizResult.fullName; this.additionalNameInformation = nativeVizResult.additionalNameInformation; this.localizedName = nativeVizResult.localizedName; this.fathersName = nativeVizResult.fathersName; this.mothersName = nativeVizResult.mothersName; this.address = nativeVizResult.address; this.additionalAddressInformation = nativeVizResult.additionalAddressInformation; this.additionalOptionalAddressInformation = nativeVizResult.additionalOptionalAddressInformation; this.placeOfBirth = nativeVizResult.placeOfBirth; this.nationality = nativeVizResult.nationality; this.race = nativeVizResult.race; this.religion = nativeVizResult.religion; this.profession = nativeVizResult.profession; this.maritalStatus = nativeVizResult.maritalStatus; this.residentialStatus = nativeVizResult.residentialStatus; this.employer = nativeVizResult.employer; this.sex = nativeVizResult.sex; this.sponsor = nativeVizResult.sponsor; this.bloodType = nativeVizResult.bloodType; this.dateOfBirth = nativeVizResult.dateOfBirth; this.dateOfIssue = nativeVizResult.dateOfIssue; this.dateOfExpiry = nativeVizResult.dateOfExpiry; this.dateOfEntry = nativeVizResult.dateOfEntry; this.localityCode = nativeVizResult.localityCode; this.maidenName = nativeVizResult.maidenName; this.municipalityCode = nativeVizResult.municipalityCode; this.municipalityOfRegistration = nativeVizResult.municipalityOfRegistration; this.pollingStationCode = nativeVizResult.pollingStationCode; this.registrationCenterCode = nativeVizResult.registrationCenterCode; this.sectionCode = nativeVizResult.sectionCode; this.stateCode = nativeVizResult.stateCode; this.stateName = nativeVizResult.stateName; this.dateOfExpiryPermanent = nativeVizResult.dateOfExpiryPermanent; this.documentNumber = nativeVizResult.documentNumber; this.personalIdNumber = nativeVizResult.personalIdNumber; this.documentAdditionalNumber = nativeVizResult.documentAdditionalNumber; this.documentOptionalAdditionalNumber = nativeVizResult.documentOptionalAdditionalNumber; this.additionalPersonalIdNumber = nativeVizResult.additionalPersonalIdNumber; this.issuingAuthority = nativeVizResult.issuingAuthority; this.visaType = nativeVizResult.visaType; this.driverLicenseDetailedInfo = nativeVizResult.driverLicenseDetailedInfo; this.documentSubtype = nativeVizResult.documentSubtype; this.remarks = nativeVizResult.remarks; this.residencePermitType = nativeVizResult.residencePermitType; this.manufacturingYear = nativeVizResult.manufacturingYear; this.vehicleType = nativeVizResult.vehicleType; this.eligibilityCategory = nativeVizResult.eligibilityCategory; this.specificDocumentValidity = nativeVizResult.specificDocumentValidity; this.dependentsInfo = nativeVizResult.dependentsInfo; this.vehicleOwner = nativeVizResult.vehicleOwner; this.countryCode = nativeVizResult.countryCode; this.certificateNumber = nativeVizResult.certificateNumber; this.nationalInsuranceNumber = nativeVizResult.nationalInsuranceNumber; } } /** * Represents the result of the MRZ recognition. * */ export class MrzResult { /** * The entire Machine Readable Zone text from ID. * */ /** * The document code. Document code contains two characters. * For MRTD the first character shall be A, C or I. * * The second character shall be discretion of the issuing State or organization except * that V shall not be used, and `C` shall not be used after `A` except in the crew member certificate. * * On machine-readable passports (MRP) first character shall be `P` to designate an MRP. One additional * letter may be used, at the discretion of the issuing State or organization, to designate a particular * MRP. * * If the second character position is not used for this purpose, it shall be filled by the filter character. */ /** * Three-letter or two-letter code which indicate the issuing State. Three-letter codes are based * on Aplha-3 codes for entities specified in ISO 3166-1, with extensions for certain States. * * Two-letter codes are based on Aplha-2 codes for entities specified in ISO 3166-1, with extensions for certain States. */ /** * The document number. * */ /** * The first optional data. Empty string if not available. * */ /** * The second optional data. Empty string if not available. * */ /** * The gender of the document holder. * * Gender is specified by use of the single initial. */ /** * The nationality of the document holder represented by a three-letter or two-letter code. * * Three-letter codes are based on Alpha-3 codes for entities specified in ISO 3166-1, with extensions for certain States. * * Two-letter codes are based on Aplha-2 codes for entities specified in ISO 3166-1, with extensions for certain States. */ /** * The primary indentifier. * * If there is more than one component, they are separated with space. */ /** * The secondary identifier. * * If there is more than one component, they are separated with space. */ /** * The full issuer name that is expanded from the three-letter or two-letter code which indicate * the issuing State. * */ /** * The full nationality of the document holder, which is expanded from the three-letter or two-letter * nationality code. */ /** * Whether the MRZ is verified. * * If the MRZ is verified, it means that all check digits are correct. */ /** * The date of birth of the document holder. * */ /** * The date of expiry of the document. * */ /** * The type of the document. * */ /** * The sanitized first optional data. * * Result without additional '<' characters if they exist. */ /** * The sanitized second optional data. * * Result without additional '<' characters if they exist. */ /** * The sanitized nationality. * * Result without additional '<' characters if they exist. */ /** * The sanitized issuer. * * Result without additional '<' characters if they exist. */ /** * The sanitized document code. * * Result without additional '<' characters if they exist. */ /** * The sanitized document number. * * Result without additional '<' characters if they exist. */ /** * * @param nativeMrzResult * */ constructor(nativeMrzResult) { this.rawMRZString = nativeMrzResult.rawMRZString; this.documentCode = nativeMrzResult.documentCode; this.issuer = nativeMrzResult.issuer; this.documentNumber = nativeMrzResult.documentNumber; this.opt1 = nativeMrzResult.opt1; this.opt2 = nativeMrzResult.opt2; this.gender = nativeMrzResult.gender; this.nationality = nativeMrzResult.nationality; this.primaryID = nativeMrzResult.primaryID; this.secondaryID = nativeMrzResult.secondaryID; this.issuerName = nativeMrzResult.issuerName; this.nationalityName = nativeMrzResult.nationalityName; this.verified = nativeMrzResult.verified; this.dateOfBirth = nativeMrzResult.dateOfBirth; this.dateOfExpiry = nativeMrzResult.dateOfExpiry; this.documentType = nativeMrzResult.documentType; this.sanitizedOpt1 = nativeMrzResult.sanitizedOpt1; this.sanitizedOpt2 = nativeMrzResult.sanitizedOpt2; this.sanitizedNationality = nativeMrzResult.sanitizedNationality; this.sanitizedIssuer = nativeMrzResult.sanitizedIssuer; this.sanitizedDocumentCode = nativeMrzResult.sanitizedDocumentCode; this.sanitizedDocumentNumber = nativeMrzResult.sanitizedDocumentNumber; } } /** * Represents the data extracted from the barcode. * */ export class BarcodeResult { /** * The raw, unparsed barcode data. * */ /** * The first name of the document owner. * */ /** * The middle name of the document owner. * */ /** * The last name of the document owner. * */ /** * The full name of the document owner. * */ /** * The additional name information of the document owner. * */ /** * The address of the document owner. * */ /** * The place of birth of the document owner. * */ /** * The nationality of the document owner. * */ /** * The race of the document owner. * */ /** * The religion of the document owner. * */ /** * The profession of the document owner. * */ /** * The marital status of the document owner. * */ /** * The residential status of the document owner. * */ /** * The employer of the document owner. * */ /** * The sex of the document owner. * */ /** * The date of birth of the document owner. * */ /** * The date of issue of the document. * */ /** * The date of expiry of the document. * */ /** * The document number. * */ /** * The personal identification number. * */ /** * The additional number of the document. * */ /** * The issuing authority of the document. * */ /** * The details about the address of the document owner. * */ /** * The driver license detailed info. * */ /** * Document specific extended elements that contain all barcode fields in their original form. * * Currently this is only filled for AAMVACompliant documents. */ /** * Indicates whether the barcode was successfully parsed. */ /** * * @param nativeBarcodeResult */ constructor(nativeBarcodeResult) { this.barcodeData = nativeBarcodeResult.barcodeData; this.firstName = nativeBarcodeResult.firstName; this.middleName = nativeBarcodeResult.middleName; this.lastName = nativeBarcodeResult.lastName; this.fullName = nativeBarcodeResult.fullName; this.additionalNameInformation = nativeBarcodeResult.additionalNameInformation; this.address = nativeBarcodeResult.address; this.placeOfBirth = nativeBarcodeResult.placeOfBirth; this.nationality = nativeBarcodeResult.nationality; this.race = nativeBarcodeResult.race; this.religion = nativeBarcodeResult.religion; this.profession = nativeBarcodeResult.profession; this.maritalStatus = nativeBarcodeResult.maritalStatus; this.residentialStatus = nativeBarcodeResult.residentialStatus; this.employer = nativeBarcodeResult.employer; this.sex = nativeBarcodeResult.sex; this.dateOfBirth = nativeBarcodeResult.dateOfBirth; this.dateOfIssue = nativeBarcodeResult.dateOfIssue; this.dateOfExpiry = nativeBarcodeResult.dateOfExpiry; this.documentNumber = nativeBarcodeResult.documentNumber; this.personalIdNumber = nativeBarcodeResult.personalIdNumber; this.documentAdditionalNumber = nativeBarcodeResult.documentAdditionalNumber; this.issuingAuthority = nativeBarcodeResult.issuingAuthority; this.addressDetailedInfo = nativeBarcodeResult.addressDetailedInfo; this.driverLicenseDetailedInfo = nativeBarcodeResult.driverLicenseDetailedInfo; this.extendedElements = nativeBarcodeResult.extendedElements; this.parsed = nativeBarcodeResult.parsed; } } /** * Represents the raw, unparsed data extracted from a scanned barcode. * */ export class BarcodeData { /** * Type of the scanned barcode. * */ /** * Raw bytes of the barcode content. * */ /** * String representation of the barcode content. * */ /** * Whether the barcode data is uncertain, i.e. if scanned barcode was incomplete or has parts of it missing. * */ /** * * @param nativeBarcodeData - specifies the barcode data obtained from the native SDK. */ constructor(nativeBarcodeData) { this.barcodeType = nativeBarcodeData.barcodeType; this.rawData = nativeBarcodeData.rawData; this.stringData = nativeBarcodeData.stringData; this.uncertain = nativeBarcodeData.uncertain; } } /** * Detailed information about the address. * */ export class AddressDetailedInfo { /** * he address street portion of the document owner. * */ /** * The address postal code portion of the document owner. * */ /** * The address city portion of the document owner. * */ /** * The address jurisdiction code portion of the document owner. * */ /** * * @param nativeAddressDetailedInfo - specificies the address detailed info obtained from the native SDK. * */ constructor(nativeAddressDetailedInfo) { this.street = nativeAddressDetailedInfo.street; this.postalCode = nativeAddressDetailedInfo.postalCode; this.city = nativeAddressDetailedInfo.city; this.jurisdiction = nativeAddressDetailedInfo.jurisdiction; } } /** * Represents the fields present in the barcode. * Currently this is only used for AAMVACompliant documents. */ export class BarcodeExtendedElements { /** * Mandatory on all AAMVA and Magnetic barcodes. * On compact barcodes, use kFullAddress. * * City portion of the cardholder address. */ /** * Mandatory on all AAMVA and Magnetic barcodes. * On compact barcodes, use kFullAddress. * * State portion of the cardholder address. */ /** * Mandatory on all AAMVA and Magnetic barcodes. * On compact barcodes, use kFullAddress. * * Postal code portion of the cardholder address in the U.S. and Canada. * If the trailing portion of the postal code in the U.S. is not known, zeros can be used * to fill the trailing set of numbers up to nine (9) digits. */ /** * Mandatory on all AAMVA and Magnetic barcodes. * On compact barcodes, use kFullAddress. * * Street portion of the cardholder address. * The place where the registered driver of a vehicle (individual or corporation) * may be contacted such as a house number, street address, etc. */ /** * Optional on all AAMVA barcodes. * On Compact barcodes, use kFullAddress. * * Second line of street portion of the cardholder address. */ /** * Optional on AAMVA 01. (MMDDCCYY format) * * ALTERNATIVE DATES(S) given as date of birth. */ /** * Optional on all AAMVA and Compact barcodes. * Other family name by which the cardholder is known. */ /** * Optional on all AAMVA and Compact barcodes. * * Other name by which the cardholder is known. ALTERNATIVE NAME(S) of the individual * holding the Driver License or ID. * * The Name field contains up to four portions, separated with the "," delimiter: * AKA Last Name (required) * , (required) * AKA First Name (required) * , (required if other name portions follow, otherwise optional) * AKA Middle Name(s) (optional) * , (required if other name portions follow, otherwise optional) * AKA Suffix (optional) * , (optional) * * If the individual has more than one AKA middle name they are separated with space. */ /** * Optional on all AAMVA and Compact barcodes. * * Other given name by which the cardholder is known */ /** * Optional on AAMVA 01 barcodes. * * ALTERNATIVE MIDDLE NAME(s) or INITIALS of the individual holding the Driver License or ID. * Hyphenated names acceptable, spaces between names acceptable, but no other * use of special symbols. */ /** * Optional on AAMVA 01 barcodes. * * ALTERNATIVE PREFIX to Driver Name. Freeform as defined by issuing jurisdiction. */ /** * Optional on AAMVA version 01. * * Driver "AKA" Social Security Number. FORMAT SAME AS DRIVER SOC SEC NUM. ALTERNATIVE NUMBERS(S) used as SS NUM. */ /** * Optional on all AAMVA and Compact barcodes. * * Other suffix by which the cardholder is known. * The Suffix Code Portion, if submitted, can contain only the Suffix Codes * shown in the following table (e.g., Andrew Johnson, III = JOHNSON@ANDREW@@3RD): * * Suffix Meaning or Synonym * JR Junior * SR Senior or Esquire 1ST First * 2ND Second * 3RD Third * 4TH Fourth * 5TH Fifth * 6TH Sixth * 7TH Seventh * 8TH Eighth * 9TH Ninth */ /** * Optional on AAMVA 02, 03, 04, 05, 06, 07, 08 and Compact barcodes. * * A string of letters and/or numbers that identifies when, where, and by whom a driver's * license/ID card was made. If audit information is not used on the card or the MRT, it * must be included in the driver record. */ /** * Optional on AAMVA 04, 05, 06, 07, 08 and Compact barcodes. * * DHS required field that indicates date of the most recent version change or * modification to the visible format of the DL/ID. (MMDDCCYY format) */ /** * Optional on AAMVA 04, 05, 06, 07, 08 and Compact barcodes. * * DHS required field that indicates compliance: "M" = materially compliant, * "F" = fully compliant, and, "N" = non-compliant. */ /** * Mandatory on AAMVA 02, 03, 04, 05, 06, 07, 08 and Compact barcodes. * * Country in which DL/ID is issued. U.S. = USA, Canada = CAN. */ /** * Mandatory on all AAMVA, Magnetic and Compact barcodes. * * Family name of the cardholder. (Family name is sometimes also called "last name" or "surname.") * Collect full name for record, print as many characters as possible on portrait side of DL/ID. */ /** * Mandatory on all AAMVA and Compact barcodes. * * The number assigned or calculated by the issuing authority. */ /** * Mandatory on all AAMVA, Magnetic and Compact barcodes. * * First name of the cardholder. */ /** * Mandatory on all AAMVA, Magnetic and Compact barcodes. * * Full name of the individual holding the Driver's License or ID. * * The Name field contains up to four portions, separated with the "," delimiter: * Last Name (required) * , (required) * First Name (required) * , (required if other name portions follow, otherwise optional) * Middle Name(s) (optional) * , (required if other name portions follow, otherwise optional) * Suffix (optional) * , (optional) * * If the individual has more than one middle name they are separated with space. */ /** * Mandatory on AAMVA 04, 05, 06, 07, 08 barcodes. * Optional on AAMVA 01, 02, 03, Magnetic and Compcat barcodes. * * Middle name(s) of the cardholder. In the case of multiple middle names they * shall be separated by space " ". */ /** * Optional on compact barcodes. * * Document discriminator. */ /** * Mandatory on all AAMVA, Magnetic and Compact barcodes. * * Date on which the cardholder was born. (MMDDCCYY format) */ /** * Mandatory on AAMVA 02, 03, 04, 05, 06, 07, 08 and Magnetic barcodes. * Optional on Compact barcodes. * * Number must uniquely identify a particular document issued to that customer * from others that may have been issued in the past. This number may serve * multiple purposes of document discrimination, audit info, and/or inventory control. */ /** * Mandatory on all AAMVA, Magnetic and Compact barcodes. * * Date on which the document expires. (MMDDCCYY format) * If the document is non expiring then "Non expiring" is written in this field. */ /** * Optional on Magnetic barcodes. * * Month on which the driving and identification privileges granted by the document are no longer valid. */ /** * Mandatory on all AAMVA and Compact barcodes. * * Date on which the document was issued. (MMDDCCYY format) */ /** * Optional on Magnetic barcodes. * * Field that indicates that the driving and identification privileges granted by the * document are nonexpiring = "1". */ /** * Mandatory on all driver's licenses. * All barcodes which are using 3-track magnetic stripe encoding used in the interest of smoothing a transition from legacy documents * shall be designated as "Magnetic". All barcodes which are using compact encoding * compliant with ISO/IEC 18013-2 shall be designated as "Compact". All barcodes (majority) * compliant with Mandatory PDF417 Bar Code of the American Association of Motor Vehicle * Administrators (AAMVA) Card Design Standard from AAMVA DL/ID-2000 standard to DL/ID-2013 * shall be designated as "AAMVA". */ /** * Mandatory on AAMVA 02, 03, 04, 05, 06, 07, 08 barcodes. * Optional on AAMVA 01, Magnetic and Compact barcodes. * * Color of cardholder's eyes. (ANSI D-20 codes) * Code Description * BLK Black * BLU Blue * BRO Brown * GRY Gray * GRN Green * HAZ Hazel * MAR Maroon * PNK Pink * DIC Dichromatic * UNK Unknown */ /** * Mandatory on AAMVA 04, 05, 06, 07, 08 barcodes. * Optional on Compact barcodes. * A code that indicates whether a field has been truncated (T), has not been * truncated (N), or – unknown whether truncated (U). */ /** * Mandatory on AAMVA versions 02 and 03. * * Federally established codes for vehicle categories, endorsements, and restrictions * that are generally applicable to commercial motor vehicles. If the vehicle is not a * commercial vehicle, "NONE" is to be entered. */ /** * Mandatory on AAMVA 04, 05, 06, 07, 08 barcodes. * Optional on Compact barcodes. * * A code that indicates whether a field has been truncated (T), has not been * truncated (N), or – unknown whether truncated (U). */ /** * Mandatory on all AAMVA and Magnetic barcodes. * Optional on Compact barcodes. * * Full address of the individual holding the Driver's License or ID. * * The full address field contains up to four portions, separated with the "," delimiter: * Street Address (required) * , (required if other address portions follow, otherwise optional) * City (optional) * , (required if other address portions follow, otherwise optional) * Jurisdiction Code (optional) * , (required if other address portions follow, otherwise optional) * ZIP - Postal Code (optional) */ /** * Optional on all AAMVA, Magnetic and Compact barcodes. * * Bald, black, blonde, brown, gray, red/auburn, sandy, white, unknown. If the issuing * j