A comprehensive browser extension template built for the Reclaim Protocol ecosystem. This template provides a solid foundation for developers to create custom browser extensions that generate zero-knowledge proofs from web activity, enabling privacy-preserving credential verification.
This project serves as a template and SDK for developers who want to build browser extensions that integrate with the Reclaim Protocol. Rather than starting from scratch, you can fork this template, customize it for your specific use case, and add additional features on top of the robust foundation we've provided.
The extension follows a modular architecture with three main layers:
Browser Extension Layer:
- Popup UI: Configuration interface, status display, and user controls
- Content Scripts: DOM monitoring, custom script injection, and page interaction
- Background Service Worker: Network monitoring, proof orchestration, and state management
Core Components Layer:
- Network Filter: Analyzes requests, extracts data, and processes responses
- Proof Generator: Integrates with snarkjs for zero-knowledge proof creation
- Provider Handlers: Custom JavaScript files (providerId.js) for provider-specific logic
Integration:
- All components work together to generate cryptographic proofs that are verified by the Reclaim Protocol without exposing the underlying user data.
- Node.js 16+
- npm or yarn
- Modern browser (Chrome/Firefox/Edge)
-
Clone the template:
git clone https://github.com/your-org/reclaim-extension-template.git cd reclaim-extension-template
-
Install dependencies:
npm install
-
Development mode (with hot reload):
npm run dev
-
Production build:
npm run build
-
Load in browser:
- Chrome: Navigate to
chrome://extensions/
β Enable Developer Mode β Load Unpacked β Selectbuild/
folder - Firefox: Navigate to
about:debugging
β This Firefox β Load Temporary Add-on β Select any file inbuild/
- Chrome: Navigate to
The extension includes an automated provider setup system that fetches the latest provider configurations and JavaScript injection scripts from the Reclaim Protocol API.
# Fetch latest providers and generate injection scripts
npm run setup:providers
# Build extension for development
npm run dev
# Build extension for production
npm run build
The setup:providers
command:
- Fetches Active Providers: Connects to
https://api.reclaimprotocol.org/api/providers/active
- Processes 20,000+ Providers: Automatically handles the complete provider registry
- Generates Injection Scripts: Creates JavaScript files in
src/js-scripts/
for providers with custom injections - Smart Updates: Only updates files when content changes, skips unnecessary writes
- Detailed Logging: Shows created, updated, and unchanged file counts
For Development:
# Update providers when needed
npm run setup:providers
# Start development
npm run dev
For Production:
# Ensure latest providers
npm run setup:providers
# Build for production
npm run build
Provider injection scripts are automatically generated in:
src/js-scripts/
βββ [provider-id-1].js # Custom injection for provider 1
βββ [provider-id-2].js # Custom injection for provider 2
βββ ... # One file per provider with custom injection
These files are automatically loaded by the extension when users interact with their respective provider websites.
src/
βββ assets/ # Icons, images, static files
β βββ img/ # Logo and other images
βββ background/ # Background service worker and related logic
β βββ background.js
β βββ messageRouter.js
β βββ sessionManager.js
β βββ proofQueue.js
β βββ tabManager.js
β βββ cookieUtils.js
β βββ types.js
β βββ README.md
βββ content/ # Content scripts for web pages
β βββ content.js
β βββ components/
β βββ ProviderVerificationPopup.js
βββ interceptor/ # Network interception logic
β βββ network-interceptor.js
βββ js-scripts/ # Custom JS scripts for injection
β βββ sample.js
β βββ 8f8f3def-7864-4dae-890d-9e95c5e45bec.js
βββ offscreen/ # Offscreen document and scripts
β βββ offscreen.html
β βββ offscreen.js
βββ utils/ # Utility functions and helpers
β βββ polyfills.js
β βββ offscreen-manager.js
β βββ session-timer.js
β βββ fetch-calls.js
β βββ websocket-polyfill.js
β βββ polyfill-test.js
β βββ offscreen-websocket.js
β βββ logger/
β β βββ index.js
β β βββ debugLogger.js
β β βββ LogEntry.js
β β βββ LoggerService.js
β β βββ constants.js
β β βββ README.md
β βββ proof-generator/
β β βββ proof-generator.js
β β βββ proof-formatter.js
β β βββ index.js
β βββ constants/
β β βββ constants.js
β β βββ interfaces.js
β β βββ index.js
β βββ claim-creator/
β β βββ claim-creator.js
β β βββ claim-creator.test.js
β β βββ index.js
β β βββ network-filter.js
β β βββ params-extractor.js
β β βββ params-extractor-utils.js
β β βββ replay-request.js
β βββ mocks/
β βββ jsdom-mock.js
β βββ koffi-mock.js
β βββ re2-mock.js
β βββ worker-threads-mock.js
βββ manifest.json # Extension manifest
The extension UI is fully customizable to match your brand and requirements.
Location: src/popup/
/* src/popup/styles.css - Customize the popup appearance */
:root {
--primary-color: #your-brand-color;
--secondary-color: #your-secondary-color;
--background: #your-background;
--text-color: #your-text-color;
}
.popup-container {
/* Modify dimensions, colors, layout */
width: 400px;
min-height: 500px;
}
Key Customization Points:
- Colors & Branding: Update CSS variables in
styles.css
- Layout: Modify
index.html
structure - Interactions: Extend
popup.js
for custom functionality - Animations: Add CSS transitions and animations
- Dark/Light Modes: Implement theme switching
Location: src/content/
Customize how the extension interacts with web pages:
// src/content/index.js - Customize injected UI elements
const createOverlay = () => {
const overlay = document.createElement('div');
overlay.className = 'reclaim-overlay'; // Style this in your CSS
// Add your custom styling and functionality
};
Monitors and filters network requests to extract verification data:
class NetworkFilter {
constructor() {
this.activeFilters = new Map();
}
// Add custom filtering logic for your providers
addProviderFilter(providerId, filterConfig) {
// Implement your custom network filtering
}
}
Handles zero-knowledge proof creation using snarkjs:
class ProofGenerator {
async generateProof(data, providerConfig) {
// Customize proof generation logic
// Add support for different proof systems
}
}
Extensible provider system for different web services.
The easiest way to add new providers is using our Developer Tool π οΈ
Step-by-step process:
-
Create Your Provider
- Visit the Dev Tool
- Design a custom provider for any website or service you want to verify
- Configure the data extraction rules and verification parameters
-
Set Up Your Application
- Create a new application in the Dev Tool
- This generates the necessary configuration for your extension
-
Integrate with Your Extension
- Use our JavaScript SDK to connect your application
- The SDK will automatically trigger this browser extension when users need verification
What this achieves: Your users can seamlessly verify credentials from any web service while keeping their data private through zero-knowledge proofs.
For providers requiring custom JavaScript execution on their pages:
- File Naming Convention:
src/providers/[providerId].js
- Automatic Loading: The extension automatically loads and injects scripts based on provider ID
- Scope: Injected scripts have access to the provider's page DOM and can interact with their APIs
Example injection workflow:
// The extension automatically looks for and loads:
// src/providers/linkedin.js β for LinkedIn data
// src/providers/[your-provider].js β for your custom provider
- Identify Extension Point: Determine where your feature fits (background, content, popup, or provider)
- Extend Base Classes: Inherit from existing components where possible
- Add Provider Logic: Create custom provider files if needed
- Update Manifest: Add any new permissions or resources
- Test Thoroughly: Test across different browsers and scenarios
# Run development server
npm run dev
# Run tests (add your test framework)
npm test
# Build for production
npm run build
# Package for distribution
npm run package
The template includes polyfills for Node.js modules to ensure compatibility:
- Webpack Configuration:
webpack.config.js
handles module resolution - Polyfills:
src/utils/polyfills.js
provides browser compatibility - Manifest V3: Built for modern extension standards
- Update
manifest.json
with your extension details - Prepare store assets (icons, screenshots, descriptions)
- Test thoroughly across target browsers
- Submit to respective extension stores
- Zero-Knowledge Proofs: Data verification without exposure
- Local Processing: Sensitive operations happen locally
- Minimal Permissions: Only essential browser permissions requested
- Secure Storage: Encrypted local storage for sensitive data
We welcome contributions that improve the template for all developers:
- Fork the repository
- Create a feature branch
- Add comprehensive tests
- Update documentation
- Submit a pull request
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Documentation: Full Documentation Site
MIT License - see LICENSE file for details.
π Ready to build your privacy-preserving browser extension? Start by forking this template and customizing it for your use case!