3.9 KiB
3.9 KiB
🏰 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
# 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 daemonbunker-config.js- Configuration for NOSTR_LOGIN_LITEREADME.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:
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
nak --version
Generate new keys (if needed)
nak key generate # Secret key
echo "your_secret_key_here" | nak key public # Public key
Manual bunker test
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