
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
face-validator-sdk
Advanced tools
Real-time selfie validation SDK with face detection, i18n (pt-BR, en, es). Built on MediaPipe.
Real-time selfie validation SDK with face detection, powered by MediaPipe. Detects faces, hands, and validates pose, lighting, and occlusions in real-time.
For any web application (React, Angular, Vue, vanilla JS, Java backend with JS frontend, etc.) that wants to use the core validator:
npm install face-validator-sdk
The SDK declares
@mediapipe/tasks-vision(^0.10.15) as a regular dependency, so it is installed automatically when you installface-validator-sdk.
import { FaceValidator, ValidationStatus } from 'face-validator-sdk';
const validator = new FaceValidator({
container: '#selfieContainer',
ui: 'default',
locale: 'pt-BR',
debugMode: false,
mirror: true,
onStatusUpdate: (status, message) => {
console.log(status, message);
},
onCaptureSuccess: (blob) => {
const url = URL.createObjectURL(blob);
document.querySelector('img')!.src = url;
},
onError: (errorType, error) => {
console.error(errorType, error);
}
});
// The validator starts automatically.
// To stop and release resources: validator.destroy();
| Status | Description |
|---|---|
INITIALIZING | Loading MediaPipe models |
NO_FACE_DETECTED | No face found in frame |
FACE_DETECTED | Face detected, validating... |
TOO_CLOSE | Face too close to camera |
TOO_FAR | Face too far from camera |
OFF_CENTER | Face not centered in oval |
FACE_OBSTRUCTED | Hand covering face or low visibility |
HEAD_NOT_STRAIGHT | Head tilted or turned |
MULTIPLE_FACES | More than one face detected |
POOR_ILLUMINATION | Insufficient lighting |
STAY_STILL | Hold still for capture |
CAPTURING | Taking photo... |
SUCCESS | Capture successful! |
ERROR | An error occurred |
interface FaceValidatorOptions {
// UI structure
container?: HTMLElement | string; // Element or selector to auto-render video/canvas and status
ui?: 'default' | 'none'; // Default: 'default'
autoStart?: boolean; // Default: true
mirror?: boolean; // Default: true
// Camera
videoElement?: HTMLVideoElement; // Use if you want to control the video manually
overlayCanvasElement?: HTMLCanvasElement | null;
videoConstraints?: MediaTrackConstraints;
videoWidth?: number;
videoHeight?: number;
// Idioma e debug
locale?: 'pt-BR' | 'en' | 'es';
debugMode?: boolean;
customMessages?: Partial<Record<ValidationStatus, string>>;
// Callbacks
onStatusUpdate?: (status: ValidationStatus, message: string) => void;
onCaptureSuccess?: (imageBlob: Blob) => void;
onError?: (errorType: ValidationStatus, error: Error) => void;
// Thresholds de validacao
minDetectionConfidence?: number;
minIlluminationThreshold?: number;
minFaceSizeFactor?: number;
maxFaceSizeFactor?: number;
stabilizationTimeThreshold?: number;
stabilityMovementThreshold?: number;
minFaceVisibilityScore?: number;
maxHeadTiltDegrees?: number;
maxHandFaceDistance?: number;
// Advanced
modelPath?: string; // Path to MediaPipe WASM (auto-detected via CDN)
}
import { ReactSelfieCapture } from 'face-validator-sdk';
export function SelfieModal() {
const handleCapture = (imageBase64: string | null) => {
if (!imageBase64) return;
// Send the selfie to your API
};
return (
<ReactSelfieCapture
locale="pt-BR"
onCapture={handleCapture}
onDismiss={() => console.log('Modal closed')}
debugMode={false}
labels={{
previewQuestion: 'Check your selfie before saving',
savePhoto: 'Confirm selfie'
}}
/>
);
}
locale: defines the language for messages and labels displayed.onCapture: main callback; receives the base64 image or null if the user cancels.onDismiss: used to close the modal/dialog when the user clicks cancel.debugMode: enables landmark visualization for debugging.labels: overrides default texts (e.g., preview title and button label).import { AfterViewInit, Component, OnDestroy } from '@angular/core';
import { FaceValidator, ValidationStatus } from 'face-validator-sdk';
@Component({
selector: 'app-selfie-dialog',
template: '<div id="selfieContainer"></div>'
})
export class SelfieDialogComponent implements AfterViewInit, OnDestroy {
private validator: FaceValidator | null = null;
ngAfterViewInit(): void {
this.validator = new FaceValidator({
container: '#selfieContainer',
ui: 'none',
locale: 'pt-BR',
debugMode: false,
mirror: true,
onStatusUpdate: (status: ValidationStatus, message: string) => {
console.log(status, message);
},
onCaptureSuccess: (blob: Blob) => {
console.log('Selfie capturada', blob);
},
onError: (errorType: ValidationStatus, error: Error) => {
console.error(errorType, error);
}
});
}
ngOnDestroy(): void {
this.validator?.destroy();
}
}
container: target element where the SDK automatically renders video and canvas.ui: use none to render your own UI (status, buttons, etc.).locale: defines the language for SDK messages.debugMode: displays landmarks for debugging during development.mirror: mirrors the camera (selfie default).onStatusUpdate: receives the status and message for you to update the UI.onCaptureSuccess: receives the Blob of the captured selfie for upload/preview.onError: captures camera or model loading errors.ReactSelfieCaptureIf you are building a React application and want a ready‑to‑use selfie capture UI, the SDK exposes an optional React component that encapsulates:
getUserMedia)FaceValidator)Your React app should already have react and react-dom installed. Then:
npm install face-validator-sdk
@mediapipe/tasks-visionis installed automatically as a dependency of the SDK.
reactandreact-domare declared as peerDependencies – they are not bundled inside the package.
Non‑React applications should use the coreFaceValidatorAPI shown above instead ofReactSelfieCapture.
import { ReactSelfieCapture } from 'face-validator-sdk';
function SelfieExample() {
const handleCapture = (imageBase64: string | null) => {
if (imageBase64) {
// send to API, store, etc.
}
};
return (
<ReactSelfieCapture
locale={navigator.language} // 'pt-BR' | 'en' | 'es' (auto-normalized)
onCapture={handleCapture}
onDismiss={() => console.log('Modal closed')}
/>
);
}
type SupportedLocale = 'pt-BR' | 'en' | 'es';
type SelfieCaptureStyles = {
container?: React.CSSProperties;
media?: React.CSSProperties;
messageBanner?: React.CSSProperties;
primaryButton?: React.CSSProperties;
secondaryButton?: React.CSSProperties;
};
type SelfieCaptureUILabelOverrides = Partial<{
previewQuestion: string;
savePhoto: string;
tryAgain: string;
cancel: string;
}>;
interface ReactSelfieCaptureProps {
onCapture: (image: string | null) => void; // base64 data URL or null on cancel
onDismiss?: () => void;
// Behaviour
locale?: SupportedLocale | string; // Default: 'pt-BR' (auto-normalized)
videoWidth?: number; // Default: 512
videoHeight?: number; // Default: 384
debugMode?: boolean; // Default: false
modelPath?: string; // Optional MediaPipe WASM path; if omitted, uses internal CDN default
// Visual customization (inline styles)
styles?: SelfieCaptureStyles;
// Optional UI labels override (per-locale defaults exist)
labels?: SelfieCaptureUILabelOverrides;
}
By default, the component renders UI labels in Portuguese (pt-BR), English (en) or Spanish (es):
You can override any of these without having to set up an external i18n layer:
<ReactSelfieCapture
locale="pt-BR"
onCapture={handleCapture}
labels={{
previewQuestion: 'Confira sua selfie antes de salvar',
savePhoto: 'Confirmar selfie',
}}
/>
The component ships with a sensible default layout, but you can tweak it via the styles prop:
<ReactSelfieCapture
onCapture={handleCapture}
styles={{
container: { borderRadius: 24 },
media: { borderRadius: 16 },
messageBanner: { backgroundColor: '#f0f9ff', color: '#0369a1' },
primaryButton: { backgroundColor: '#2563eb', borderColor: '#2563eb' },
secondaryButton: { borderRadius: 9999 },
}}
/>;
Tip: you can wrap
ReactSelfieCapturein your own modal/dialog and passonDismissto close it from the Cancel button.
The SDK uses two MediaPipe models running in parallel:
Migrated from face-api.js (discontinued 2021) to MediaPipe (Google):
| Feature | face-api.js | MediaPipe |
|---|---|---|
| Landmarks | 68 points | 478 points |
| Hand detection | ❌ None | ✅ 21 pts/hand |
| Maintenance | ❌ Discontinued | ✅ Active (Google) |
| Performance | CPU only | ✅ GPU accelerated |
| Accuracy | ~60-70% | ✅ ~90-95% |
| Model size | ~8MB | ~15MB |
Contributions are welcome! Please:
git checkout -b feature/amazing-featuregit commit -m 'feat: add amazing feature'git push origin feature/amazing-featureMIT License - see LICENSE file for details.
FAQs
Real-time selfie validation SDK with face detection, i18n (pt-BR, en, es). Built on MediaPipe.
The npm package face-validator-sdk receives a total of 33 weekly downloads. As such, face-validator-sdk popularity was classified as not popular.
We found that face-validator-sdk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.