facecog-liveness-showcase
v0.0.1
Published
FaceCog Liveness Verification Showcase - Demo application for @naniteninja/liveness-verification library
Readme
FaceCog Liveness Verification
An Angular workspace containing a liveness verification library and a showcase demo application.
Project Structure
facecog-ionic-front/
├── projects/
│ ├── facecog-liveness-verification/ # @naniteninja/liveness-verification
│ │ ├── src/lib/
│ │ │ ├── models/
│ │ │ │ ├── types/ # Type definitions (one per file)
│ │ │ │ │ ├── liveness-backend.type.ts
│ │ │ │ │ ├── verification-flow-step.type.ts
│ │ │ │ │ ├── liveness-action.type.ts
│ │ │ │ │ ├── pose-category.type.ts
│ │ │ │ │ ├── pose-difficulty.type.ts
│ │ │ │ │ ├── detection-strategy.type.ts
│ │ │ │ │ └── index.ts
│ │ │ │ │
│ │ │ │ ├── interfaces/ # Interface definitions (one per file)
│ │ │ │ │ ├── liveness-verification-config.interface.ts
│ │ │ │ │ ├── liveness-result.interface.ts
│ │ │ │ │ ├── pose-definition.interface.ts
│ │ │ │ │ ├── ... (13 more interfaces)
│ │ │ │ │ └── index.ts
│ │ │ │ │
│ │ │ │ ├── constants/ # Constant values
│ │ │ │ │ ├── default-liveness-config.constant.ts
│ │ │ │ │ ├── pose-definitions.constant.ts
│ │ │ │ │ └── index.ts
│ │ │ │ │
│ │ │ │ ├── utils/ # Utility functions
│ │ │ │ │ ├── pose.utils.ts
│ │ │ │ │ └── index.ts
│ │ │ │ │
│ │ │ │ └── index.ts
│ │ │ │
│ │ │ ├── services/ # Core services
│ │ │ │ ├── backends/
│ │ │ │ │ ├── backend-adapter.interface.ts
│ │ │ │ │ └── mock-backend.service.ts
│ │ │ │ ├── camera.service.ts
│ │ │ │ ├── liveness-config.service.ts
│ │ │ │ ├── pose-selection.service.ts
│ │ │ │ └── video-recorder.service.ts
│ │ │ │
│ │ │ ├── liveness-verification.component.ts
│ │ │ └── liveness-verification.module.ts
│ │ │
│ │ ├── src/public-api.ts
│ │ ├── package.json
│ │ ├── ng-package.json
│ │ └── README.md
│ │
│ └── facecog-liveness-verification-test/ # Showcase Demo App
│ └── src/
│ ├── app/
│ │ ├── liveness-verification/ # Full implementation
│ │ ├── verification-demo/ # FaceTec demo
│ │ └── home/ # Home page
│ ├── assets/
│ ├── environments/
│ └── theme/
│
├── dist/
│ └── naniteninjas-liveness-verification/ # Built library
│
├── angular.json
├── tsconfig.json
└── package.jsonQuick Start
Install Dependencies
npm installDevelopment Server
npm startStarts facecog-liveness-verification-test on http://localhost:4200.
Build Library
npm run build:libOutputs to dist/naniteninjas-liveness-verification/.
Build Demo App
npm run build:prodOutputs to www/.
Library Usage
Local Development (No Build Required)
The workspace is configured with TypeScript path mapping:
// tsconfig.json
{
"paths": {
"@naniteninja/liveness-verification": [
"projects/facecog-liveness-verification/src/public-api.ts"
]
}
}Import Examples
// Types (single export per file)
import { LivenessBackend } from '@naniteninja/liveness-verification';
import { VerificationFlowStep } from '@naniteninja/liveness-verification';
import { PoseCategory } from '@naniteninja/liveness-verification';
// Interfaces (single export per file)
import { LivenessVerificationConfig } from '@naniteninja/liveness-verification';
import { LivenessResult } from '@naniteninja/liveness-verification';
import { PoseDefinition } from '@naniteninja/liveness-verification';
// Constants
import { DEFAULT_LIVENESS_CONFIG } from '@naniteninja/liveness-verification';
import { POSE_DEFINITIONS } from '@naniteninja/liveness-verification';
// Utils
import { getPoseById, getPosesByCategory } from '@naniteninja/liveness-verification';
// Services
import { LivenessConfigService, PoseSelectionService } from '@naniteninja/liveness-verification';
// Module/Component
import { LivenessVerificationModule, provideLivenessVerification } from '@naniteninja/liveness-verification';Module-based Usage
import { LivenessVerificationModule } from '@naniteninja/liveness-verification';
@NgModule({
imports: [
LivenessVerificationModule.forRoot({
apiUrl: 'https://api.example.com',
backends: ['amazon', 'facetec']
})
]
})
export class AppModule {}Standalone Usage
import { provideLivenessVerification } from '@naniteninja/liveness-verification';
bootstrapApplication(AppComponent, {
providers: [
provideLivenessVerification({ backends: ['mock'] })
]
});Template
<facecog-liveness-verification
[pose]="5"
(verificationComplete)="onComplete($event)"
(verificationError)="onError($event)">
</facecog-liveness-verification>Available Scripts
| Script | Description |
|--------|-------------|
| npm start | Start the showcase demo app |
| npm run build | Build the demo app |
| npm run build:prod | Build demo app for production |
| npm run build:lib | Build the library |
| npm run package | Build and pack the library |
| npm run npm:pub | Publish library to npm |
| npm run bump:lib | Bump library version |
| npm run lint | Lint the demo app |
Publishing
# Update version
npm run bump:lib
# Build and pack
npm run package
# Publish
npm run npm:pubCode Organization Principles
Single Export Per File
All types, interfaces, and enums follow the single-export-per-file pattern:
// ✅ Good: types/liveness-backend.type.ts
export type LivenessBackend = 'amazon' | 'openpose' | 'facetec' | 'azure' | 'mock';
// ✅ Good: interfaces/liveness-result.interface.ts
export interface LivenessResult {
success: boolean;
confidence: number;
// ...
}Barrel Exports (index.ts)
Each folder has an index.ts that re-exports its contents:
// types/index.ts
export { LivenessBackend } from './liveness-backend.type';
export { VerificationFlowStep } from './verification-flow-step.type';
// ...
// models/index.ts
export * from './types';
export * from './interfaces';
export * from './constants';
export * from './utils';Features
- 40+ Poses: Face, head, hand, gesture, and combined poses
- Multi-Backend: Amazon, FaceTec, OpenPose, Azure, Mock
- TensorFlow.js: MoveNet for pose detection
- MediaPipe: Face & Hand Landmarker
- Configurable: Thresholds, retries, video recording
Tech Stack
- Angular 20
- Ionic 8
- TensorFlow.js
- MediaPipe
- RxJS
License
MIT
