react-native-scanbot-sdk
Version:
Scanbot Document and Barcode Scanner SDK React Native Plugin for Android and iOS
157 lines (138 loc) • 4.64 kB
JavaScript
/// Auto-generated with ScanbotSDKCodegenV3. Modifications will be overwritten.
/// Generated from core/schemas/MRZTypes.yaml
import { GenericDocument } from '../documents/GenericDocument';
import { AccumulatedResultsVerifierConfiguration } from '../frame_accumulation/FrameAccumulationTypes';
import { ToJsonConfiguration } from '../utils/json/JsonSerializationTypes';
import { PartiallyConstructible } from '../utils/utils';
/**
Type of document containing the MRZ.
- `UNKNOWN`:
Undefined.
- `CREW_MEMBER_CERTIFICATE`:
Crew member certificate.
- `ID_CARD`:
ID card.
- `PASSPORT`:
Passport.
- `VISA`:
Visa card.
- `CH_DRIVING_LICENSE`:
Swiss driver license.
*/
export const MrzDocumentTypeValues = ['UNKNOWN', 'CREW_MEMBER_CERTIFICATE', 'ID_CARD', 'PASSPORT', 'VISA', 'CH_DRIVING_LICENSE'];
/**
Container for result of MRZ scanning attempt.
*/
export class MrzScannerResult extends PartiallyConstructible {
/**
Scanning successful.
Default is false
*/
success = false;
/**
Raw string value of MRZ.
*/
/**
Generic document containing MRZ data.
*/
/** @param source {@displayType `DeepPartial<MrzScannerResult>`} */
constructor(source = {}) {
super();
if (source.success !== undefined) {
this.success = source.success;
}
if (source.rawMRZ !== undefined) {
this.rawMRZ = source.rawMRZ;
} else {
throw new Error('rawMRZ must be present in constructor argument');
}
if (source.document !== undefined) {
this.document = source.document != null ? new GenericDocument(source.document) : null;
} else {
throw new Error('document must be present in constructor argument');
}
}
async serialize(config = new ToJsonConfiguration()) {
return {
success: this.success,
rawMRZ: this.rawMRZ,
document: this.document != null ? await this.document.serialize(config) : null
};
}
_released = false;
release() {
if (this._released) {
return;
}
{
if (this.document != null) {
this.document.release();
}
}
this._released = true;
}
async encodeImages() {
if (this.document != null) {
await this.document.encodeImages();
}
}
}
/**
Defines how to handle incomplete MRZ results (e.g. caused by failed validation).
- `ACCEPT`:
Accept incomplete results. Fields failing validation will have a validation status of INVALID. Typically used for single-shot scanning.
- `REJECT`:
Reject incomplete results. If any fields are missing or fail validation, the result document will be empty. Typically used for live scanning.
*/
export const MrzIncompleteResultHandlingValues = ['ACCEPT', 'REJECT'];
/**
The scanning mode.
- `LIVE`:
The scanner will merge all information from multiple frames to provide the best possible result.
Use this mode when the input is a video or camera stream.
- `SINGLE_SHOT`:
The scanner will only use the current frame and will spend additional time to ensure the
best possible result. Use this mode when scanning single images, e.g. imported from the gallery.
*/
export const MrzScanningModeValues = ['LIVE', 'SINGLE_SHOT'];
/**
Configuration for MRZ scanner.
*/
export class MrzScannerConfiguration extends PartiallyConstructible {
/**
Configure the frame accumulation process.
*/
frameAccumulationConfiguration = new AccumulatedResultsVerifierConfiguration({});
/**
Enable MRZ detection. If disabled, the scanner skips the detection step and assumes that the input image is a crop of the MRZ area.
Default is true
*/
enableDetection = true;
/**
Defines how to handle incomplete MRZ results (e.g. caused by failed validation).
Default is REJECT
*/
incompleteResultHandling = 'REJECT';
/**
If true, crops of the detected MRZ and its fields will be returned in the result.
Default is false
*/
returnCrops = false;
/** @param source {@displayType `DeepPartial<MrzScannerConfiguration>`} */
constructor(source = {}) {
super();
if (source.frameAccumulationConfiguration !== undefined) {
this.frameAccumulationConfiguration = new AccumulatedResultsVerifierConfiguration(source.frameAccumulationConfiguration);
}
if (source.enableDetection !== undefined) {
this.enableDetection = source.enableDetection;
}
if (source.incompleteResultHandling !== undefined) {
this.incompleteResultHandling = source.incompleteResultHandling;
}
if (source.returnCrops !== undefined) {
this.returnCrops = source.returnCrops;
}
}
}
//# sourceMappingURL=MrzTypes.js.map