✨Works out of the box guarantee. If you face any issue at all, hit us up on Telegram and we will write the integration for you.

Backend Flow
Best Practices

Backend Best Practices

This guide outlines the best practices for implementing Reclaim Protocol in your backend applications, covering both JavaScript and Python implementations.

Security Best Practices

Protect Your Application Secret

// Store secrets securely
const APP_SECRET = process.env.RECLAIM_APP_SECRET;
const APP_ID = process.env.RECLAIM_APP_ID;
 
// Validate proofs before processing
const isValid = await verifyProof(proof);
if (!isValid) {
  throw new Error('Invalid proof');
}
⚠️

Never expose your Application Secret in public repositories or client-side code. This is crucial for maintaining the security of your application.

  1. Store your APP_SECRET securely using environment variables.
  2. Use a package like dotenv to manage your environment variables:

Error Handling

try {
  const reclaimProof = await ReclaimProofRequest.init(APP_ID, APP_SECRET);
  // ... handle success
} catch (error) {
  console.error('Initialization failed:', error);
  // Implement proper error reporting
  throw new Error('Service temporarily unavailable');
}
  1. Graceful Error Handling: Implement proper error handling for all SDK operations.
  2. Logging: Log errors for debugging while keeping sensitive information secure.
  3. User-Friendly Messages: Return appropriate error messages to clients.

Performance Optimization

// Cache initialization where appropriate
let reclaimProofRequest;
 
async function getOrCreateProofRequest() {
  if (!reclaimProofRequest) {
    reclaimProofRequest = await ReclaimProofRequest.init(APP_ID, APP_SECRET);
  }
  return reclaimProofRequest;
}
  1. Request Caching: Cache proof request configurations when appropriate.
  2. Connection Pooling: Use connection pooling for database operations.
  3. Async Operations: Utilize async/await for better performance.

Monitoring and Logging

  1. Metrics: Track success rates, response times, and error rates.
  2. Alerts: Set up alerts for unusual patterns or high error rates.
  3. Logging: Implement structured logging for better debugging.

Additional Recommendations

  1. Version Control: Keep track of SDK versions and update regularly.
  2. Documentation: Document your implementation and any custom configurations.
  3. Backup: Implement backup strategies for proof data if stored.
  4. Rate Limiting: Implement rate limiting to prevent abuse.

Remember to always refer to the latest SDK documentation for specific version requirements and updates.