@daddymaou/idverify
v1.0.1
Published
ID verification library — OCR, MRZ parsing, screenshot detection, and age gate for government IDs
Maintainers
Readme
idverify
ID verification library — OCR, MRZ parsing, screenshot detection, and age gate for government IDs.
Install
npm install @daddymaou/idverifyUsage
import { verifyId, checkAge } from '@daddymaou/idverify';
import { readFileSync } from 'fs';
const buffer = readFileSync('./passport.jpg');
// Full verification
const result = await verifyId(buffer);
console.log(result.status); // "valid" | "expired" | "invalid"
console.log(result.documentType); // "passport" | "drivers_license" | ...
console.log(result.checksum); // "passed" | "failed" | "not_applicable"
console.log(result.screenshotDetected); // false
// Age gate only (no birthdate exposed)
const age = await checkAge(buffer);
console.log(age.over18); // true
console.log(age.over21); // falseAPI
verifyId(buffer: Buffer): Promise<VerificationResult>
Accepts an image buffer (PNG, JPG, WebP). Returns:
| Field | Type | Description |
|---|---|---|
| id | string | Unique scan UUID |
| documentType | string | passport / drivers_license / national_id / unknown |
| issuingCountry | string | ISO country code |
| expiryDate | string \| null | YYYY-MM-DD |
| status | string | valid / expired / invalid |
| checksum | string | passed / failed / not_applicable |
| screenshotDetected | boolean | EXIF-based detection |
| confidence | number | 0–100 |
| over18 | boolean \| null | null if DOB not found |
| over21 | boolean \| null | null if DOB not found |
checkAge(buffer: Buffer): Promise<AgeGateResult>
Returns { over18: boolean, over21: boolean } without exposing the full birthdate.
How it works
- Preprocessing — sharp resizes, grayscales, normalizes, and sharpens the image
- OCR — tesseract.js extracts all text
- MRZ parsing — looks for Machine Readable Zone lines, validates checksums with the
mrzpackage - Fallback extraction — regex-based date and country parsing if no MRZ found
- Screenshot detection — exifr checks for camera EXIF metadata (Make, Model)
- Age gate — calculates age from DOB without returning the raw date
Requirements
- Node.js 18+
- The
sharppackage requires a native build —npm installhandles this automatically
License
MIT
