react-native-mdl-verification
v1.0.25
Published
React Native bridge for MDL (Mobile Driver's License) verification using CheckMDL SDK
Downloads
819
Maintainers
Readme
react-native-mdl-verification
React Native bridge for MDL (Mobile Driver's License) verification using CheckMDL SDK.
Installation
npm install react-native-mdl-verification
# or
yarn add react-native-mdl-verificationAndroid Setup
The package includes the required AAR files for the CheckMDL SDK. No additional manual linking is needed for React Native 0.60+.
Required Permissions
Add the following permissions to your android/app/src/main/AndroidManifest.xml:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-feature android:name="android.hardware.bluetooth_le" android:required="true" />Usage
Initialize the SDK
import MdlVerification from 'react-native-mdl-verification';
// Initialize with your license key
await MdlVerification.initialize('YOUR_LICENSE_KEY');Start Verification
try {
const result = await MdlVerification.startVerification({
command: 'VERIFY',
stan: '000001',
terminalId: 'TERMINAL_001',
merchantId: 'MERCHANT_001',
minAge: '18',
timeout: '60',
demoMode: false,
onlyVerified: true
});
if (result.isSuccessful) {
console.log('Verification successful!');
console.log('MDL Token:', result.mdlToken);
console.log('Document Type:', result.docType);
console.log('Document Valid:', result.docValid);
} else {
console.log('Verification failed:', result.successMesg);
}
} catch (error) {
console.error('Verification error:', error);
}Listen to Verification Events
// Listen for progress updates
const progressListener = MdlVerification.addListener(
MdlVerification.Events.VERIFICATION_PROGRESS,
(progress) => {
console.log('Progress:', progress.status);
console.log('Log:', progress.logData);
}
);
// Listen for completion
const completeListener = MdlVerification.addListener(
MdlVerification.Events.VERIFICATION_COMPLETE,
(result) => {
console.log('Verification complete:', result);
}
);
// Clean up listeners when done
progressListener.remove();
completeListener.remove();
// Or remove all listeners for an event
MdlVerification.removeAllListeners(MdlVerification.Events.VERIFICATION_PROGRESS);API
Methods
initialize(licenseKey: string): Promise<void>
Initialize the MDL verification SDK with your license key.
startVerification(options: VerificationOptions): Promise<VerificationResponse>
Start the MDL verification process.
Options:
command(string, optional): Command type for verificationstan(string, optional): Station numberterminalId(string, optional): Terminal IDmerchantId(string, optional): Merchant IDtestHostResponse(string, optional): Test host response for testing purposesminAge(string, required): Minimum age requirement (default: '18')mdlToken(string, optional): MDL token for re-verificationtimeout(string, required): Timeout in seconds (default: '60')demoMode(boolean, optional): Enable demo modeonlyVerified(boolean, optional): Only accept verified documents
Returns: VerificationResponse object
addListener(eventName: string, listener: Function): Subscription
Add an event listener for verification events.
Events:
MdlVerification.Events.VERIFICATION_PROGRESS- Progress updates during verificationMdlVerification.Events.VERIFICATION_COMPLETE- Verification completed
Types
VerificationOptions
interface VerificationOptions {
command?: string; // Command type for verification
stan?: string; // Station number
terminalId?: string; // Terminal ID
merchantId?: string; // Merchant ID
testHostResponse?: string; // Test host response for testing
minAge: string; // Minimum age requirement (e.g., '18', '21')
mdlToken?: string; // MDL token for re-verification
timeout: string; // Timeout in seconds (e.g., '60')
demoMode?: boolean; // Enable demo mode
onlyVerified?: boolean; // Only accept verified documents
}VerificationResponse
interface VerificationResponse {
command?: string;
stan?: string;
terminalId?: string;
merchantId?: string;
success?: string; // 'Y' for success, 'N' for failure
successMesg?: string; // Success or error message
status?: number; // Status code
mdlToken?: string; // Token for the verified MDL
docType?: string; // Document type (e.g., 'mDL')
docValid?: string; // Document validity status
authMethod?: string; // Authentication method used
authSuccess?: string; // Authentication success status
msoValid?: string; // MSO (Mobile Security Object) validity
cert?: string; // Certificate data
ica_cert?: string; // Intermediate CA certificate
isSuccessful?: boolean; // Convenience boolean (true if success === 'Y')
applicationId?: string; // Application ID (returned on license errors)
licenseKey?: string; // License key (returned on license errors)
}ProgressResponse
interface ProgressResponse {
command?: string;
status?: string;
logData?: string;
logLevel?: string;
}License
MIT
Support
For issues and questions, please visit the GitHub repository.
