- Added SignRequestManager.js to manage sign requests, including UI states for keyspace lock, mismatch, and approval. - Implemented methods for loading state, rendering UI, and handling user interactions (approve/reject requests). - Integrated background message listeners for keyspace unlock events and request updates.
76 lines
2.2 KiB
Markdown
76 lines
2.2 KiB
Markdown
# Mock SigSocket Server Demo
|
|
|
|
This directory contains a mock SigSocket server for testing the browser extension functionality.
|
|
|
|
## Setup
|
|
|
|
1. Install dependencies:
|
|
```bash
|
|
npm install
|
|
```
|
|
|
|
2. Start the mock server:
|
|
```bash
|
|
npm start
|
|
```
|
|
|
|
The server will listen on `ws://localhost:8080/ws`
|
|
|
|
## Usage
|
|
|
|
### Interactive Commands
|
|
|
|
Once the server is running, you can use these commands:
|
|
|
|
- `test` - Send a test sign request to all connected clients
|
|
- `status` - Show server status and connected clients
|
|
- `quit` - Shutdown the server
|
|
|
|
### Testing Flow
|
|
|
|
1. Start the mock server
|
|
2. Load the browser extension in Chrome
|
|
3. Create a keyspace and keypair in the extension
|
|
4. The extension should automatically connect to the server
|
|
5. The server will send a test sign request after 3 seconds
|
|
6. Use the extension popup to approve or reject the request
|
|
7. The server will log the response and send another request after 10 seconds
|
|
|
|
### Expected Output
|
|
|
|
When a client connects:
|
|
```
|
|
New WebSocket connection from: ::1
|
|
Received message: 04a8b2c3d4e5f6...
|
|
Client registered: client_1234567890_abc123 with public key: 04a8b2c3d4e5f6...
|
|
📝 Sending sign request to client_1234567890_abc123: req_1_1234567890
|
|
Message: "Test message 1 - 2024-01-01T12:00:00.000Z"
|
|
```
|
|
|
|
When a sign response is received:
|
|
```
|
|
Received sign response from client_1234567890_abc123: {
|
|
id: 'req_1_1234567890',
|
|
message: 'VGVzdCBtZXNzYWdlIDEgLSAyMDI0LTAxLTAxVDEyOjAwOjAwLjAwMFo=',
|
|
signature: '3045022100...'
|
|
}
|
|
✅ Sign request req_1_1234567890 completed successfully
|
|
Signature: 3045022100...
|
|
```
|
|
|
|
## Protocol
|
|
|
|
The mock server implements a simplified version of the SigSocket protocol:
|
|
|
|
1. **Client Introduction**: Client sends hex-encoded public key
|
|
2. **Welcome Message**: Server responds with welcome JSON
|
|
3. **Sign Requests**: Server sends JSON with `id` and `message` (base64)
|
|
4. **Sign Responses**: Client sends JSON with `id`, `message`, and `signature`
|
|
|
|
## Troubleshooting
|
|
|
|
- **Connection refused**: Make sure the server is running on port 8080
|
|
- **No sign requests**: Check that the extension is properly connected
|
|
- **Extension errors**: Check the browser console for JavaScript errors
|
|
- **WASM errors**: Ensure the WASM files are properly built and loaded
|