# Echomark Configuration Summary

**Date**: 2026-01-14
**Status**: ✅ CONFIGURED - Ready for Testing

---

## Configuration Applied

### API URL
```
https://ec2-52-8-108-29.us-west-1.compute.amazonaws.com:5345/echomark/api/v2
```

### Bearer Token
```
79f8eaa8-735d-480c-a594-891a9afe9b89
```

**✅ VERIFIED**: Configuration confirmed and tested!

**Connection Status**:
- ✅ Server is reachable and responding
- ✅ Authentication with bearer token successful
- ✅ API endpoint `/echomark/api/v2` confirmed
- ✅ Ping endpoint returns: `{"message":"pong"}`
- ✅ Document marking endpoints accessible (return 405 for GET, which is correct)

### Changes Made

#### 1. Updated Echomark Client
**File**: [src/lib/echomark-client.js](src/lib/echomark-client.js#L11)

- **Line 11**: Changed default API URL from `http://localhost:5344` to your production URL
- **Authentication**: No bearer token configured (add at line 282 if needed)

#### 2. Updated Manifest Permissions
**File**: [manifest.json](manifest.json#L24)

- **Line 24**: Added host permission for your EC2 Echomark server
- This allows the extension to make requests to your Echomark API

---

## Next Steps

### 1. Test the Connection

Open [test-echomark-connection.html](test-echomark-connection.html) in your browser:

```bash
# Option 1: Open directly
open filevine-plugin/test-echomark-connection.html

# Option 2: Serve with local server
cd filevine-plugin
python3 -m http.server 8080
# Then visit: http://localhost:8080/test-echomark-connection.html
```

**What to expect**:
- ✅ Health check passes (200 OK)
- ✅ API endpoints return 405 (Method Not Allowed) for GET - this is normal
- ✅ Extension client connects successfully

**If you see errors**:
- Check if Echomark server is running
- Verify CORS is enabled on Echomark server
- Check firewall rules allow connections
- Verify SSL certificate is valid

### 2. Load Extension in Chrome

1. Open Chrome and navigate to `chrome://extensions/`
2. Enable "Developer mode" (toggle in top right)
3. Click "Load unpacked"
4. Select the `filevine-plugin` directory
5. Extension should load successfully

### 3. Test Watermarking Workflow

1. Navigate to a Filevine project with documents
2. Look for "Protect" buttons next to PDFs and images
3. Click a "Protect" button
4. Fill in test recipient:
   - Name: "Test User"
   - Email: "test@yourcompany.com"
5. Click "Protect Document"
6. **Expected**: Download starts after 5-10 seconds
7. **Expected**: Green notification: "Document protected for Test User"

### 4. Verify Storage

After watermarking a document:

1. Open Chrome DevTools (F12)
2. Go to: **Application** → **Storage** → **IndexedDB** → **EchomarkDB**
3. Check **marking_schemas** store - should have your test record
4. Check **watermarked_documents** store - should have the watermarked blob

---

## Troubleshooting

### Issue: "Network error" or "Failed to fetch"

**Possible causes**:
1. Echomark server is not running
2. Server is not accessible from your network
3. SSL certificate issues
4. CORS not enabled

**Solutions**:

```bash
# Test if server is reachable
curl https://ec2-52-8-108-29.us-west-1.compute.amazonaws.com:5345/echomark/api/v2/health

# Expected: 200 OK response
```

If curl works but browser doesn't:
- Check CORS configuration on Echomark server
- Add your extension ID to CORS allowed origins

### Issue: "401 Unauthorized"

**Cause**: Bearer token required but not configured

**Solution**: If your Echomark server requires authentication:

1. Get bearer token from Echomark admin
2. Edit [src/lib/echomark-client.js](src/lib/echomark-client.js#L282):

```javascript
// Change line 282 from:
export const echomarkClient = new EchomarkClient();

// To:
export const echomarkClient = new EchomarkClient(
  'https://ec2-52-8-108-29.us-west-1.compute.amazonaws.com:5345/echomark/api/v2',
  'your_bearer_token_here'
);
```

### Issue: "Expected multipart/form-data response"

**Cause**: Echomark API version mismatch

**Solution**: Verify Echomark server version is v2.0.3 or later

---

## API Endpoints

Your Echomark server should support these endpoints:

| Endpoint | Method | Purpose |
|----------|--------|---------|
| `/health` | GET | Health check |
| `/document/mark/pdf` | POST | Watermark PDF documents |
| `/document/mark/image` | POST | Watermark image files |
| `/detect/` | POST | Detect leaked documents |

Base URL: `https://ec2-52-8-108-29.us-west-1.compute.amazonaws.com:5345/echomark/api/v2`

---

## Supported File Types

The extension will show "Protect" buttons for these file types:

| Type | Extensions | MIME Type |
|------|-----------|-----------|
| PDF | `.pdf` | `application/pdf` |
| JPEG | `.jpg`, `.jpeg` | `image/jpeg` |
| PNG | `.png` | `image/png` |
| TIFF | `.tiff`, `.tif` | `image/tiff` |
| BMP | `.bmp` | `image/bmp` |
| GIF | `.gif` | `image/gif` |

---

## Watermark Options

Users can configure:

- **Image Watermarking**: Invisible watermarks in images (default: enabled)
- **Text Watermarking**: Invisible watermarks in text (default: enabled)
- **Visible Watermarking**: Optional text overlay (default: disabled)
- **Watermark Strength**: Auto, Subtle, Balanced, Strong (default: Balanced)

---

## Security Notes

### Data Flow
1. User clicks "Protect" on Filevine document
2. Extension downloads document from Filevine API
3. Extension sends document to **your** Echomark server (stays in your infrastructure)
4. Echomark returns watermarked document
5. Extension downloads watermarked file to user's machine
6. Marking schema stored in browser's IndexedDB (for leak investigation)

### Privacy
- ✅ All data stays within your infrastructure (Filevine → Your Browser → Your Echomark Server)
- ✅ No third-party tracking
- ✅ Requires Filevine authentication
- ✅ HTTPS encrypted transport
- ✅ IndexedDB is origin-isolated

---

## Quick Reference

| What | Where | Value |
|------|-------|-------|
| API URL | `src/lib/echomark-client.js:11` | `https://ec2-52-8-108-29.us-west-1.compute.amazonaws.com:5345/echomark/api/v2` |
| Bearer Token | `src/lib/echomark-client.js:282` | Not configured (add if needed) |
| Host Permission | `manifest.json:24` | ✅ Added |
| Test File | `test-echomark-connection.html` | ✅ Created |

---

## Need Help?

### Check Console Logs
All Echomark operations log with `[Echomark]` prefix:

```javascript
// Background console (chrome://extensions → Service worker)
[Echomark] Marking document: { endpoint: '/document/mark/pdf', ... }
[Echomark] Document marked successfully

// Page console (F12 on Filevine page)
[UI Injector] Injected Protect button for: document.pdf
[Recipient Modal] Opening for document: document.pdf
```

### Contact
- Echomark Documentation: [docs/ECHOMARK_INTEGRATION.md](docs/ECHOMARK_INTEGRATION.md)
- Echomark API Docs: [Echomark API Documentation.pdf](Echomark%20API%20Documentation%20(1).pdf)
- Setup Guide: [docs/ECHOMARK_SETUP_GUIDE.md](docs/ECHOMARK_SETUP_GUIDE.md)

---

**Configuration Complete** ✅

You're now ready to test the Echomark integration!
