A Node-RED node for integrating with the Nostr protocol. This node allows you to connect to Nostr relays, publish events, and subscribe to events in the Nostr network.
A private key is only required if you want to:
- Publish events to relays
- Send encrypted direct messages
- Perform any action that requires signing
For just listening to relays or subscribing to events, no private key is needed.
If you do need to publish events, follow these security guidelines:
-
Generate a separate key pair specifically for your Node-RED automation using services like:
-
Keep the scope of this automation key limited:
- Only give it permissions it actually needs
- Consider it like a "bot account"
- Regularly rotate the key if possible
-
Store the private key securely:
- Use Node-RED's encrypted credentials
- Never share or expose the key
- Don't commit it to version control
This package provides nodes for interacting with Nostr relays, allowing you to:
- Connect to multiple relays simultaneously
- Monitor specific NPUBs for events
- Filter events by type (text notes, DMs, etc.)
- Post events to relays (using a dedicated automation key)
- Support for multiple NIPs (see Supported NIPs section)
- TypeScript support with full type definitions
- Secure credential management
- Automatic reconnection handling
This package uses a hybrid approach to module systems to ensure maximum compatibility:
- Built as CommonJS for Node-RED compatibility
- Handles ESM dependencies through dynamic imports
- Supports both modern and legacy Node.js environments
Built on nostr-websocket-utils for enterprise-grade reliability:
- Automatic Reconnection: Smart backoff strategy for connection drops
- Connection Health: Built-in heartbeat monitoring
- Type Safety: Full TypeScript support
- Error Resilience: Comprehensive error handling
- Memory Efficient: Proper cleanup of resources
- Debug Support: Detailed logging
Run the following command in your Node-RED user directory - typically ~/.node-red
npm install node-red-contrib-nostr
cd ~/.node-red
git clone https://github.com/HumanjavaEnterprises/node-red-contrib-nostr.git
cd node-red-contrib-nostr
npm install
npm run build
git clone https://github.com/HumanjavaEnterprises/node-red-contrib-nostr.git
cd node-red-contrib-nostr
docker compose up -d
Configuration node for managing relay connections:
- Multiple relay support
- Secure private key storage
- Automatic reconnection handling
- Connection status monitoring
- Dynamic import of ESM dependencies
Specialized node for event filtering:
- Filter by event kinds
- Filter by authors (NPUBs)
- Filter by tags
- Time-based filtering
- Custom filter combinations
- Real-time event processing
Dedicated node for NPUB-based filtering:
- Monitor specific NPUBs
- Filter by event types
- Real-time NPUB event tracking
- Automatic hex key conversion
{
"id": "basic-monitor",
"type": "nostr-filter",
"relay": "wss://relay.example.com",
"filterType": "kind",
"eventKinds": [1],
"wires": [["debug"]]
}
{
"id": "npub-track",
"type": "nostr-npub-filter",
"relay": "wss://relay.example.com",
"npubValue": "npub1...",
"eventKinds": [1, 6],
"wires": [["debug"]]
}
The nodes implement comprehensive error handling:
- Invalid private key detection
- Relay connection failures
- Message parsing errors
- NPUB validation
- WebSocket connection issues
npm install
npm run build
npm test
Test coverage includes:
- Unit tests for all nodes
- WebSocket connection handling
- Event filtering logic
- Error handling
docker compose -f docker-compose.dev.yml up
NIP | Description | Status |
---|---|---|
NIP-01 | Basic Protocol | β Implemented |
NIP-02 | Contact List and Petnames | β Implemented |
NIP-03 | OpenTimestamps Attestations | π§ Planned |
NIP-04 | Encrypted Direct Messages | π§ Planned |
NIP-09 | Event Deletion | π§ Planned |
NIP-11 | Relay Information Document | β Implemented |
NIP-15 | End of Stored Events Notice | β Implemented |
NIP-20 | Command Results | β Implemented |
NIP-28 | Public Chat | π§ Planned |
NIP-40 | Expiration Timestamp | π§ Planned |
Legend:
- β Implemented: Fully supported
- π§ Planned: On the roadmap
- β Not Planned: Not currently planned for implementation
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'feat: add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
This module provides nodes for working with Nostr protocol in Node-RED.
- Category: network
- Name: node-red-contrib-nostr
- Types: nostr-relay-config, nostr-filter, nostr-npub-filter
- Description: Node-RED nodes for interacting with Nostr protocol
- Author: Vveerrgg
- Keywords: node-red,nostr,websocket,relay,filter,npub
- Dependencies: @humanjavaenterprises/nostr-tools,nostr-websocket-utils
- Node-RED: >= 2.0.0