An adaptive identity and risk evaluation platform implementing passwordless authentication (WebAuthn/FIDO2) and dynamic risk-based policies.
Kavach ID provides a centralized backend for managing multi-tenant identity, sessions, and device trust. It evaluates user requests against predefined risk policies and device fingerprints to trigger authentication step-ups selectively rather than requiring static, high-friction multifactor authentication on every request.
Problem Solved: Balances security and user experience by silently scoring risk levels for incoming requests, invoking biometric verification (via WebAuthn/Passkeys) only when anomalous behavior is detected.
Scope: The repository serves as a monorepo containing the core NestJS API backend and a suite of client SDKs to integrate risk-based authentication flows across multiple platforms.
- Multi-Tenant Identity Management — Isolates users, devices, sessions, and roles per tenant.
- Risk-Based Authentication (RBA) — Evaluates request context against
PolicyRuleschemas to compute a dynamic risk score. - Passwordless (WebAuthn) — Handles credential registration and assertion using
@simplewebauthnfor hardware-backed FaceID/TouchID/Windows Hello flows. - Device Fingerprinting & Trust — Cryptographically binds active sessions to trusted physical devices.
- Audit & Outbox Pattern — Maintains immutable audit logs and reliable outbox event propagation for distributed transaction integrity.
| Category | Technology |
|---|---|
| Language | TypeScript |
| Framework | NestJS / Express |
| Database | PostgreSQL |
| ORM | Prisma |
| Authentication | WebAuthn, JWT (JOSE), Argon2 |
| Testing | Jest, Supertest |
| Infrastructure | Docker, Docker Compose |
.
├── admin-console/ # Frontend for configuring risk policies
├── kubernetes/ # Kubernetes deployment configurations
├── prisma/ # Database schemas and migrations
├── samples/ # Reference implementation examples
├── sdks/
│ ├── kavach-android/
│ ├── kavach-flutter/
│ ├── kavach-go/
│ ├── kavach-ios/
│ ├── kavach-python/
│ ├── kavach-react-native/
│ └── kavach-web/
├── src/ # Core Node.js / NestJS backend implementation
└── test/ # E2E test suites
- Node.js: v20 or higher
- npm: v9 or higher
- Docker & Docker Compose: For local PostgreSQL provisioning
- TypeScript:
ts-nodeglobally available (optional, for running scripts directly)
-
Clone the repository:
git clone https://github.com/Rajeev02/kavachid.git cd kavachid -
Install dependencies:
npm install
-
Start the Database Infrastructure:
docker-compose up -d db
-
Initialize Database Schema:
npx prisma db push npx prisma generate
-
Start the Application in Development Mode:
npm run start:dev
The API server will run locally. Webhook events can be routed through the mocked webhook listener provided by the docker-compose.yml.
Environment variables can be provided in a .env file or exported to the shell.
| Variable | Description | Required | Default |
|---|---|---|---|
DATABASE_URL |
PostgreSQL connection string | Yes | postgresql://kavach:supersecretpassword@localhost:5432/kavachid?schema=public |
PORT |
API server listening port | No | 3000 |
KAVACHID_MASTER_KEY |
Master cryptographic key for encryption | Yes (in prod) | None |
WEBHOOK_URL |
Destination URL for emitted events | No | None |
JWT_ACCESS_EXPIRES_IN |
Access token lifespan | No | 15m |
JWT_REFRESH_EXPIRES_IN |
Refresh token lifespan | No | 7d |
The project uses Jest for both unit and end-to-end testing.
Run unit tests:
npm run testRun tests in watch mode:
npm run test:watchRun End-to-End (E2E) tests:
npm run test:e2eGenerate coverage report:
npm run test:covA Dockerfile is provided at the root for containerized deployments.
Build the core image:
docker build -t kavach-core .The stack can be deployed utilizing the provided docker-compose.yml or the resources in the kubernetes/ directory for orchestration. Ensure DATABASE_URL and KAVACHID_MASTER_KEY are injected safely via secrets.
- Cryptography: Utilizes
josefor robust JWT issuance and signature validation. Private keys are securely managed and rotated via theKeyPairschema. - Passwords: Uses
argon2for password hashing, though the primary authentication mechanism defaults to WebAuthn. - Device Identity: DPoP (Demonstrating Proof-of-Possession) public keys are supported to bind tokens strictly to the client device that requested them.
- Fork the repository
- Create a feature branch (
git checkout -b feature-name) - Adhere to the existing code style via ESLint and Prettier (
npm run format,npm run lint) - Ensure all tests pass (
npm run test) - Submit a pull request detailing your changes
This project is currently marked as UNLICENSED. Please review repository policies before modifying or distributing.