Skip to content

Add nsec-based login support#106

Open
auggie-lahey wants to merge 2 commits into
vicariousdrama:mainfrom
auggie-lahey:feature/nsec-login
Open

Add nsec-based login support#106
auggie-lahey wants to merge 2 commits into
vicariousdrama:mainfrom
auggie-lahey:feature/nsec-login

Conversation

@auggie-lahey
Copy link
Copy Markdown

Summary

Adds the ability to sign in with an nsec private key, enabling Nostr login for users without a NIP-07 browser extension.

Changes

  • New signInWithNsec function in ui/nostr/nostr.js — decodes nsec, derives pubkey, signs a login event locally using schnorr (via nostr-tools), fetches user metadata, and sets the identity
  • Encrypted nsec storage — the nsec is encrypted with a random key and stored in localStorage, never sent to any server
  • Updated signAndSendEvent — now falls back to stored nsec signing when window.nostr is unavailable, so all Nostr features (follows, zaps, live chat, etc.) work with nsec login
  • Updated getPublicKey — derives pubkey from stored nsec when no extension is present
  • New nsec input UI in ui/views/EnterRoom.jsx — when no NIP-07 extension is detected, users see a "Login with nsec" button that reveals a password input field
  • Bug fix: corrected relative import path in RoomHeader2.jsx (../../nostr/emojiText.js../nostr/emojiText.js)

Test plan

  • Verify nsec login works when no NIP-07 extension is installed
  • Verify extension login still works when NIP-07 extension is present
  • Verify stored nsec is used for signing events (follows, zaps, chat)
  • Build passes with yarn build

🤖 Generated with Claude Code

auggie-lahey and others added 2 commits April 20, 2026 08:31
- Add signInWithNsec function to nostr.js for direct key login
- Store nsec encrypted in localStorage for local event signing
- Modify signAndSendEvent to fallback to stored nsec when no extension
- Update getPublicKey to derive from stored nsec
- Add nsec input UI in EnterRoom when no NIP-07 extension detected
- Fix incorrect relative import path in RoomHeader2.jsx

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Show sign-in status (name, avatar, green badge) on home page
- Add "Sign in with Nostr Extension" and "Sign in with nsec" buttons
- Fetch profile metadata from relays and persist to identity for rooms
- Add sign-out button that clears stored keys and reloads
- Fix updateInfo to always update local state even if server save fails

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant