Usage
Implement Reclaim verification flows in your browser extension popup or panel
Overview
With the SDK initialized and configured, you can now implement verification flows in your extension's user interface. This guide covers implementing verification in popups, side panels, and handling the complete verification lifecycle.
Prerequisites
Before implementing verification flows, ensure you have:
- ✅ Completed Manifest Configuration
- ✅ Completed Background Setup
- ✅ Obtained API credentials from the API Key guide
Basic Popup Implementation
HTML Structure
Create a simple popup interface (popup.html):
JavaScript Implementation
Create the popup logic (popup.js):
Security Note: Never store appSecret in chrome.storage. In production, generate verification requests server-side and only pass
the configuration to the client. The example above is for demonstration only.
SDK API Reference
Initialization Methods
reclaimExtensionSDK.init()
Initialize a new verification request with credentials.
Parameters:
appId(string): Your application ID from Reclaim dashboardappSecret(string): Your application secret (keep secure!)providerId(string): ID of the provider to verify (e.g.,"google-login")
Returns: Promise that resolves to a ReclaimRequest object
reclaimExtensionSDK.fromConfig()
Initialize from a pre-generated configuration (recommended for production).
Parameters:
requestConfig(object): Configuration object from backend
Returns: ReclaimRequest object
Use Case: When using server-side request generation for better security
reclaimExtensionSDK.getVersion()
Get the current version of the Reclaim Extension SDK.
Parameters: None
Returns: String containing the SDK version (e.g., "1.0.0")
Use Case:
- Display SDK version in your application
- Log version information for debugging
- Check SDK version for compatibility
Request Object Methods
After calling reclaimExtensionSDK.init(), you receive a request object with these methods:
request.setAppCallbackUrl()
Set a callback URL where proofs will be sent automatically.
Parameters:
url(string): Your backend endpoint to receive proofs
Use Case: Automatically send proofs to your server when verification completes
request.setParams()
Add custom parameters to the verification request.
Parameters:
params(object): Custom key-value pairs to include with the proof
Use Case: Pass additional context or metadata with the verification
request.addContext()
Add context information to the verification.
Parameters:
address(string): Context address or identifiermessage(string): Context message or description
Use Case: Add on-chain context or additional verification metadata
request.startVerification()
Start the verification process and return a promise that resolves with proofs.
Returns: Promise that resolves with proof data when verification completes
Use Case:
- Get proofs via promise instead of event listeners
- Use with async/await for cleaner code flow
- Combine with event listeners for both immediate and async handling
Note: You can use both the promise return value AND event listeners together. The completed event will fire, and the promise will resolve with the same proof data.
request.on()
Register event listeners for verification lifecycle events.
Parameters:
event(string): Event name ("started","completed", or"error")callback(function): Function to call when event fires
Available Events: See Event Handling section below for details
Complete Usage Example
Event Handling
The SDK uses an event-driven API. Here are all available events:
started Event
Fired when verification session begins.
Payload:
sessionId(string): Unique identifier for this verification session
Use Cases:
- Show loading states
- Track session for analytics
- Store session ID for debugging
completed Event
Fired when verification succeeds and proofs are generated.
Payload:
proofs(object): Contains verification proofs and metadata
Typical Proof Structure:
Use Cases:
- Send proofs to backend for validation
- Store proofs for later use
- Display verification success to user
- Update application state
error Event
Fired when verification fails or is cancelled.
Payload:
error(Error | string): Error object or message
Common Error Types:
- User cancelled verification
- Network errors
- Invalid credentials
- Session timeout
- Provider authentication failed
Server-Side Configuration (Recommended for Production)
🔒 Production Security Best Practice
For production deployments, generate verification requests on your backend instead of exposing credentials in your extension popup/panel.
Why this approach:
- ✅ Keeps secrets secure -
APP_IDandAPP_SECRETstay on your server - ✅ Server-side validation - You control who can request verification
- ✅ No credential exposure - Users can't extract secrets from extension code
- ✅ Better security - Add authentication, rate limiting, logging
What you'll use:
- Backend:
@reclaimprotocol/js-sdk(different package with server-side features) - Extension:
@reclaimprotocol/browser-extension-sdk(just receives config from backend)
📖 Full Backend Setup Guide: Backend Usage Documentation
Backend API Setup
First, install the backend SDK on your server:
Create an Express.js server with verification endpoints:
Create a .env file for your credentials:
Extension Popup/Panel Code
Complete Flow
Benefits Summary:
- 🔐 Credentials never leave your server
- ✅ You control authorization (who can verify)
- 🛡️ Server validates proofs before accepting
- 📊 Track usage, add rate limits, log events
- 🚀 Update verification logic without extension updates
See Backend SDK Documentation for complete backend setup guide.
Testing Your Implementation
Manual Testing
-
Load your extension in Chrome:
-
Open the popup by clicking your extension icon
-
Enter credentials:
- Application ID
- Application Secret
- Provider ID
-
Start verification and follow the flow
-
Check console logs in both popup and background:
- Popup console: Right-click popup → "Inspect"
- Background console: Extensions page → "service worker"
Debugging Tips
Check Network Requests:
Log All Events:
Common Issues
Verification Not Starting
Symptoms: Button click doesn't trigger verification
Solutions:
- Check browser console for errors
- Verify background script is initialized
- Ensure content script is loaded on pages
- Check API credentials are correct
Proofs Not Received
Symptoms: completed event never fires
Solutions:
- Check if user completed provider authentication
- Look for errors in service worker console
- Verify offscreen document is created successfully
- Check network connectivity
Multiple Verification Attempts
Issue: Starting verification multiple times causes issues
Solution: Track verification state and prevent concurrent attempts:
Next Steps
You've successfully implemented verification in your extension! Consider:
- Troubleshooting - Common issues and solutions
- Web Integration - Learn about website integration
- Backend validation - Implement server-side proof verification