Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions Integration-for-verifiers (Billions Wallet)/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Server Configuration
PORT=8080
HOST_URL=https://your-domain.com # Your production domain or ngrok URL for development

# Verifier Configuration
#⚠️ CRITICAL: IMMUTABLE VALUES - DO NOT CHANGE AFTER FIRST USE (NULLIFIER_ID & VERIFIER_DID)
# These values CANNOT be changed once users start verifying, as changing them
# will result in different nullifier IDs and DIDs for the same users.
VERIFIER_DID=your_verifier_did_here # Download the Billions app and Login into it.Copy the DID created for your account to use as the Verifier. You can find that in settings.
USE_CASE=POU # Options: POH, POU, POVH
NULLIFIER_SESSION_ID=your_nullifier_session_id # Must be a positive BigInt for the proof request.

#Use case selection
# POH (Proof of Humanity): Verify that the user is a real human via `Human` Credential
# POU (Proof of Uniqueness): Verify that the user is unique (anti-Sybil) via `Verified Human` credential
# POVH (Proof of Verified Humanity): Verify that the user is a real verified human via `Verified Human` Credential

USE_CASE=POVH #Options: 'POH', 'POU'

# Redis Configuration (Production)
# ⚠️ SECURITY: Never commit real credentials to code repositories
REDIS_HOST=your-redis-host.redis-cloud.com
REDIS_PORT=12345
REDIS_USERNAME=your-redis-username
REDIS_PASSWORD=your-secure-redis-password-here

# Database Configuration
DATABASE_URL="your-database-url-here"

# Security Configuration (Production)
ALLOWED_ORIGINS=https://your-frontend-domain.com,https://your-mobile-app-domain.com # Comma-separated list
NODE_ENV=production # Set to 'production' for strict CORS
LOG_LEVEL=info # Options: error, warn, info, debug
3 changes: 3 additions & 0 deletions Integration-for-verifiers (Billions Wallet)/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.env
node_modules/
logs/
75 changes: 59 additions & 16 deletions Integration-for-verifiers (Billions Wallet)/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,50 @@ This project is a demo backend and static UI for integrating verifications via B
1. **Install dependencies**

```bash
cd "Integration-for-verifiers (Billions Wallet)/js"
npm install
```

### 2. Configure Environment Variables

Create a `.env` file based on the env.example in the `js/` directory with the following variables:
Create a `.env` file based on the `env.example` in the directory:

```bash
cp env.example .env
```

Edit the `.env` file with your configuration:

```bash
# Server Configuration
PORT=8080
HOST_URL=https://your-domain.com # Your production domain or ngrok URL for development

# Verifier Configuration
#⚠️ CRITICAL: IMMUTABLE VALUES - DO NOT CHANGE AFTER FIRST USE (NULLIFIER_ID & VERIFIER_DID)
# These values CANNOT be changed once users start verifying, as changing them
# will result in different nullifier IDs and DIDs for the same users.
VERIFIER_DID=your_verifier_did_here # Download the Billions app and Login into it.Copy the DID created for your account to use as the Verifier. You can find that in settings.
USE_CASE=POU # Options: POH, POU, POVH
NULLIFIER_SESSION_ID=your_nullifier_session_id # Must be a positive BigInt for the proof request.

#Use case selection
# POH (Proof of Humanity): Verify that the user is a real human via `Human` Credential
# POU (Proof of Uniqueness): Verify that the user is unique (anti-Sybil) via `Verified Human` credential
# POVH (Proof of Verified Humanity): Verify that the user is a real verified human via `Verified Human` Credential

USE_CASE=POVH #Options: 'POH', 'POU'

# Redis Configuration (Production)
# ⚠️ SECURITY: Never commit real credentials to code repositories
REDIS_HOST=your-redis-host.redis-cloud.com
REDIS_PORT=12345
REDIS_USERNAME=your-redis-username
REDIS_PASSWORD=your-secure-redis-password-here

# Security Configuration (Production)
ALLOWED_ORIGINS=https://your-frontend-domain.com,https://your-mobile-app-domain.com # Comma-separated list
NODE_ENV=production # Set to 'production' for strict CORS
LOG_LEVEL=info # Options: error, warn, info, debug
```

