mirror of
https://github.com/purrgrammer/grimoire.git
synced 2026-06-16 17:48:34 +02:00
ef86b02863e17bbfdf1bc03e072dc83b63ba6060
Implements comprehensive NIP-17 private direct messaging with NIP-59 gift wrapping and NIP-44 encryption for metadata protection. ## Key Features **Gift Wrap Decryption Service** (src/services/gift-wrap.ts): - Automatic syncing of kind 1059 gift wraps from user's DM relays - Efficient decryption using user's private key via signer - Tracks decryption state (pending/success/failed) in IndexedDB - Retries failed decryptions with exponential backoff - Stores unsealed kind 14/15 rumor events locally - Indexes messages by conversation key for fast lookup **Local Storage Schema** (src/services/db.ts): - giftWrapDecryptions: Tracks decryption attempts per gift wrap - unsealedDMs: Stores decrypted messages with full conversation context - Indexed by sender, recipient, conversation key, and timestamps - Supports soft deletion and conversation management **NIP-17 Chat Adapter** (src/lib/chat/adapters/nip-17-adapter.ts): - Parses npub/nprofile/hex identifiers for DM recipients - Creates gift-wrapped messages with double NIP-44 encryption - Randomizes timestamps (±2 days) per NIP-17 spec - Sends copy to sender's DM relays for message history - Loads messages from local unsealed storage (no relay queries) - Supports replies, emoji tags, and blob attachments **Integration**: - Added NIP-17 adapter to chat parser with priority ordering - Auto-starts gift wrap sync on account login (useAccountSync) - Updated chat command help text with NIP-17 examples ## Implementation Details - Double encryption: Rumor → Seal (kind 13) → Gift Wrap (kind 1059) - Ephemeral keys for gift wraps (plausible deniability) - Conversation key: sorted pubkeys for consistent grouping - Supports user's kind 10050 DM relay preferences - Falls back to general relays if DM relays not found - All decryption happens locally - no metadata leakage ## Testing - TypeScript compilation verified (npx tsc --noEmit) - Database schema migration to v18 - Gift wrap manager singleton pattern - RxJS observables for reactive message updates References: - NIP-17: https://github.com/nostr-protocol/nips/blob/master/17.md - NIP-59: https://github.com/nostr-protocol/nips/blob/master/59.md - NIP-44: https://github.com/nostr-protocol/nips/blob/master/44.md
Grimoire
A Nostr protocol explorer and developer tool with a tiling window manager interface.
Features
- Tiling Windows - Each window is a Nostr "app" (profile viewer, event feed, NIP docs, etc.)
- Command Palette - Unix-style commands via
Cmd+Kto open apps and navigate - Multi-workspace - Virtual desktops with independent layouts
- Real-time - Reactive event subscriptions with automatic updates
Stack
React 19, TypeScript, Vite, TailwindCSS, Jotai, Dexie, Applesauce
Getting Started
npm install
npm run dev
Scripts
| Command | Description |
|---|---|
npm run dev |
Start dev server |
npm run build |
Build for production |
npm test |
Run tests in watch mode |
npm run lint |
Lint code |
npm run format |
Format code |
License
MIT
Languages
TypeScript
98.9%
CSS
0.8%
JavaScript
0.3%