Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
841069c
booky init
catch-21 Oct 21, 2025
f4b5b99
remove periodic sync in favour of event-driven, also fixed deletion
catch-21 Oct 21, 2025
09287ee
fix bookmark edit sync and add pubky click to copy in UI
catch-21 Oct 21, 2025
d5e7bce
add logo, custom homeserver during signup, better handling errors dur…
catch-21 Oct 22, 2025
6c40ef8
logo in UI
catch-21 Oct 22, 2025
3c955f2
styling
catch-21 Oct 22, 2025
4f9fedd
update readme
catch-21 Oct 22, 2025
0441cab
recovery file export and import
catch-21 Oct 22, 2025
4d4d870
fix attempted read of undefined data on init
86667 Oct 22, 2025
5b6b56c
handle firefox promise-based api
86667 Oct 22, 2025
69c631f
correctly sync and remove monitored keys
86667 Oct 22, 2025
f85513f
hash filename to generate fixed length id
86667 Oct 22, 2025
327e199
trigger sync when bookmark copied or moved into synced folder
86667 Oct 22, 2025
6b0ce85
add signout button which removes state and bookmarks for current session
86667 Oct 22, 2025
74a5c81
sub directories supported in syncing
86667 Oct 22, 2025
2cd449a
fix bug in file and folder removal
86667 Oct 22, 2025
9b0d935
pubkey -> public key
86667 Oct 22, 2025
3c8df7a
recovery code sign-in
86667 Oct 22, 2025
fe596ed
priv folder not pulled
86667 Oct 22, 2025
d3f8178
Recovery file user input passphrase with modal
catch-21 Oct 23, 2025
b61ae74
tidy sign up screen UI and use modal for recovery code
catch-21 Oct 23, 2025
fab8f93
cleanup bookmarkSync after Sign Out to fix bug where new users synced…
catch-21 Oct 23, 2025
9681c8a
fix delete in homeserver when moving out of folder
catch-21 Oct 23, 2025
ce2baca
write shared bookmarks to local storage
86667 Oct 23, 2025
5d0a458
popout window option for firefox to allow recovery file selection dur…
catch-21 Oct 23, 2025
75038ab
add monitored key to priv_sharing
86667 Oct 23, 2025
2181f5b
add groups folder which finds common bookmark folders across keys
86667 Oct 23, 2025
a6c1ca0
use 'pubky' instead of 'public key' or 'pubkey'
catch-21 Oct 23, 2025
a4574fc
update readme
86667 Oct 23, 2025
474fea1
do not fetch priv data
86667 Oct 23, 2025
aab1956
cleanup
86667 Oct 23, 2025
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
9 changes: 9 additions & 0 deletions booky/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
node_modules/
dist/
*.log
.DS_Store
*.swp
*.swo
*~
.vscode/
.idea/
260 changes: 260 additions & 0 deletions booky/IMPLEMENTATION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,260 @@
# Booky Implementation Summary

## Completion Status

✅ All components have been successfully implemented and built!

## What Was Built

### 1. Project Structure
- Node.js project with webpack bundling
- Separate builds for Chrome (Manifest V3) and Firefox (Manifest V2)
- Complete source code organization

### 2. Core Modules

#### Offscreen Document (Chrome only - `src/offscreen/`)
- **Why**: Chrome Manifest V3 service workers have strict CSP that blocks eval/WASM
- **Solution**: Run Pubky SDK in offscreen document with relaxed CSP
- `offscreen.html`: HTML wrapper for offscreen context
- `offscreen.js`: Handles all Pubky SDK operations (key generation, signup, data ops)
- Communicates with service worker via `chrome.runtime.sendMessage()`

#### Offscreen Client (`src/pubky/offscreenClient.js`)
- Proxy layer between service worker and offscreen document
- Converts all SDK calls to message passing
- Handles Uint8Array ↔ Array conversion for message serialization

#### Key Management (`src/crypto/keyManager.js`)
- Ed25519 keypair generation via offscreen client
- Private key encryption and secure storage
- Pubkey derivation and folder naming (7-char prefix)

#### Homeserver Client (`src/pubky/homeserverClient.js`)
- Uses offscreen client for all Pubky SDK operations
- Session-based authentication (SDK manages cookies in offscreen context)
- Data operations proxied: `put()`, `get()`, `list()`
- Homeserver resolution via pkarr: `getHomeserverOf()`

#### Bookmark Sync Engine (`src/sync/bookmarkSync.js`)
- Two-way sync for main folder (`pub_abcdefg`)
- Read-only sync for monitored folders
- Timestamp-based conflict resolution
- Automatic bookmark folder creation
- Event listeners for real-time bookmark changes
- Periodic sync every 20 seconds (development setting)

#### Storage Manager (`src/storage/storageManager.js`)
- Cross-browser storage abstraction
- Encrypted key storage
- Monitored pubkeys management
- Sync status tracking

#### Background Service (`src/background/background.js`)
- Extension initialization
- Message handling from popup UI
- Periodic sync alarm management
- Coordinate all modules

### 3. User Interface

#### Popup UI (`src/ui/popup.html`, `popup.js`, `popup.css`)
- **Setup Screen**:
- Welcome message
- Optional invite code input
- Key generation and signup
- **Main Screen**:
- Display user's pubkey and folder name
- Add/remove monitored pubkeys
- Visual sync status indicators:
- ✓ Green: synced successfully
- ✗ Red: error (with tooltip)
- ↻ Rotating: currently syncing
- Manual sync button