### 3. Set Up Public Access
Expand All @@ -31,30 +67,37 @@ The Billions mobile app sends callbacks to your server, so you need public acces

### 4. Start the Server

To start ans test the server in dev mode use:
```bash
node index.js
npm run pm2:dev
```

You should see:
```
🚀 Privado verifier backend running on port 8080
🔧 Using verification configuration: POU (Verified Human)
```
You should see a series of messages from PM2 indicating that it’s launching multiple instances of the backend in cluster mode. This confirms that your Billions Verifier backend has successfully started under PM2, leveraging multiple workers for scalability and fault tolerance.

### 5. Test the Integration

1. **Open your browser** to `http://localhost:8080`
2. **Reload** the page to start a session and invoke verification request.
2. **Click** the button to continue flow on Billions Web Wallet or **Scan the QR after downloading the APP** to continue the flow on the native app.
4. **Complete verification** in the app
5. **See status update** on the web page
2. **Check health status** at `http://localhost:8080/api/health` to verify Redis connection
3. **Reload** the page to start a session and invoke verification request.
4. **Click** the button to continue flow on Billions Web Wallet or **Scan the QR after downloading the APP** to continue the flow on the native app.
5. **Complete verification** in the app
6. **See status update** on the web page

### 6. Production Features

---
This implementation includes production-ready features:

- **Redis Storage**: Persistent storage for sessions and verifications
- **PM2**: Process Manager for Node.js applications with a built-in Load Balancer.
- Use a permament storage for sessions and verifications relared to uniquness and nullifier id.
- **Health Check**: `/api/health` endpoint for monitoring
- **Graceful Shutdown**: Proper cleanup of Redis connections
- **Error Handling**: Comprehensive error handling for Redis operations
- **TTL Management**: Automatic expiration of stored data
- **Security**: Rate limiting, CORS, and security headers

**Ready to integrate Billions verification into your application? Start with this example and customize it for your needs!** 🚀

## License
MIT
---



55 changes: 55 additions & 0 deletions Integration-for-verifiers (Billions Wallet)/ecosystem.config.js

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete it

Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
module.exports = {
apps: [{
name: 'billions-verifier',
script: 'src/index.js',
instances: 'max', // Use all CPU cores
exec_mode: 'cluster', // Enable cluster mode for load balancing

// Environment configuration
env: {
NODE_ENV: 'development',
PORT: 8080
},
env_production: {
NODE_ENV: 'production',
PORT: 8080
},

// Process management
max_memory_restart: '1G',
min_uptime: '10s',
max_restarts: 10,
restart_delay: 4000,

// Logging
log_file: 'logs/pm2-combined.log',
out_file: 'logs/pm2-out.log',
error_file: 'logs/pm2-error.log',
log_date_format: 'YYYY-MM-DD HH:mm:ss Z',
merge_logs: true,

// Monitoring
source_map_support: true,
instance_var: 'INSTANCE_ID',

// Health monitoring
watch: false, // Set to true for development auto-restart
ignore_watch: ['node_modules', 'logs', '.git'],

// Production optimizations
node_args: '--max-old-space-size=1024'
}],

// Deployment configuration
deploy: {
production: {
user: 'deploy',
host: ['your-server.com'],
ref: 'origin/main',
repo: 'git@github.com:your-username/billions-verifier.git',
path: '/var/www/billions-verifier',
'post-deploy': 'npm install && pm2 reload ecosystem.config.js --env production',
'pre-setup': 'apt-get install git -y'
}
}
};
19 changes: 0 additions & 19 deletions Integration-for-verifiers (Billions Wallet)/js/.env.example

This file was deleted.

Loading