Still don't have dm working because I can't decrypt at primal.
This commit is contained in:
139
nip46-test/README.md
Normal file
139
nip46-test/README.md
Normal file
@@ -0,0 +1,139 @@
|
||||
# 🏰 NIP-46 Remote Signer (Bunker) Test Setup
|
||||
|
||||
This directory contains a complete NIP-46 remote signing setup for testing NOSTR_LOGIN_LITE.
|
||||
|
||||
## 🔧 Setup Overview
|
||||
|
||||
**Bunker**: A remote signer daemon that holds your private keys securely
|
||||
**Client**: Browser client that connects to the bunker to request signatures
|
||||
**NOSTR_LOGIN_LITE**: Connects to bunker for remote signing capability
|
||||
|
||||
## 🔑 Generated Keys
|
||||
|
||||
```
|
||||
Bunker Secret Key: a33767c3bd05bda47880119d6665b79e6f0eecdf8d025966b0b59a9366379d01
|
||||
Bunker Public Key: 7566048aa9df5b36428f2ce364797f7ac6f6d4a17ee566f0cd3fefcf35146b90
|
||||
```
|
||||
|
||||
## 🚀 Testing NIP-46 Remote Signing
|
||||
|
||||
### Step 1: Start the Bunker
|
||||
|
||||
```bash
|
||||
# Open a new terminal and run:
|
||||
./nip46-test/start-bunker.sh
|
||||
```
|
||||
|
||||
You'll see output like:
|
||||
```
|
||||
🔐 Starting NIP-46 Bunker Remote Signer...
|
||||
==============================================
|
||||
Bunker Public Key: 7566048aa9df5b36428f2ce364797f7ac6f6d4a17ee566f0cd3fefcf35146b90
|
||||
Secret key is securely held by bunker
|
||||
|
||||
🚀 Starting bunker daemon...
|
||||
{"time":"202X-XX-XXTXX:XX:XX.XXXZ","level":"info","msg":"starting bunker on ws://localhost:8080"}
|
||||
{"time":"202X-XX-XXTXX:XX:XX.XXXZ","level":"info","msg":"bunker ready to handle NIP-46 requests"}
|
||||
```
|
||||
|
||||
### Step 2: Test with NOSTR_LOGIN_LITE
|
||||
|
||||
Navigate to:
|
||||
```
|
||||
http://localhost:8000/examples/modal-login-demo.html
|
||||
```
|
||||
|
||||
Click "🚀 Launch Authentication Modal" and select **"NIP-46 Remote"** option.
|
||||
|
||||
The browser will connect to the bunker running on `ws://localhost:8080` and request signatures remotely.
|
||||
|
||||
## 🔄 How NIP-46 Works
|
||||
|
||||
```
|
||||
Browser (NOSTR_LOGIN_LITE) → WebSocket → Bunker (NAK on localhost:8080)
|
||||
↓ ↓
|
||||
Requests signature Holds private key
|
||||
↓ ↓
|
||||
Receives signed event Signs & returns result
|
||||
```
|
||||
|
||||
## 📁 Files in this Directory
|
||||
|
||||
- `start-bunker.sh` - Script to start the remote signer daemon
|
||||
- `bunker-config.js` - Configuration for NOSTR_LOGIN_LITE
|
||||
- `README.md` - This documentation
|
||||
|
||||
## 🧪 Testing Scenarios
|
||||
|
||||
### ✅ Successful Connection
|
||||
- Bunker runs on localhost:8080
|
||||
- Browser connects and requests pubkey
|
||||
- Bunker responds with `7566048aa9df5b36428f2ce364797f7ac6f6d4a17ee566f0cd3fefcf35146b90`
|
||||
|
||||
### 🔧 Signature Requests
|
||||
- Browser sends event to sign
|
||||
- Bunker signs with private key
|
||||
- Signed event returned to browser
|
||||
- Browser publishes signed event to relay
|
||||
|
||||
### 🐛 Debug Issues
|
||||
- Check bunker logs for connection errors
|
||||
- Verify WebSocket connection in browser dev tools
|
||||
- Look for NIP-46 protocol errors
|
||||
|
||||
## 📝 NOSTR_LOGIN_LITE Configuration
|
||||
|
||||
In your app, configure remote signing like this:
|
||||
|
||||
```javascript
|
||||
const nip46Config = {
|
||||
type: "nip46",
|
||||
bunker: {
|
||||
pubkey: "7566048aa9df5b36428f2ce364797f7ac6f6d4a17ee566f0cd3fefcf35146b90",
|
||||
url: "ws://your-bunker-server:8080" // Production URL
|
||||
}
|
||||
};
|
||||
|
||||
await window.NOSTR_LOGIN_LITE.init(nip46Config);
|
||||
```
|
||||
|
||||
## ⚠️ Production Notes
|
||||
|
||||
- **This setup uses localhost** - replace with real server URL in production
|
||||
- **Private key is shown for testing** - production bunkers should be secured
|
||||
- **WebSocket URL should be secure** (wss://) in production
|
||||
- **Consider authentication** for your bunker to prevent unauthorized access
|
||||
|
||||
## 🎯 Common Testing Commands
|
||||
|
||||
### Check NAK version
|
||||
```bash
|
||||
nak --version
|
||||
```
|
||||
|
||||
### Generate new keys (if needed)
|
||||
```bash
|
||||
nak key generate # Secret key
|
||||
echo "your_secret_key_here" | nak key public # Public key
|
||||
```
|
||||
|
||||
### Manual bunker test
|
||||
```bash
|
||||
nak bunker --sec "your_secret_key" --port 8080 --relay "wss://relay.damus.io"
|
||||
```
|
||||
|
||||
## 🐛 Troubleshooting
|
||||
|
||||
**Bunker won't start:**
|
||||
- Check if port 8080 is free
|
||||
- Verify NAK is installed correctly
|
||||
|
||||
**Browser can't connect:**
|
||||
- Check firewall settings
|
||||
- Verify bunker is running (`ps aux | grep nak`)
|
||||
- Check browser console for WebSocket errors
|
||||
|
||||
**Signing fails:**
|
||||
- Verify keys are correct
|
||||
- Check bunker logs for errors
|
||||
- Ensure event format is valid
|
||||
42
nip46-test/start-bunker.sh
Executable file
42
nip46-test/start-bunker.sh
Executable file
@@ -0,0 +1,42 @@
|
||||
#!/bin/bash
|
||||
|
||||
# NIP-46 Remote Signer Bunker Setup
|
||||
# Self-contained script to run a test bunker for NOSTR_LOGIN_LITE
|
||||
|
||||
echo "🔐 Starting NIP-46 Bunker Remote Signer..."
|
||||
echo "=============================================="
|
||||
|
||||
# NIP-46 Keys (Generated with NAK for testing)
|
||||
|
||||
BUNKER_SECRET_KEY="a33767c3bd05bda47880119d6665b79e6f0eecdf8d025966b0b59a9366379d01"
|
||||
BUNKER_PUB_KEY="7566048aa9df5b36428f2ce364797f7ac6f6d4a17ee566f0cd3fefcf35146b90"
|
||||
|
||||
|
||||
|
||||
RELAY_URL="wss://relay.laantungir.net"
|
||||
# RELAY_URL="wss://nostr.mom"
|
||||
|
||||
echo "Bunker Configuration:"
|
||||
echo " Public Key: $BUNKER_PUB_KEY"
|
||||
echo " Relay URL: $RELAY_URL"
|
||||
echo " Secret key securely held by bunker process"
|
||||
echo ""
|
||||
|
||||
# Check if nak is installed
|
||||
if ! command -v nak &> /dev/null; then
|
||||
echo "❌ Error: 'nak' command not found"
|
||||
echo "Please install nak from: https://github.com/fiatjaf/nak"
|
||||
echo "Or run: go install github.com/fiatjaf/nak@latest"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "🚀 Starting bunker daemon..."
|
||||
echo "The bunker will display a QR code with the connection URL"
|
||||
echo "Copy the bunker:// URL and paste it into the NOSTR_LOGIN_LITE modal"
|
||||
echo ""
|
||||
echo "Press Ctrl+C to stop the bunker"
|
||||
echo "=============================================="
|
||||
|
||||
# Start the NAK bunker daemon
|
||||
# This listens for NIP-46 requests via the relay and handles signing operations
|
||||
nak bunker --sec "$BUNKER_SECRET_KEY" --qrcode --verbose "$RELAY_URL"
|
||||
Reference in New Issue
Block a user