### 4. Build System
- Webpack configuration for extension bundling
- Separate Chrome and Firefox builds
- Asset copying (icons, HTML, CSS, manifests)
- npm scripts for building and watching

### 5. Documentation
- Comprehensive README with setup instructions
- MIT License
- Architecture overview
- Usage guide

## File Structure

```
booky/
├── package.json # Dependencies and scripts
├── webpack.config.js # Build configuration
├── README.md # Documentation
├── LICENSE # MIT License
├── IMPLEMENTATION.md # This file
├── manifest.v3.json # Chrome manifest
├── manifest.v2.json # Firefox manifest
├── src/
│ ├── background/
│ │ └── background.js # Background service
│ ├── crypto/
│ │ └── keyManager.js # Key management
│ ├── pubky/
│ │ └── homeserverClient.js # Homeserver client
│ ├── sync/
│ │ └── bookmarkSync.js # Sync engine
│ ├── storage/
│ │ └── storageManager.js # Storage wrapper
│ ├── ui/
│ │ ├── popup.html # Popup UI
│ │ ├── popup.js # Popup logic
│ │ └── popup.css # Popup styles
│ └── utils/
│ ├── browserCompat.js # Cross-browser support
│ └── logger.js # Logging utility
├── icons/
│ ├── icon.svg # Source icon
│ ├── icon16.png # 16x16 icon
│ ├── icon48.png # 48x48 icon
│ └── icon128.png # 128x128 icon
└── dist/ # Build output
├── chrome/ # Chrome build
└── firefox/ # Firefox build
```

## Key Features

### 1. Automatic Key Generation
- Generates keypair on first use
- With option to import and export via encrypted recovery file
- Secure storage with encryption

### 2. Two-Way Bookmark Sync
- Main folder: `pub_abcdefg` (first 7 chars of pubkey)
- Syncs to homeserver at `<pubky>/public/booky/`
- Real-time change detection
- Periodic sync every 20 seconds (development)

### 3. Read-Only Monitoring
- Add other pubkeys to monitor
- Creates folder `pub_hijklmn` for each monitored pubkey
- Resolves homeserver via pkarr if not in staging
- One-way sync from homeserver to browser

### 4. Conflict Resolution
- Timestamp-based: newest wins
- Automatic merging of changes
- Handles deletions correctly

### 5. Visual Feedback
- Sync status indicators for each folder
- Error messages with details
- Loading states during operations

## How to Use

### Load the Extension

**Chrome:**
1. Open `chrome://extensions/`
2. Enable "Developer mode"
3. Click "Load unpacked"
4. Select `booky/dist/chrome/`

**Firefox:**
1. Open `about:debugging#/runtime/this-firefox`
2. Click "Load Temporary Add-on"
3. Navigate to `booky/dist/firefox/` and select `manifest.json`

### First Time Setup
1. Click the Booky icon in toolbar
2. Enter invite code (get from staging homeserver)
3. Click "Setup Booky"
4. Your folder will be created automatically

### Syncing Bookmarks
1. Add bookmarks to your `pub_abcdefg` folder
2. They sync automatically every 20 seconds
3. Or click "Sync Now" for immediate sync

### Monitor Other Pubkeys
1. Open Booky popup
2. Enter a pubkey in the input field
3. Click "Add"
4. Their bookmarks appear in a new folder (read-only)

## Technical Details

### Dependencies
- `@synonymdev/pubky@0.6.0-rc.6` - Pubky SDK
- `webpack` - Bundler
- `copy-webpack-plugin` - Asset copying

### Browser APIs Used
- `bookmarks` - Bookmark management
- `storage.local` - Local storage
- `alarms` - Periodic sync
- `runtime` - Messaging

### Data Format
```json
{
"url": "https://example.com",
"title": "Example",
"tags": [],
"timestamp": 1234567890,
"id": "bookmark_id"
}
```

### Security
- Private keys encrypted before storage
- Session cookies managed by SDK
- Public data path: `<pubky>/public/booky/`

## Next Steps

### For Testing
1. Get invite code from staging homeserver
2. Load extension in browser
3. Complete setup
4. Add bookmarks to test sync

### Future Enhancements
- Key import/export
- Bookmark tags support
- Folder organization
- Conflict resolution UI
- Search functionality
- Batch operations
- Production homeserver support
- Longer sync intervals for production (5 minutes)

## Notes

- Development sync interval: 20 seconds
- Production should use 5 minutes
- Staging homeserver pubkey: `ufibwbmed6jeq9k4p583go95wofakh9fwpp4k734trq79pd9u1uy`
- Folder naming: first 7 chars of pubkey
- Path structure: `<pubky>/public/booky/`

## Chrome CSP Fix

Chrome Manifest V3 service workers have strict Content Security Policy that blocks:
- `eval()` and similar dynamic code evaluation
- WASM module loading (even with `wasm-unsafe-eval`)

**Solution: Offscreen Document**
1. Created `src/offscreen/offscreen.html` and `offscreen.js`
2. Added CSP meta tag to offscreen.html: `script-src 'self' 'unsafe-eval' 'wasm-unsafe-eval'`
3. Offscreen document runs in separate context with relaxed CSP that allows WASM
4. Service worker communicates via `chrome.runtime.sendMessage()`
5. All Pubky SDK operations happen in offscreen context
6. Added `offscreen` permission to manifest.v3.json

**File Sizes:**
- `background.js`: 44 KB (no SDK)
- `offscreen.js`: 1.3 MB (includes Pubky SDK)
- Communication overhead: minimal (async message passing)

22 changes: 22 additions & 0 deletions booky/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
MIT License

Copyright (c) 2025 Booky

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Loading