# ๐Ÿฐ 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