Developer Documentation
Complete guide to integrating RebelVerify into your application.
Installation
Install the RebelVerify SDK using npm or yarn:
npm install @elyndra-studios/rebelverify
# or
yarn add @elyndra-studios/rebelverifyFor TypeScript projects, types are included automatically. No additional type definitions needed.
Note: The SDK works in both browser and Node.js environments.
Quick Start
Get started with RebelVerify in just a few lines of code:
import { rebelVerify } from '@elyndra-studios/rebelverify';
// Initialize the SDK
await rebelVerify.initialize();
// verificationToken: obtained from ID upload (documentation coming soon)
const verificationToken = 'YOUR_VERIFICATION_TOKEN';
// Generate proof for minimum age of 18
const proof = await rebelVerify.generateProof(verificationToken, 18);
if (proof.success) {
// Send proof to your backend for verification
console.log('Proof generated:', proof.data);
}What Happens Here?
- Initialize: Sets up cryptographic keys
- Submit ID: documentation coming soon
- Generate Proof: Creates proof for age verification
- Verify: Send proof to backend for verification & billing
Authentication
RebelVerify uses API keys for backend authentication. Get your API key from the dashboard or create one programmatically.
Getting an API Key
API keys are required for backend verification endpoints. You can create them via the API or dashboard.
Using API Keys
Include your API key in the Authorization header:
// Verify a proof on backend
const response = await fetch('https://api.rebelverify.com/api/v1/verify', {
method: 'POST',
headers: {
'Authorization': `Bearer YOUR_API_KEY`,
'Content-Type': 'application/json',
'X-RebelVerify-Mode': 'sandbox' // or 'production' for live keys
},
body: JSON.stringify({
proof: proof.proof,
publicSignals: proof.publicSignals,
signature: proof.signature
})
});
const result = await response.json();
if (result.valid) {
console.log('Verification successful!');
}Environment Header: Set X-RebelVerify-Mode to sandbox or production to match your API key. Production backends reject sandbox traffic automatically.
Security: Never expose your API key in client-side code. Always use it on your backend server.
initialize()
Initializes the SDK with cryptographic keys. Must be called before using any other SDK methods.
Signature
await rebelVerify.initialize(privateKey?: string): Promise<void>Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
privateKey | string | No | Existing private key as hex string. If not provided, generates a new key pair or uses stored key. |
Returns
Promise that resolves when initialization is complete. Throws an error if initialization fails.
Examples
// Initialize with new keys (recommended for first-time users)
await rebelVerify.initialize();
// Initialize with existing key (for returning users)
await rebelVerify.initialize('your-private-key-hex-string');
// Initialize in React component
useEffect(() => {
const initSDK = async () => {
try {
await rebelVerify.initialize();
console.log('SDK ready!');
} catch (error) {
console.error('Failed to initialize:', error);
}
};
initSDK();
}, []);submitID()
documentation coming soon
generateProof()
Generates a proof for age verification. Designed so sites don't need to see your date of birth.
Signature
await rebelVerify.generateProof(
verificationToken: string,
minAge: number
): Promise<VerificationResult>Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
verificationToken | string | Yes | obtained from ID upload (documentation coming soon) |
minAge | number | Yes | Minimum age requirement (e.g., 18, 21, 25) |
Returns
interface VerificationResult {
success: boolean;
error?: string;
data?: {
proof: AgeProof;
proofId: string;
minAge: number;
};
}
interface AgeProof {
proof: any; // Proof object
publicSignals: string[]; // Public inputs
signature: string; // Cryptographic signature
proofId: string; // Unique proof identifier
timestamp: number; // Proof generation timestamp
verificationKey: any; // Verification key for proof validation
}Examples
// verificationToken: obtained from ID upload (documentation coming soon)
const verificationToken = 'YOUR_VERIFICATION_TOKEN';
// Generate proof for 18+ verification
const proof = await rebelVerify.generateProof(verificationToken, 18);
if (proof.success) {
// Send to backend for verification
await sendToBackend(proof.data);
}
// Generate proof for 21+ verification
const proof21 = await rebelVerify.generateProof(verificationToken, 21);
// Handle age requirement not met
try {
const proof = await rebelVerify.generateProof(verificationToken, 25);
} catch (error) {
if (error.message.includes('minimum age')) {
console.log('User does not meet age requirement');
}
}Designed so sites don't need to see your date of birth.
POST /api/v1/verify
Verify an age verification proof on your backend server. This endpoint validates the proof and returns verification status.
Endpoint
POST https://api.rebelverify.com/api/v1/verifyAuthentication
Requires API key authentication via Bearer token in the Authorization header.
Request Body
{
"proof": {
"type": string,
"commitment": string,
"a": [string, string],
"b": [[string, string], [string, string]],
"c": [string, string],
"metadata": {
"currentYear": number,
"minAge": number,
"isEligible": boolean
}
},
"publicSignals": string[], // Public inputs
"signature": string, // Cryptographic signature
"timestamp"?: number // Optional timestamp
}Response
// Success Response (200)
{
"valid": true,
"timestamp": "2025-01-01T00:00:00.000Z",
"minAge": 18
}
// Error Response (400)
{
"valid": false,
"error": "Invalid proof structure",
"timestamp": "2025-01-01T00:00:00.000Z"
}
// Duplicate Proof (400)
{
"valid": false,
"error": "This proof has already been used",
"timestamp": "2025-01-01T00:00:00.000Z"
}Examples
// Using fetch
const response = await fetch('https://api.rebelverify.com/api/v1/verify', {
method: 'POST',
headers: {
'Authorization': `Bearer ${apiKey}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
proof: proof.proof,
publicSignals: proof.publicSignals,
signature: proof.signature
})
});
const result = await response.json();
if (result.valid) {
console.log('User verified! Minimum age:', result.minAge);
} else {
console.error('Verification failed:', result.error);
}
// Using axios
import axios from 'axios';
const response = await axios.post(
'https://api.rebelverify.com/api/v1/verify',
{
proof: proof.proof,
publicSignals: proof.publicSignals,
signature: proof.signature
},
{
headers: {
'Authorization': `Bearer ${apiKey}`,
'X-RebelVerify-Mode': 'sandbox'
}
}
);
if (response.data.valid) {
// User is verified
}
// Using curl
curl -X POST https://api.rebelverify.com/api/v1/verify \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-H "X-RebelVerify-Mode: sandbox" \
-d '{
"proof": {...},
"publicSignals": [...],
"signature": "..."
}'Error Codes
| Status Code | Description |
|---|---|
200 | Verification successful |
400 | Invalid proof, missing fields, or duplicate proof |
401 | Invalid or missing API key |
429 | Rate limit exceeded |
500 | Internal server error |
GET /api/v1/usage
Get usage statistics for your API key, including total verifications, revenue, and recent activity.
Endpoint
GET https://api.rebelverify.com/api/v1/usageAuthentication
Requires API key authentication via Bearer token in the Authorization header.
Response
{
"apiKeyId": "uuid",
"platformName": "Your Platform",
"totalVerifications": 1250,
"recentVerifications": [
{
"id": "uuid",
"createdAt": "2025-01-01T00:00:00.000Z"
}
]
}Examples
// Using fetch
const response = await fetch('https://api.rebelverify.com/api/v1/usage', {
headers: {
'Authorization': `Bearer ${apiKey}`
}
});
const stats = await response.json();
console.log('Total verifications:', stats.totalVerifications);
// Using axios
import axios from 'axios';
const response = await axios.get(
'https://api.rebelverify.com/api/v1/usage',
{
headers: {
'Authorization': `Bearer ${apiKey}`
}
}
);
const stats = response.data;
// Using curl
curl -X GET https://api.rebelverify.com/api/v1/usage \
-H "Authorization: Bearer YOUR_API_KEY"React Integration
Example of generating a proof in a React application. ID upload documentation is coming soon.
import React, { useState, useEffect } from 'react';
import { rebelVerify } from '@elyndra-studios/rebelverify';
function AgeVerification() {
const [proof, setProof] = useState(null);
const [loading, setLoading] = useState(false);
const [error, setError] = useState(null);
// verificationToken: obtained from ID upload (documentation coming soon)
const verificationToken = 'YOUR_VERIFICATION_TOKEN';
useEffect(() => {
const initSDK = async () => {
try {
await rebelVerify.initialize();
} catch (err) {
setError('Failed to initialize SDK');
}
};
initSDK();
}, []);
const handleGenerateProof = async (minAge = 18) => {
setLoading(true);
setError(null);
try {
const proofResult = await rebelVerify.generateProof(verificationToken, minAge);
if (!proofResult.success) {
setError(proofResult.error || 'Failed to generate proof');
return;
}
setProof(proofResult.data);
} catch (err) {
setError(err.message || 'An error occurred');
} finally {
setLoading(false);
}
};
return (
<div className="age-verification">
<p>ID upload: documentation coming soon</p>
<button onClick={() => handleGenerateProof(18)} disabled={loading}>
Verify 18+
</button>
{loading && <p>Processing...</p>}
{error && <p className="error">{error}</p>}
{proof && <p>Proof generated</p>}
</div>
);
}
export default AgeVerification;Using with Next.js
// app/api/verify/route.ts (Next.js App Router)
import { NextRequest, NextResponse } from 'next/server';
export async function POST(request: NextRequest) {
const body = await request.json();
const apiKey = process.env.REBELVERIFY_API_KEY;
const response = await fetch('https://api.rebelverify.com/api/v1/verify', {
method: 'POST',
headers: {
'Authorization': `Bearer ${apiKey}`,
'Content-Type': 'application/json'
},
body: JSON.stringify(body)
});
const result = await response.json();
return NextResponse.json(result);
}Error Handling
Always check the success property and handle errors appropriately. The SDK returns structured error messages to help with debugging.
Basic Error Handling
// verificationToken: obtained from ID upload (documentation coming soon)
const verificationToken = 'YOUR_VERIFICATION_TOKEN';
const result = await rebelVerify.generateProof(verificationToken, 18);
if (!result.success) {
console.error('Error:', result.error);
// Handle error (show message to user, retry, etc.)
return;
}
// Continue with successful result
const { proof } = result.data;Comprehensive Error Handling
async function verifyAge(verificationToken: string, minAge: number) {
try {
// Initialize SDK
await rebelVerify.initialize();
} catch (error) {
return {
success: false,
error: 'Failed to initialize SDK. Please refresh and try again.'
};
}
try {
// verificationToken: obtained from ID upload (documentation coming soon)
// Generate proof
const proofResult = await rebelVerify.generateProof(
verificationToken,
minAge
);
if (!proofResult.success) {
if (proofResult.error?.includes('minimum age')) {
return {
success: false,
error: `You must be at least ${minAge} years old to continue.`
};
}
return {
success: false,
error: proofResult.error || 'Failed to generate proof'
};
}
return {
success: true,
data: proofResult.data
};
} catch (error) {
// Handle unexpected errors
console.error('Unexpected error:', error);
return {
success: false,
error: 'An unexpected error occurred. Please try again.'
};
}
}Common Error Messages
| Error Message | Cause | Solution |
|---|---|---|
SDK not initialized | initialize() not called | Call initialize() first |
Failed to extract birth date | Could not read the document | Use clearer image or different document |
does not meet minimum age | User too young | Inform user of age requirement |
Verification token not found | Invalid or expired token | Re-submit document |
Best Practices
Follow these best practices to ensure secure, reliable, and user-friendly integration.
Initialization
- Always initialize first: Call
initialize()before using any SDK methods - Handle initialization errors: Wrap initialization in try-catch and provide user feedback
- Initialize once: Initialize in your app's entry point or root component, not on every action
Security
- Never expose API keys: Always use API keys on your backend, never in client-side code
- Use HTTPS: Always use HTTPS in production to protect data in transit
- Validate input: Validate file types and sizes before submission
User Experience
- Show loading states: Display loading indicators during processing
- Provide clear errors: Show user-friendly error messages, not technical details
- Guide users: Provide instructions on what documents are accepted
- Allow retries: Let users retry if verification fails
Performance
- Optimize images: Compress images before submission to reduce processing time
- Cache credentials: Store exported credentials to avoid re-verification
- Implement rate limiting: Add rate limiting on your backend to prevent abuse
Code Example
// Best practice: Complete integration example
import { rebelVerify } from '@elyndra-studios/rebelverify';
class AgeVerificationService {
private initialized = false;
async initialize() {
if (this.initialized) return;
try {
await rebelVerify.initialize();
this.initialized = true;
} catch (error) {
throw new Error('Failed to initialize verification service');
}
}
async verifyUser(verificationToken: string, minAge: number) {
// Ensure initialized
if (!this.initialized) {
await this.initialize();
}
try {
// verificationToken: obtained from ID upload (documentation coming soon)
// Generate proof
const proofResult = await rebelVerify.generateProof(
verificationToken,
minAge
);
if (!proofResult.success) {
throw new Error(proofResult.error || 'Proof generation failed');
}
// Verify on backend
const backendResult = await this.verifyOnBackend(proofResult.data);
if (!backendResult.valid) {
throw new Error('Backend verification failed');
}
return {
success: true,
minAge: backendResult.minAge
};
} catch (error) {
console.error('Verification error:', error);
throw error;
}
}
private async verifyOnBackend(proofData: any) {
const response = await fetch('/api/verify', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
proof: proofData.proof.proof,
publicSignals: proofData.proof.publicSignals,
signature: proofData.proof.signature
})
});
return response.json();
}
}