KYC Validation
Agent-TS includes multi-layer KYC document validation with OCR extraction, OpenAI Vision verification, and fraud detection for Sierra Leone National ID cards.Validation Pipeline
OCR Service
The OCR service uses Tesseract.js to extract text and compute confidence scores.Extracted Fields
For Sierra Leone National ID cards:| Field | Example |
|---|---|
| Personal ID Number (NIN) | NIN: 1234567890 |
| Surname | KAMARA |
| First Name | IBRAHIM |
| Middle Name | MOHAMED |
| Date of Birth | 15/03/1990 |
| Gender | MALE |
| Height | 1.75m |
| Date of Expiry | 15/03/2030 |
Usage
OCR Result Interface
Vision API Validation
The ID Card Validator uses OpenAI’s Vision API for document authenticity checks.Validation Checks
Document Type
Verifies the image is a valid Sierra Leone National ID
Photo Presence
Confirms a clear photo is visible on the document
Official Appearance
Checks for official government styling and elements
Text Readability
Ensures text is legible and not obscured
Usage
Fraud Detection
Fraud Indicators
The system detects multiple fraud patterns:| Indicator | Description |
|---|---|
LOW_OCR_CONFIDENCE | OCR confidence below 60% |
MISSING_OFFICIAL_HEADER | ”REPUBLIC OF SIERRA LEONE” not found |
MISSING_ID_HEADER | ”NATIONAL IDENTITY CARD” not found |
SUSPICIOUS_TEXT_PATTERN | Contains “photoshop”, “edited”, “sample”, etc. |
REPEATING_ID_PATTERN | ID number like “11111111” or “12341234” |
FRONT_BACK_MISMATCH | Name/ID differs between sides |
MISSING_CRITICAL_DATA | Required fields not extracted |
CONFIDENCE_MISMATCH | Large difference between front/back confidence |
Suspicious Text Patterns
Cross-Validation
When both sides are provided, the system performs cross-validation:Complete Validation Flow
Single Image Upload
KYC Upgrade (Both Sides)
Configuration
OCR Settings
Confidence Thresholds
| Threshold | Value | Purpose |
|---|---|---|
| Minimum OCR confidence | 60% | Below this triggers fraud flag |
| Warning OCR confidence | 75% | Below this shows warning |
| Cross-validation mismatch | 20% | Difference between front/back |
Image Requirements
For best results, KYC images should:Image Quality
Image Quality
- Minimum resolution: 800x600 pixels
- Clear, in-focus image
- Good lighting without glare
- No blur or motion artifacts
Document Positioning
Document Positioning
- ID card fills 70-80% of frame
- All edges visible
- No fingers covering text
- Flat surface (no curves)
File Format
File Format
- JPEG or PNG format
- Maximum file size: 10MB
- Base64 encoded with data URI prefix