Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
88c2de8
Add browser extension entrypoints, injected/content bridge, and provi…
jonatan-holmgren Mar 17, 2026
eeb0bee
Bump
jonatan-holmgren Mar 17, 2026
bccbddd
Bump
jonatan-holmgren Mar 17, 2026
faaff69
Bump
jonatan-holmgren Mar 18, 2026
c235a91
Bump
jonatan-holmgren Mar 19, 2026
e34679b
Implement session management improvements
jonatan-holmgren Mar 20, 2026
10d1846
Bump
jonatan-holmgren Mar 20, 2026
dff4906
Cleanup
jonatan-holmgren Mar 21, 2026
88be62a
Use eventemitter3 and fix leaking event listener
jonatan-holmgren Mar 21, 2026
1b6c8cc
Clean up
jonatan-holmgren Mar 21, 2026
8f85614
Bump
jonatan-holmgren Mar 21, 2026
0c22782
Update readme
jonatan-holmgren Mar 21, 2026
eedb21e
Refactor createFakeProvider to simplify status handling and remove un…
jonatan-holmgren Mar 21, 2026
f388b66
Revert debug stuff
jonatan-holmgren Mar 21, 2026
66469f2
Open popup without auto-creating session and accept optional handshak…
jonatan-holmgren Mar 22, 2026
ae36004
Update providerDetail UUID generation and modify rdns for extension
jonatan-holmgren Mar 22, 2026
2ac5325
Open popup for eth_requestAccounts only after user interaction
jonatan-holmgren Mar 23, 2026
c640fcf
Add content script bridge and modal/provider integration
jonatan-holmgren Mar 24, 2026
a1716b6
Refactor session management logic to simplify error handling during s…
jonatan-holmgren Mar 24, 2026
cdd435e
Fixes in extension
jonatan-holmgren Mar 27, 2026
02e3753
Improve provider and session error handling
jonatan-holmgren Mar 27, 2026
ec63bef
Refactor session handling to guard against sessions closing during as…
jonatan-holmgren Mar 27, 2026
34d59b9
Use wxt browser and utils in extension entrypoints
jonatan-holmgren Mar 27, 2026
5614fb5
Replace manual response timeout with Promise.race in session creation
jonatan-holmgren Mar 27, 2026
a273f5f
Changeset
jonatan-holmgren Mar 27, 2026
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
7 changes: 7 additions & 0 deletions .changeset/cyan-doodles-dream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@openlv/provider": patch
"@openlv/session": patch
"@openlv/modal": patch
---

Improve openlv to work better in real-world dapps
155 changes: 2 additions & 153 deletions packages/extension/README.md
Original file line number Diff line number Diff line change
@@ -1,153 +1,2 @@
# OpenLV Browser Extension

A cross-browser extension that provides seamless OpenLV wallet connectivity for web applications. Built using [WXT](https://wxt.dev/) for maximum compatibility.

## 🌟 Features

- **🔗 Automatic Provider Injection**: Seamlessly injects `window.openlv` into web pages
- **🌐 Cross-Browser Support**: Works on Chrome, Firefox, Edge, Opera, and other browsers
- **🔒 Secure P2P Communication**: Handles encrypted peer-to-peer connections in the background
- **📱 User-Friendly Interface**: Clean popup UI for managing connections
- **⚡ Real-time Status**: Live connection status updates and phase tracking

## 🛠️ Development

```bash
# Install dependencies
pnpm install

# Development mode (auto-reload)
pnpm dev # Chromium-based browsers
pnpm dev:firefox # Firefox

# Build for production
pnpm build # Chromium-based browsers
pnpm build:firefox # Firefox

# Create distributable zip files
pnpm zip # Chromium zip
pnpm zip:firefox # Firefox zip
```

## 📦 Installation

### For Development

1. Build the extension: `pnpm build`
2. Open Chrome/Edge and go to `chrome://extensions/`
3. Enable "Developer mode"
4. Click "Load unpacked" and select `packages/extension/.output/chrome-mv3`

### For Firefox

1. Build for Firefox: `pnpm build:firefox`
2. Open Firefox and go to `about:debugging`
3. Click "This Firefox" → "Load Temporary Add-on"
4. Select the `manifest.json` from `packages/extension/.output/firefox-mv2`

## 🔧 Architecture

```
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ Web Page │ │ Content Script │ │ Background │
│ │ │ │ │ Service Worker │
│ window.openlv │◄──►│ Message Bridge │◄──►│ OpenLV Manager │
│ │ │ │ │ │
└─────────────────┘ └─────────────────┘ └─────────────────┘
▲ ▲
│ │
▼ ▼
┌─────────────────┐ ┌─────────────────┐
│ Injected Script │ │ Popup Interface │
│ (Provider API) │ │ (User Controls) │
└─────────────────┘ └─────────────────┘
```

### Components

- **Background Script**: Manages OpenLV connections using the transport layer
- **Content Script**: Bridges communication between web pages and the extension
- **Injected Script**: Provides the `window.openlv` API to web applications
- **Popup Interface**: User-friendly UI for managing connections and viewing status

## 📋 API Reference

The extension injects a `window.openlv` object with the following API:

```javascript
// Initialize a new connection (dApp side)
const { openLVUrl, connectionId } = await window.openlv.initConnection();

// Connect to existing session (wallet side)
await window.openlv.connectToSession(openLVUrl);

// Send JSON-RPC messages
await window.openlv.sendMessage({
jsonrpc: '2.0',
id: 1,
method: 'eth_requestAccounts',
params: []
});

// Listen for events
window.openlv.onPhaseChange((phase) => {
console.log('Connection phase:', phase.state);
});

window.openlv.onMessage((message) => {
console.log('Received message:', message);
});

window.openlv.onError((error) => {
console.error('Connection error:', error);
});

// Disconnect
await window.openlv.disconnect();
```

## 🔒 Security

- All communication is end-to-end encrypted using ECDH P-256 + AES-256-GCM
- No sensitive data is stored in extension storage
- Connections are isolated per tab for security
- Content Security Policy prevents script injection attacks

## 🌐 Browser Compatibility

| Browser | Support | Notes |
|---------|---------|-------|
| Chrome | ✅ Full | Manifest V3 |
| Edge | ✅ Full | Manifest V3 |
| Opera | ✅ Full | Manifest V3 |
| Firefox | ✅ Full | Manifest V2 (auto-converted) |
| Safari | ⚠️ Limited | Not tested |

## 🐛 Troubleshooting

### Common Issues

1. **Extension not loading**: Check console for errors, ensure all dependencies are built
2. **Connection timeouts**: Verify MQTT broker connectivity and firewall settings
3. **WebRTC failures**: May require TURN servers in restrictive network environments

### Debug Mode

Enable debug logging by setting `DEBUG=true` in the extension options or console:

```javascript
// In browser console
localStorage.setItem('openlv-debug', 'true');
```

## 🤝 Contributing

1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Test on both Chrome and Firefox
5. Submit a pull request

## 📄 License

Part of the Open Lavatory Protocol - see main repository for license details.
# @openlv/extension
The OpenLV Extension is a browser extension for dApp integration.
Loading
Loading